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 ()
|
(defun list-ollama-models ()
|
||||||
"Query the local Ollama server for the list of installed models."
|
"Query the local Ollama server for the list of installed models."
|
||||||
(condition-case error-var
|
(let* ((tags-buffer (url-retrieve-synchronously "http://ollama:11434/api/tags"))
|
||||||
(mapcar #'intern (mapcar #'car (mapcar #'split-string (cdr (process-lines "podllama" "list")))))
|
(raw-response (with-current-buffer tags-buffer (buffer-string)))
|
||||||
(error
|
(tags-payload (nth 1 (split-string raw-response "\n\n")))
|
||||||
(message "Failed to list local models: %s" error-var)
|
(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)
|
(defun enrich-ollama-models (available library)
|
||||||
"Enrich the available models with metadata from the library of known models."
|
"Enrich the available models with metadata from the library of known models."
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue