Skip to content

ollama support - #128

Merged
BaaRai merged 2 commits into
BaaRai:mainfrom
glauberportella:develop
Oct 25, 2026
Merged

BaaRai merged 2 commits into
BaaRai:mainfrom
glauberportella:develop

Conversation

@glauberportella

Copy link
Copy Markdown
Contributor

Adds Ollama support for LLM models.

@glauberportella glauberportella changed the title ollama llm ollama support Oct 23, 2026
@BaaRai

BaaRai commented Oct 25, 2026

Copy link
Copy Markdown
Owner

Thanks for this. The design is careful where it matters: the keyless sentinel, the forced default base URL, and the placeholder bearer so an empty key can never fall back to OpenAI's public endpoint. I applied the patch on current main and verified it: go build, go vet, the web typecheck and all four of your tests pass, including the DB-backed lifecycle test.

Two small things I am fixing on top before merging:

  1. FromEnv sets c.APIKey = oaiKey for the ollama case, so an exported OPENAI_API_KEY would be sent as the bearer token to the Ollama endpoint. That contradicts your own comment in NewProvider and the doc line saying credentials are unused for ollama. Fix: do not inherit it for this format.
  2. ConfigFrom only strips /chat/completions, so the natural Ollama URL (http://host:11434, without /v1) would send chat requests to /chat/completions and 404, while pgListModels already normalizes by appending /v1. Fix: append /v1 when it is missing.

Both are small, with a test assertion each. I will push them to your branch so this PR stays the merge point.

Two review fixes on top of the Ollama provider:

FromEnv no longer inherits OPENAI_API_KEY for the ollama format. Ollama
ignores the bearer token, so inheriting the cloud key could only ship it to
the local or LAN endpoint, contradicting the comment in NewProvider and the
documented behavior.

ConfigFrom now normalizes the base URL to the /v1 root, so the natural
Ollama URL (host:11434 without /v1) works for chat as well. Previously the
provider appended /chat/completions to it and the request landed on a path
Ollama does not serve, while pgListModels already appended /v1.

Tests: bare-host normalization assertion, the /v1/chat/completions path
assertion, and a new test that the env config carries no inherited key.
@BaaRai
BaaRai merged commit 9e63a80 into BaaRai:main Oct 25, 2026
BaaRai added a commit that referenced this pull request Oct 25, 2026
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.

2 participants