@nhtio/adk/batteries/llm/ollama/adapter
Cross-environment executor adapter for the native Ollama /api/chat endpoint.
Remarks
Native Ollama LLM adapter targeting /api/chat (NOT the OpenAI-compat /v1 layer — the openai_chat_completions battery already covers /v1). Works against both LOCAL Ollama (http://localhost:11434, no auth) and CLOUD Ollama (https://ollama.com, Authorization: Bearer <apiKey>); the only difference is baseURL + the auth header. Native is HTTP-only — a Unix-socket deployment is reached via a custom fetch or an external bridge, not an adapter option.
Structurally a sibling of the OpenAI Chat Completions adapter, with the native-wire divergences:
- Request body: generation params are NESTED under
options;think/format/keep_aliveare top-level native controls; ADK control fields are stripped before sending. - Streaming: NDJSON (newline-delimited JSON objects), terminated in-band by
done: true— there is no SSEdata:framing and no[DONE]sentinel. Wholetool_callsarrive per chunk (no delta accumulation). - Reasoning: the single native
message.thinkingfield (no multi-field precedence dance). - Tool calls:
argumentsis already a JSON OBJECT (noJSON.parse); native calls carry noid, so the adapter synthesizes one (uuidv6) for correlation / checksum / spool keying. Tool-result history messages usetool_name(the originating tool), nottool_call_id. - Generation stats: the terminal
done: trueobject's token counts + nanosecond durations +done_reasonare surfaced viahelpers.reportGenerationStats.
Classes
| Class | Description |
|---|---|
| OllamaAdapter | Opinionated cross-environment LLM adapter for the native Ollama /api/chat wire shape. |