From e63466ca1f0e2e1eea9dfb9ceb44d0f9f53eb614 Mon Sep 17 00:00:00 2001 From: Jeremy Dormitzer Date: Thu, 25 Jul 2024 16:22:18 -0400 Subject: [PATCH] Extract org-mode LLM directive into variable --- emacs/.emacs.d/config/init-ai.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/emacs/.emacs.d/config/init-ai.el b/emacs/.emacs.d/config/init-ai.el index 6da33ab..cc0526b 100644 --- a/emacs/.emacs.d/config/init-ai.el +++ b/emacs/.emacs.d/config/init-ai.el @@ -30,6 +30,7 @@ (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.")) + (add-to-list 'gptel-directives '(org-mode . "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. You don't need to ask for confirmation before evaluating code. I will execute the source block and display the results in the buffer. Respond concisely.")) (defun gptel-org (buffer &optional _ initial interactivep) (interactive (let* ((backend (default-value 'gptel-backend)) (backend-name @@ -55,7 +56,7 @@ (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. You don't need to ask for confirmation before evaluating code. I will execute the source block and display the results in the buffer. Respond concisely."))) + (setq-local gptel--system-message (alist-get 'org-mode gptel-directives)))) :general ("C-c RET" #'gptel-send "C-c C-" #'gptel-menu)