From 9c27848e427482d5862ceaff0cde310f32726097 Mon Sep 17 00:00:00 2001 From: Vineet Kumar Date: Sun, 26 Apr 2026 19:53:15 -0400 Subject: files/emacs: make gptel more daily-drivable I'm now at the stage of consciously stopping myself from opening the web interfaces and asking via gptel which is nice actually --- epistemia/files/emacs/.config/emacs/init.el | 46 ++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/epistemia/files/emacs/.config/emacs/init.el b/epistemia/files/emacs/.config/emacs/init.el index 68ac223..d0f0b1e 100644 --- a/epistemia/files/emacs/.config/emacs/init.el +++ b/epistemia/files/emacs/.config/emacs/init.el @@ -545,33 +545,51 @@ ;;;;;;;;; ;; LLM ;; ;;;;;;;;; +(defun vin/gptel-mode-auto () + "Ensure that this file opens with `gptel-mode' enabled." + ;; taken from https://github.com/karthink/gptel/wiki/Auto%E2%80%90restore-gptel%E2%80%90mode-in-chat-buffers + (save-excursion + (let ((enable-local-variables t)) ; Ensure we can modify local variables + (if (and (save-excursion + (goto-char (point-min)) + (looking-at ".*-\\*-"))) ; If there's a -*- line + ;; First remove any existing eval, then add the new one + (modify-file-local-variable-prop-line + 'eval nil 'delete)) + ;; Always add our eval + (add-file-local-variable-prop-line + 'eval '(and (fboundp 'gptel-mode) (gptel-mode 1)))))) + (use-package gptel :after age ; because of ~/.authinfo.age :config - (gptel-make-openai "llama-swap" - :protocol "http" - :host "llm.demiurge.epistemia" - :endpoint "/v1/chat/completions" - :stream t - :models '(Qwen3.5-27B - Qwen3.5-35B-A3B - Rocinante-X-12B-v1 - Ministral-3-14B-Instruct-2512)) + (setq gptel-backend + (gptel-make-openai "llama-swap" + :protocol "http" + :host "llm.demiurge.epistemia" + :endpoint "/v1/chat/completions" + :stream t + :models '(Qwen3.6-27B + Qwen3.6-35B-A3B + Gemma4-26B-A4B + Gemma4-31B))) + (setq gptel-model 'Qwen3.6-35B-A3B) (gptel-make-openai "OpenRouter" :host "openrouter.ai" :endpoint "/api/v1/chat/completions" :stream t :key (auth-source-pick-first-password :host "openrouter.ai") - :models '(minimax/minimax-m2.7 - minimax/minimax-m2.5:free - anthropic/claude-sonnet-4.6)) + :models '(moonshotai/kimi-k2.6 + deepseek/deepseek-v4-pro)) :custom - (gptel-model "llama-swap:Qwen3.5-35B-A3B") + (gptel-default-mode #'org-mode) + (gptel-response-prefix-alist '((org-mode . "**** Response\n"))) (gptel-temperature nil) (gptel-directives '((default . "You are a large language model living in Emacs and a helpful assistant. Respond 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.")))) + (writing . "You are a large language model and a writing assistant. Respond concisely."))) + :hook (gptel-save-state . vin/gptel-mode-auto)) (use-package gptel-agent :after gptel -- cgit v1.2.3