Repository navigation
feat(prefs): detect Ollama models at a custom Base URL - #59
francescobianco merged 2 commits into
Conversation
An explicit Detect click now probes <Base URL>/models when the Base URL holds a URL the user typed (not empty and not the OpenAI default). The automatic probe when "Ollama (local)" is selected still goes only to localhost, so no non-local host is contacted without a click. - ollama_models_url() normalizes the Base URL: strips spaces and trailing slashes, adds /v1 when missing, and accepts only http and https. - ollama_detect_endpoint() picks the endpoint for an automatic or explicit detection. - Status messages name the probed host and port (never credentials). - Same 2 s timeout and bodyless GET as before. Closes openapi#57
The model list can now come from a server on another machine.
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
francescobianco
left a comment
There was a problem hiding this comment.
Thanks @AdityaWagh06, this is exactly what #57 asked for, and it went further than the plan: the automatic probe stays on localhost and only an explicit Detect click uses the typed Base URL;
invalid schemes and ports are rejected before any request; the status line shows host:port only, so credentials never reach the UI; the fake-server tests cover the whole acceptance list, and the screenshots with a real
non-default URL are a great touch. Approving and merging. Thank you again! 🙏
Summary
An explicit Detect click now probes
<Base URL>/modelswhen the Base URL holds a URL the user typed (not empty and not the OpenAI default). Closes #57.What stays the same
localhost:11434. No non-local host is contacted without a click.Changes
ollama_models_url(): strips spaces and a trailing/, adds/v1when missing, accepts onlyhttp/https. Anything else shows an error in Preferences and sends no request.ollama_detect_endpoint(): localhost for the automatic probe, the typed URL for an explicit click.Screenshots
Detect with a non-default Base URL (
http://172.28.34.102:11500/v1, a server on another network address and port):Detect when nothing answers at that URL:
The screenshots were taken on Ubuntu 24.04 (GTK 4.14, libadwaita 1.5) with a small stand-in server that answers
GET /v1/modelsthe same way Ollama does.Tests
Fake-server tests for a custom Base URL (with and without a trailing
/and/v1), refused connection, timeout, non-http schemes and invalid ports, plus a check that the automatic probe stays on localhost. All existing tests pass (tests/test_openai_compatible.py: 43 passed;tests/test_core.py: passed).