From fd645f60a28e5608453035da9677405d3a2f1815 Mon Sep 17 00:00:00 2001 From: Ohad Livne Date: Mon, 17 Nov 2025 23:45:11 +0200 Subject: [PATCH] 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."