From 06d2a14d0914bcf966ed24edd9f8a2b086e627bf Mon Sep 17 00:00:00 2001 From: Ohad Livne Date: Mon, 17 Nov 2025 23:21:31 +0200 Subject: [PATCH 1/8] Add an Emacs Lisp lexical binding cookie --- .config/emacs/site-lisp/local-models.el | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.config/emacs/site-lisp/local-models.el b/.config/emacs/site-lisp/local-models.el index cddf6e8..2af6bd6 100644 --- a/.config/emacs/site-lisp/local-models.el +++ b/.config/emacs/site-lisp/local-models.el @@ -1,3 +1,5 @@ +;; -*- lexical-binding: t; -*- + (defconst gptel--local-models '( ;; keep-sorted start From 90c310302de79175f57b6f4777987a201522b96d Mon Sep 17 00:00:00 2001 From: Ohad Livne Date: Mon, 17 Nov 2025 22:47:21 +0200 Subject: [PATCH 2/8] Allow sharing configurations between host and containers --- .config/emacs/init.el | 1 + .config/environment.d/ollama.conf | 3 +++ .config/hosts | 1 + 3 files changed, 5 insertions(+) create mode 100644 .config/environment.d/ollama.conf create mode 100644 .config/hosts diff --git a/.config/emacs/init.el b/.config/emacs/init.el index 5a3e8cb..497d7d8 100644 --- a/.config/emacs/init.el +++ b/.config/emacs/init.el @@ -343,6 +343,7 @@ :key 'gptel-api-key-from-auth-source ) (gptel-make-ollama "Ollama" + :host "ollama:11434" :stream t :models (enrich-ollama-models (list-ollama-models) gptel--local-models) ) diff --git a/.config/environment.d/ollama.conf b/.config/environment.d/ollama.conf new file mode 100644 index 0000000..6105efa --- /dev/null +++ b/.config/environment.d/ollama.conf @@ -0,0 +1,3 @@ +# keep-sorted start +HOSTALIASES=~/.config/hosts +# keep-sorted end diff --git a/.config/hosts b/.config/hosts new file mode 100644 index 0000000..4aa6d0b --- /dev/null +++ b/.config/hosts @@ -0,0 +1 @@ +ollama localhost From fd645f60a28e5608453035da9677405d3a2f1815 Mon Sep 17 00:00:00 2001 From: Ohad Livne Date: Mon, 17 Nov 2025 23:45:11 +0200 Subject: [PATCH 3/8] Retrieve model list directly from the Ollama server --- .config/emacs/init.el | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.config/emacs/init.el b/.config/emacs/init.el index 497d7d8..0da29e5 100644 --- a/.config/emacs/init.el +++ b/.config/emacs/init.el @@ -307,11 +307,12 @@ (defun list-ollama-models () "Query the local Ollama server for the list of installed models." - (condition-case error-var - (mapcar #'intern (mapcar #'car (mapcar #'split-string (cdr (process-lines "podllama" "list"))))) - (error - (message "Failed to list local models: %s" error-var) - ()))) + (let* ((tags-buffer (url-retrieve-synchronously "http://ollama:11434/api/tags")) + (raw-response (with-current-buffer tags-buffer (buffer-string))) + (tags-payload (nth 1 (split-string raw-response "\n\n"))) + (models (gethash "models" (json-parse-string tags-payload))) + (model-names (mapcar (lambda (model) (gethash "name" model)) models))) + model-names)) (defun enrich-ollama-models (available library) "Enrich the available models with metadata from the library of known models." From 55d5c907e200462f7c595fb7f240619b7142181e Mon Sep 17 00:00:00 2001 From: Ohad Livne Date: Thu, 13 Nov 2025 00:15:04 +0200 Subject: [PATCH 4/8] Give the vault container access to the Ollama server --- .local/bin/vaulter | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.local/bin/vaulter b/.local/bin/vaulter index f12dd73..4409d0e 100755 --- a/.local/bin/vaulter +++ b/.local/bin/vaulter @@ -11,5 +11,5 @@ podman --transient-store run --rm -ti \ --mount type=bind,readonly=true,source="$(systemd-path user)"/.keys/vaults,target=/root/.age/key \ --mount type=bind,readonly=true,source="$(systemd-path user)"/.keys/vaults.pub,target=/root/.age/key.pub \ --mount type=bind,source="$(systemd-path user)"/Vaults,target=/root/Vaults \ - --network none \ + --network systemd-ollama \ vaulter:latest From 91c52deda9825014712cd660eec95dd5d5d6fb50 Mon Sep 17 00:00:00 2001 From: Ohad Livne Date: Tue, 18 Nov 2025 08:51:16 +0200 Subject: [PATCH 5/8] Share the local model library into the vault container --- .local/bin/vaulter | 1 + 1 file changed, 1 insertion(+) diff --git a/.local/bin/vaulter b/.local/bin/vaulter index 4409d0e..876832f 100755 --- a/.local/bin/vaulter +++ b/.local/bin/vaulter @@ -8,6 +8,7 @@ podman --transient-store run --rm -ti \ --env XDG_RUNTIME_DIR=/tmp \ --hostname localhost \ --mount type=bind,source="${XDG_RUNTIME_DIR}"/"${WAYLAND_DISPLAY}",target=/tmp/"${WAYLAND_DISPLAY}" \ + --mount type=bind,source="$(systemd-path user-configuration)"/emacs/site-lisp/local-models.el,target=/root/.config/emacs/site-lisp/local-models.el \ --mount type=bind,readonly=true,source="$(systemd-path user)"/.keys/vaults,target=/root/.age/key \ --mount type=bind,readonly=true,source="$(systemd-path user)"/.keys/vaults.pub,target=/root/.age/key.pub \ --mount type=bind,source="$(systemd-path user)"/Vaults,target=/root/Vaults \ From 3de4e0ab1e72082be88c8189d2db88d0c927f770 Mon Sep 17 00:00:00 2001 From: Ohad Livne Date: Tue, 18 Nov 2025 23:40:13 +0200 Subject: [PATCH 6/8] Add Devstral to the model library --- .config/emacs/site-lisp/local-models.el | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.config/emacs/site-lisp/local-models.el b/.config/emacs/site-lisp/local-models.el index 2af6bd6..93635a9 100644 --- a/.config/emacs/site-lisp/local-models.el +++ b/.config/emacs/site-lisp/local-models.el @@ -20,6 +20,11 @@ :context-window 32 :cutoff-date "2023-10" ) + ( + hf.co/unsloth/Devstral-Small-2507-GGUF:latest + :description "Agentic LLM for software engineering tasks" + :context-window 128 + ) ( llama3.2:latest :description "Instruction-tuned model optimized for multilingual dialogue" From 1756c8c80253e4b85e843384c328658288995e94 Mon Sep 17 00:00:00 2001 From: Ohad Livne Date: Tue, 18 Nov 2025 23:42:28 +0200 Subject: [PATCH 7/8] Switch to a more powerful default model --- .config/emacs/init.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.config/emacs/init.el b/.config/emacs/init.el index 0da29e5..abf0b8e 100644 --- a/.config/emacs/init.el +++ b/.config/emacs/init.el @@ -335,7 +335,7 @@ (gptel-default-mode 'org-mode) (gptel-expert-commands t) (gptel-highlight-methods '(face margin)) - (gptel-model 'llama3.2:latest) + (gptel-model 'hf.co/unsloth/Devstral-Small-2507-GGUF:latest) ;; keep-sorted end :preface (load "local-models.el") From 45e530a9839a605b9d6b69062f5d48e7cd0a3ccb Mon Sep 17 00:00:00 2001 From: Ohad Livne Date: Tue, 18 Nov 2025 23:43:13 +0200 Subject: [PATCH 8/8] Make the default system prompt more fun --- .config/emacs/init.el | 1 + 1 file changed, 1 insertion(+) diff --git a/.config/emacs/init.el b/.config/emacs/init.el index abf0b8e..3309767 100644 --- a/.config/emacs/init.el +++ b/.config/emacs/init.el @@ -331,6 +331,7 @@ ;; keep-sorted end :custom ;; keep-sorted start + (gptel--system-message "You are a sassy, sharp-tongued personal assistant. I need you to assist me in crafting responses to questions, dripping with ascerbic wit and sarcasm.") (gptel-backend (gptel-get-backend "Ollama")) (gptel-default-mode 'org-mode) (gptel-expert-commands t)