diff options
| author | Craig Jennings <c@cjennings.net> | 2025-09-02 12:36:34 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2025-09-02 12:36:34 -0500 |
| commit | a64ff2b145b2ef83e8b087aa18cbab165232e8a4 (patch) | |
| tree | b3bd670071ac10673660f5789839442a524fcaa5 /modules | |
| parent | 0c137382a7387491fce33f257973f7350a790124 (diff) | |
| download | dotemacs-a64ff2b145b2ef83e8b087aa18cbab165232e8a4.tar.gz dotemacs-a64ff2b145b2ef83e8b087aa18cbab165232e8a4.zip | |
gptel should use projectile to add file to context if in project
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/ai-config.el | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/modules/ai-config.el b/modules/ai-config.el index 18c1e8cb..72219c1b 100644 --- a/modules/ai-config.el +++ b/modules/ai-config.el @@ -140,14 +140,30 @@ ;; ---- Auth: pick the API key from your auth source (setq auth-sources `((:source ,authinfo-file))) (setq gptel-api-key (auth-source-pick-first-password :host "api.openai.com")) - ;; (setq anthropic-api-key (auth-source-pick-first-password :host "api.anthropic.com")) + (setq anthropic-api-key (auth-source-pick-first-password :host "api.anthropic.com")) - ;; ;; Setup Anthropic's Claude - ;; (setq gptel-backend (gptel-make-anthropic "Claude" - ;; :stream t :key anthropic-api-key)) - ;; (setq gptel-model 'claude-3-opus-4-20250514) + ;; Setup Anthropic's Claude + (setq gptel-backend (gptel-make-anthropic "Claude" + :stream t :key anthropic-api-key)) + (setq gptel-model 'claude-3-opus-4-20250514) + ) ;; end use-package declaration - ) + +(with-eval-after-load 'projectile + (defun cj/gptel-add-file () + "Add a file to the GPTel context. +If inside a Projectile project, prompt from the project's file list; +otherwise use =read-file-name'." + (interactive) + (let* ((in-proj (and (fboundp 'projectile-project-p) + (projectile-project-p))) + (file (if in-proj + (projectile-completing-read + "GPTel add file: " + (projectile-current-project-files)) + (read-file-name "GPTel add file: ")))) + (gptel-add-file file))) + (define-key ai-keymap (kbd "f") #'cj/gptel-add-file)) ;; -------------------------------- GPTel-Magit -------------------------------- |
