summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2025-07-13 18:36:41 -0500
committerCraig Jennings <c@cjennings.net>2025-07-13 18:36:41 -0500
commit2f9c87e0f9ea800cad9c97fe14ae1ec629f72fe4 (patch)
treeb2836575c9881bef1187a8ca01173456fc16a5b0 /modules
parentdb6be555e9cfde016c69e336c542cd75392b8d53 (diff)
downloaddotemacs-2f9c87e0f9ea800cad9c97fe14ae1ec629f72fe4.tar.gz
dotemacs-2f9c87e0f9ea800cad9c97fe14ae1ec629f72fe4.zip
ai-config changes
- use defvars for directives - created a toggle function that only actually works when gptel is already up and running. - bind the toggle function to f9
Diffstat (limited to 'modules')
-rw-r--r--modules/ai-config.el58
1 files changed, 36 insertions, 22 deletions
diff --git a/modules/ai-config.el b/modules/ai-config.el
index df943554..643bac0b 100644
--- a/modules/ai-config.el
+++ b/modules/ai-config.el
@@ -23,39 +23,53 @@
;; ----------------------------------- GPTel -----------------------------------
;; integration with ChatGPT and other large language models.
+(defvar default-directive
+ "You are a large language model living in Emacs. You understand philosophy, critical theory, and comparative
+ literature at a university graduate student level. You are concise and always provide references to source material.")
+
+(defvar code-only-directive
+ "You are a large language model living in Emacs. You are an expert in emacs-lisp, Python, Golang, and Shell scripting.
+ You encourage unit testing and always provide unit tests when you provide code.")
+
+(defvar writing-directive
+ "You are a large language model and a writing assistant. Respond concisely.")
+
+(defvar chat-directive
+ "You are a large language model and a funny conversation partner who asks good questions.")
+
+
+(defun toggle-gptel ()
+ "Toggle the visibility of the ChatGPT buffer."
+ (interactive)
+ (let ((buffer (get-buffer "*ChatGPT*")))
+ (if (and buffer (get-buffer-window buffer))
+ (delete-window (get-buffer-window buffer))
+ (if buffer
+ (display-buffer-in-side-window buffer '((side . right) (window-width . 0.4)))
+ (gptel)))))
+
(use-package gptel
:defer t
:commands (gptel gptel-send)
:bind
- ("C-h G" . gptel)
- (:map gptel-mode-map
- ("C-<return>" . gptel-send))
+ (("C-h G" . gptel)
+ ("<f9>" . toggle-gptel)
+ (:map gptel-mode-map
+ ("C-<return>" . gptel-send)))
:custom
- ;; (gptel-model "gpt-3.5-turbo-16k") ;; next best alternative
(gptel-model "gpt-4")
(gptel-default-mode 'org-mode)
:config
(setq gptel-directives
- '((default
- . "You are a large language model living in Emacs. You are an expert
- in emacs-lisp, Python, Golang, and Shell scripting. You encourage unit testing
- code and propose unit tests when you provide code. Please be accurate and
- concise in your responses.")
- (code-only
- . "You are a large language model living in Emacs. You are an expert
- in emacs-lisp, Python, Golang, and Shell scripting. You encourage unit testing
- code and propose unit tests when you provide code. Please be accurate and
- concise in your responses.")
- (writing
- . "You are a large language model and a writing assistant. Respond
- concisely.")
- (chat
- . "You are a large language model and a conversation partner. Respond
- concisely.")))
-
- ;; grab the secret from the auth file
+ `((default . ,default-directive)
+ (code-only . ,code-only-directive)
+ (writing . ,writing-directive)
+ (chat . ,chat-directive)))
+
+ ;; Grab the secret from the auth file
(setq auth-sources `((:source ,authinfo-file)))
(setq gptel-api-key (auth-source-pick-first-password :host "api.openai.com")))
+
(provide 'ai-config)
;;; ai-config.el ends here