Retrieve model list directly from the Ollama server
This commit is contained in:
parent
90c310302d
commit
fd645f60a2
1 changed files with 6 additions and 5 deletions
|
|
@ -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."
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue