What this adapter does
Translates Ollama's NDJSON streaming to the universal StreamChunk. Handles message content, tool calls, the final done frame with timing. Implements health check (any HTTP 200 from /api/version) and model listing (/api/tags).
Translation map
| Ollama field | StreamChunk field |
|---|---|
message.content | content |
message.tool_calls | tool_calls (passed through; already parsed dicts) |
done: true | done = True + tokens_per_sec |
| (absent) | thinking (only used by reasoning models that emit it) |
Where to handle errors
Inside the adapter's stream(). Connection refused → OllamaUnavailable (caught by orchestrator and triggers fallback). Read timeout → ModelLoadingTimeout. Malformed JSON line → OllamaProtocolError. Each one carries enough context to log meaningfully.