Skip to content

feat(prefs): detect Ollama models at a custom Base URL - #59

Open
AdityaWagh06 wants to merge 2 commits into
openapi:mainfrom
AdityaWagh06:feat/ollama-detect-custom-base-url
Open

AdityaWagh06 wants to merge 2 commits into
openapi:mainfrom
AdityaWagh06:feat/ollama-detect-custom-base-url

Conversation

@AdityaWagh06

Copy link
Copy Markdown
Contributor

Summary

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). Closes #57.

What stays the same

  • The automatic probe when "Ollama (local)" is selected still goes only to localhost:11434. No non-local host is contacted without a click.
  • Same 2 s timeout, one GET with no body, no document content sent.
  • A Base URL the user typed is never overwritten.

Changes

  • ollama_models_url(): strips spaces and a trailing /, adds /v1 when missing, accepts only http/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.
  • Status messages name the probed host and port, e.g. "No Ollama server found at 192.168.1.50:11434". Credentials in the URL are never shown.
  • The model row subtitle now says "Discovered from Ollama server" (it can be a remote one now).
  • Removed the extra blank line you mentioned in feat(prefs): detect a local Ollama server and offer its models #46.

Screenshots

Detect with a non-default Base URL (http://172.28.34.102:11500/v1, a server on another network address and port):

1-detect-found

Detect when nothing answers at that URL:

2-detect-not-found

The screenshots were taken on Ubuntu 24.04 (GTK 4.14, libadwaita 1.5) with a small stand-in server that answers GET /v1/models the 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).

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.
Copilot AI balanced review requested due to automatic review settings November 19, 2026 09:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Detect Ollama models at a custom Base URL

2 participants