summaryrefslogtreecommitdiff
path: root/modules/ai-config.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
committerCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
commit754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch)
treef1190704f78f04a2b0b4c977d20fe96a828377f1 /modules/ai-config.el
new repository
Diffstat (limited to 'modules/ai-config.el')
-rw-r--r--modules/ai-config.el51
1 files changed, 51 insertions, 0 deletions
diff --git a/modules/ai-config.el b/modules/ai-config.el
new file mode 100644
index 00000000..14380a2b
--- /dev/null
+++ b/modules/ai-config.el
@@ -0,0 +1,51 @@
+;;; ai-config.el --- Configuration for AI Integrations -*- lexical-binding: t; -*-
+
+;;; Commentary:
+
+;; There are several workflows available. Here are the ones I use most.
+
+;; - Launch GPTel and chat with the AI in a separate buffer.
+;; Chatting is fine, but it can mean cutting and pasting code back and forth
+;; between buffers.
+
+;; - Select a region and launch GPTel.
+;; The region is automatically inserted into the buffer making it easy to
+;; simply ask a question after it's read the code.
+
+;; Note that you can save a file, then turn on gptel-mode to resume your
+;; conversation.
+
+;; Remember that sending the message requires C-<return>.
+
+;;; Code:
+
+;; ----------------------------------- GPTel -----------------------------------
+;; integration with ChatGPT and other large language models.
+
+(use-package gptel
+ :defer .5
+ :bind
+ ("C-h G" . 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 and a careful and
+ knowledgeable emacs-lisp programmer. Respond accurately and concisely.")
+ (programming
+ . "You are a large language model and a careful programmer. Provide code
+ and only code as output without any additional text, prompt or note.")
+ (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.")))
+
+ (setq gptel-api-key (auth-source-pick-first-password :host "api.openai.com")))
+
+(provide 'ai-config)
+;;; ai-config.el ends here.