Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enumerate Ollama models on the server pointed to by :host directive #447

Open
vick08 opened this issue Oct 30, 2024 · 4 comments
Open

Enumerate Ollama models on the server pointed to by :host directive #447

vick08 opened this issue Oct 30, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@vick08
Copy link

vick08 commented Oct 30, 2024

Presently, I have to add/remove all Ollama models manually modifying the ":models" string.
Would it be possible for GPTEL to enumerate the existing models on the fly when the transient menu opens, just like it is done for Anthropic, Gemini and OpenAI models?
Thanks for considering my request and apologies if I am missing something.

@karthink karthink added the enhancement New feature or request label Nov 5, 2024
@karthink
Copy link
Owner

karthink commented Nov 5, 2024

This has come up before, see #394. Fetching it easy enough, the question is when it should be done.

We don't want gptel to be making network request at the time that (gptel-make-ollama ...) is evaluated, because this code lives in the user's configuration. I would be quite annoyed if evaluating my settings for a package in a use-package block caused network requests to be created.

@vick08
Copy link
Author

vick08 commented Nov 6, 2024

I understand. Perhaps in the Transient menu there could be an option under the "models" submenu to populate the Ollama list?
The way things stand now, as I am sure you understand, we have to modify the :models every time a model is added or removed. Therefore, some kind of dynamic polling for Ollama models would make this a consistent behavior with how other services are enumerated (Anthropic, Gemini, Open AI, etc).
Thank you for considering this request.

@karthink
Copy link
Owner

karthink commented Nov 13, 2024

as I am sure you understand, we have to modify the :models every time a model is added or removed.

Do you add and remove models from Ollama often enough that this is a concern? I'm curious. I can't run Ollama right now, but back when I had an Ollama-capable PC, I changed models maybe twice in three months.

there could be an option under the "models" submenu to populate the Ollama list

There is no "models" submenu.

Therefore, some kind of dynamic polling for Ollama models would make this a consistent behavior with how other services are enumerated

True. I just don't know where to put this code in the usual course of using gptel.

There is one additional concern. How should conflicts between the :models field of the backend definition and the polled list of models be resolved? A simple merge will not work, here's an example of why:

Models explicitly defined for gptel:

:models
'(model1
  (model2
   :capabilities (media nosystem)
   :description "description2"
   :mime-types ("image/jpeg" "image/png"))
  model3)

Models returned from API call, after processing:

:models
'((model1
   :description "description1"
   :context-window 32)
  (model2
   :capabilities (media)
   :description "description2_alternate"
   :mime-types ("image/png" "image/heic")))

It's clear how to update model1 here. But the other differences are not simple to resolve:

  • Should model3 be removed?
  • model2 includes a plist with arbitrary metadata attached. How should the two plists be merged?

@karthink
Copy link
Owner

karthink commented Nov 13, 2024

In the branch feature-ollama-auto-update, I've added a function to fetch and merge the available Ollama models into the list of the active backend, assuming the Ollama backend is the active one. It can be used as follows:

(gptel--ollama-fetch-models) ;; Update active backend if it's of type Ollama
(gptel--ollama-fetch-models "Ollama") ;; Update backend named "Ollama"
;; OR
(gptel--ollama-fetch-models some-backend) ;; Update backend "some-backend"

You can test it out. The merge strategy is non-destructive, and when there is a conflict it prioritizes provided metadata over metadata returned by Ollama.

The problem, as discussed, is where/when this code should run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants