-
Notifications
You must be signed in to change notification settings - Fork 743
Add Ollama provider #5051
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rrrodzilla
wants to merge
8
commits into
tensorzero:main
Choose a base branch
from
Govcraft:feat/ollama-provider
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add Ollama provider #5051
Conversation
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
Register Ollama as a new provider type with configuration options for model_name and api_base.
Implement InferenceProvider trait for Ollama using native /api/chat endpoint: - Streaming and non-streaming inference - Tool calling with function definitions - JSON mode with schema enforcement - Support for all standard inference parameters
Add ollama::model_name shorthand syntax for inline model configuration and integrate Ollama into the model routing table.
Add Ollama container with qwen2:0.5b model for E2E testing: - ollama service with healthcheck - ollama-model-pull service to pull model on startup - Volume for model persistence
Add qwen2-0.5b-ollama model configuration and function variants for E2E testing.
Add E2E tests for Ollama provider covering: - Simple inference - Streaming inference - JSON mode - Inference parameters - Shorthand syntax - Credential fallbacks
- Add "ollama::" to SHORTHAND_MODEL_PREFIXES for shorthand model syntax - Add ollama case in from_shorthand match for shorthand resolution - Quote variant names with dots in TOML configs to prevent parsing issues - Use correct model name (qwen2:0.5b) for shorthand test variant
Member
|
Hi @rrrodzilla, thanks for the PR. I am curious what was wrong with using the OpenAI client to call Ollama that warrants a separate provider here. Do you mind sharing? |
Author
|
Oh haha. I just saw there'd been an open issue for it that didn't have any movement and I went for it because I was bored! No worries. It was a good exercise. Can disregard. 😬 |
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.
Summary
This PR adds native Ollama provider support for local LLM inference via Ollama's
/api/chatendpoint.Changes
Ollamavariant toProviderTypeenum withmodel_nameandapi_baseconfigurationInferenceProvidertrait for Ollama with full feature support:ollama::model_nameshorthand syntax for inline model configurationqwen2:0.5bmodelKnown Limitations
LazyFileasynchronously requires additional work. File blocks are skipped with a warning.reasoning_effortservice_tierthinking_budget_tokensverbosityLocal Test Results
Notes
/api/chatendpoint (NDJSON streaming, not SSE)ollama-model-pullservice to pull model on startupTest plan