Skip to content

feat(prefs): detect a local Ollama server and offer its models - #46

Merged
francescobianco merged 1 commit into
openapi:mainfrom
AdityaWagh06:feat/ollama-model-detection
Oct 27, 2026
Merged

francescobianco merged 1 commit into
openapi:mainfrom
AdityaWagh06:feat/ollama-model-detection

Conversation

@AdityaWagh06

Copy link
Copy Markdown
Contributor

feat(prefs): detect a local Ollama server and offer its models

Closes #19
Refs #5

Summary

Adds local Ollama model discovery to Preferences. When users select Ollama (local) or click Detect, the app requests http://localhost:11434/v1/models with a 2-second timeout and displays the available models.

  • On-demand detection: No requests at startup or when other providers are selected.
  • Privacy: Sends a GET request to localhost; no document content is sent.
  • Base URL: Prefills the Ollama URL only when the field is empty or still contains the OpenAI default. Custom URLs are preserved.
  • Model selection: Supports discovered models, saved selections, and custom model names.
  • Error handling: Displays a status message if Ollama is unavailable or returns an invalid response.
  • Responsive UI: Runs detection in a background thread and updates the UI through GLib.idle_add.

Implementation

  • gknowledge/providers/openai_compatible.py — Model discovery and helper functions.
  • gknowledge/ui/preferences.py — Detection button, model dropdown, status, and selection persistence.
  • tests/test_openai_compatible.py — Tests for discovery, connection errors, timeouts, malformed responses, URL prefill, and model selection.

Tests

  • make test — passed
  • python -m pytest -q — 36 passed
  • make check — passed
  • git diff --check — passed

Flatpak sandbox checks also passed for localhost reachability, on-demand detection, model selection, URL preservation, and the no-server scenario.

Screenshots

  • Ollama models found

  • No Ollama server found

ollama-models-found ollama-no-server

Copilot AI balanced review requested due to automatic review settings October 20, 2026 15:11

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 reached their quota limit.

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

Copy link
Copy Markdown
Member

Thanks a lot @AdityaWagh06, and sorry for the week of silence: this is a really solid PR. Probing only on user action, always against the local default and with a 2 s timeout is exactly the privacy behaviour I wanted, and the fake-server tests (bodyless GET, refused connection, timeout, malformed payloads) are better than most of the suite.

I've read the whole diff; two small, non-blocking notes:

  1. openai_compatible.py has three blank lines before DEFAULT_OLLAMA_BASE_URL; two is enough.
  2. Detect always probes localhost:11434, even when the Base URL points to an Ollama on another machine (e.g. http://192.168.1.50:11434/v1). That's the right default; a later follow-up could let an explicit Detect click use the Base URL when the user has typed one. Happy to open an issue for it if you'd like to take it.

CI for fork PRs needs a maintainer to approve the run; that's on me now, and I'll merge once it's green. Since #5 asks for the same thing as #19, I'll close both with this PR.

@francescobianco
francescobianco merged commit 476250e into openapi:main Oct 27, 2026
4 checks passed
@francescobianco

Copy link
Copy Markdown
Member

CI is green on every job (test, metadata, deb, flatpak), so this is merged. Thanks again @AdityaWagh06! This is your third contribution after #1 and #19, and Ollama detection is the kind of feature people notice the first time they open Preferences. It will ship in the next release.

If you'd like to see what else we build, have a look at (and maybe follow) our org, @openapi. Our main work is certified data: company records, registries and other official sources served through APIs, plus the SDKs and MCP servers around them. We see our role as a trusted source that grounds AI in domains where accuracy matters, like legal, engineering and compliance. gknowledge is the local, offline side of the same idea.

The follow-up for Detect with a custom Base URL is still yours if you want it. Just say so and I'll open the issue.

@AdityaWagh06

Copy link
Copy Markdown
Contributor Author

Thanks, Francesco! I'd be happy to work on the custom Base URL detection follow-up. Please open the issue, and I'll take a look.

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 a local Ollama server in Preferences

3 participants