Add gptel-org function
Implemented a gptel-org function to allow interacting with GPTel within an Org-Mode buffer, setting the appropriate system message for context. Updated init-org.el to load Emacs-Lisp and Python Babel languages and disabled org-confirm-babel-evaluate for smoother code execution.
This commit is contained in:
parent
a7b98cad02
commit
ed63a1ea0f
@ -30,11 +30,38 @@
|
||||
(setq gptel-backend (car backend)
|
||||
gptel-model (cadr backend))))
|
||||
(add-to-list 'gptel-directives '(shell-command . "You are a command line helper. Generate shell commands that do what is requested, without any additional description or explanation. Reply in plain text with no Markdown or other syntax. Reply with the command only."))
|
||||
(defun gptel-org (buffer &optional _ initial interactivep)
|
||||
(interactive (let* ((backend (default-value 'gptel-backend))
|
||||
(backend-name
|
||||
(format "*%s*" (gptel-backend-name backend))))
|
||||
(list (read-buffer "Create or choose gptel buffer: "
|
||||
(generate-new-buffer-name backend-name) nil ; DEFAULT and REQUIRE-MATCH
|
||||
(lambda (b) ; PREDICATE
|
||||
(let ((buffer (get-buffer (or (car-safe b) b))))
|
||||
(and
|
||||
(with-current-buffer buffer (eq major-mode 'org-mode))
|
||||
(buffer-local-value 'gptel-mode buffer)))))
|
||||
(condition-case nil
|
||||
(gptel--get-api-key
|
||||
(gptel-backend-key backend))
|
||||
((error user-error)
|
||||
(setq gptel-api-key
|
||||
(read-passwd
|
||||
(format "%s API key: " backend-name)))))
|
||||
(and (use-region-p)
|
||||
(buffer-substring (region-beginning)
|
||||
(region-end)))
|
||||
t)))
|
||||
(let ((gptel-default-mode #'org-mode))
|
||||
(gptel buffer nil initial interactivep))
|
||||
(with-current-buffer buffer
|
||||
(setq-local gptel--system-message "You are a large language model living in an Emacs Org-Mode buffer and a helpful assistant. You may evaluate code when necessary by outputting an Org-Mode source block. I will execute the source block and display the results in the buffer. Respond concisely.")))
|
||||
:general
|
||||
("C-c RET" #'gptel-send
|
||||
"C-c C-<return>" #'gptel-menu)
|
||||
(ai-map
|
||||
"g" #'gptel
|
||||
"o" #'gptel-org
|
||||
"s" #'gptel-send
|
||||
"m" #'gptel-menu
|
||||
"b" #'gptel-select-backend
|
||||
|
@ -37,7 +37,9 @@ DATE should be in the format \"YYYY-MM-DD\". If called interactively, default to
|
||||
(org-find-daily-note (format-time-string "%Y-%m-%d")))
|
||||
(org-babel-do-load-languages
|
||||
'org-babel-load-languages
|
||||
'((plantuml . t)))
|
||||
'((emacs-lisp . t)
|
||||
(plantuml . t)
|
||||
(python . t)))
|
||||
:custom
|
||||
(org-modules '(ol-doi
|
||||
ol-w3m
|
||||
@ -88,6 +90,7 @@ DATE should be in the format \"YYYY-MM-DD\". If called interactively, default to
|
||||
("\\.x?html?\\'" . default)))
|
||||
(org-plantuml-exec-mode 'jar)
|
||||
(org-plantuml-jar-path (expand-file-name "~/plantuml/plantuml.jar"))
|
||||
(org-confirm-babel-evaluate nil)
|
||||
:general
|
||||
(leader-map "oa" #'org-agenda)
|
||||
(leader-map "oc" #'org-capture)
|
||||
|
Loading…
Reference in New Issue
Block a user