fix(ollama): forward API key to backend - #4533
Open
mameikagou wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses Ollama backends that require bearer-token authentication by forwarding configured API keys as Authorization: Bearer ... headers, while also updating the ollama-rs dependency and adapting the embedding call to the current ollama-rs embeddings API.
Changes:
- Add header injection for
ollama/completionrequests viaollama-rsheader support. - Update the embedding request path to use
GenerateEmbeddingsRequestand handle the response shape by selecting the first embedding. - Bump the pinned
ollama-rsgit revision and addtokiodev-dependencies to support new unit tests.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| crates/ollama-api-bindings/src/embedding.rs | Switch embedding call to the new ollama-rs embeddings request API and add a unit test for response handling. |
| crates/ollama-api-bindings/src/completion.rs | Add connection setup that forwards API keys as Authorization headers and add a unit test verifying the header is sent. |
| crates/ollama-api-bindings/Cargo.toml | Update ollama-rs revision/features (adds headers) and add tokio dev-dependencies for tests. |
| Cargo.lock | Lockfile updates from the ollama-rs revision bump and transitive dependency changes. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Forward configured Ollama API keys as sensitive
Authorization: Bearerheaders. This updates the pinnedollama-rsrevision for header support and adapts the embedding call to its current API.Validation:
cargo test -p ollama-api-bindings --locked --libFixes #4525