OllamaProvider connects Logicore to a locally running Ollama daemon. Because all inference happens on your hardware, this provider is ideal for privacy-sensitive workloads, offline environments, and experimentation where cloud API costs are a concern.
Installation
Install and start the Ollama daemon
Download Ollama from ollama.com and verify it is running:
Pull a model
No API key is required.
OllamaProvider communicates with the local daemon over HTTP (default: http://localhost:11434).Constructor parameters
The Ollama model tag to use, e.g.
"qwen3.5:0.8b", "llama3.3:70b", "qwen3-vl:latest". Must match a model that has already been pulled locally.Unused for local Ollama. Accepted for interface compatibility with other providers. Defaults to
None.Extra keyword arguments forwarded directly to the underlying
ollama.Client() constructor. Use this to set a custom host, timeout, or TLS options when connecting to a remote Ollama instance.Basic usage
Streaming
Pass anon_token callback to chat_stream to receive tokens as they are generated. The callback can be synchronous or async.
chat_stream returns the final assembled message dict after streaming completes. The on_token callback fires for every incremental token, including thinking tokens emitted by reasoning-capable models.Tool calling
Tool calling works the same way as with cloud providers. Pass Python functions directly toAgent:
Vision / multimodal
Use a vision-capable model tag (qwen3-vl, llava, moondream, etc.) and pass a list with both text and image parts:
image_url values:
- Local file path (Linux, macOS, Windows)
https://image URLdata:image/...;base64,...inline data
OllamaProvider automatically detects vision capability by inspecting the model’s metadata via ollama show. It raises ValueError if you send an image to a non-vision model.
Pulling models programmatically
OllamaProvider exposes a pull_model() helper that downloads the model if it is not already present:
Connecting to a remote Ollama instance
Troubleshooting
ValueError: No valid messages to send to Ollama
ValueError: No valid messages to send to Ollama
All messages in the conversation were filtered out (empty content and no tool calls). Ensure at least the final user message has non-empty
content.ValueError: Ollama model does not support vision capabilities
ValueError: Ollama model does not support vision capabilities
The model tag you specified is not a vision model. Switch to
qwen3-vl:latest, llava:13b, or another vision-capable tag, then retry.Ollama error: model not found / 404
Ollama error: model not found / 404
The model has not been pulled. Run
ollama pull <model> or call provider.pull_model() in your code.Slow inference
Slow inference
Ollama defaults to CPU inference when no GPU is available. Install CUDA or Metal drivers and ensure Ollama picks up the GPU. Run
ollama run <model> in the terminal and check the logs for using device.Empty response / ValueError: Ollama returned empty message
Empty response / ValueError: Ollama returned empty message
Some smaller models occasionally return empty responses. Try a larger quantization (e.g.,
q8_0 instead of q2_K) or switch to a model with better instruction-following, such as qwen3.5:7b.