Skip to content
2 min read · 498 words

@nhtio/adk/batteries/llm/ollama/helpers

Swappable translation helpers for rendering ADK state into native Ollama /api/chat requests.

Remarks

The wire-shape-agnostic helpers (renderUntrustedContent, renderMemories, renderChatCompletionsSystemPrompt, toolsToChatCompletionsTools, …) are shared with the OpenAI battery via the internal ../chat_common/helpers submodule and re-exported here under their original names. Only the Ollama-WIRE-SPECIFIC helpers are defined here: renderOllamaTimelineMessage (flat content + base64 images[] + thinking), renderOllamaToolCallResult (string-only result content), buildOllamaHistory (synthetic assistant.tool_calls with object-form arguments + tool-role messages labelled by tool_name), and ollamaToolsFromTools (alias of the shared tool-definition renderer — native /api/chat uses the same function-tool wire shape).

Native /api/chat supports only base64 images[]; every non-image modality routes through the unsupportedMediaPolicy fallback (stash text / synthetic description) or throws.

Variables

VariableDescription
defaultBuildOllamaHistoryDefault native-history assembler; alias of buildOllamaHistory.
defaultOllamaToolsFromToolsDefault implementation of OllamaHelpers-style tool translation; alias of ollamaToolsFromTools.
defaultRenderOllamaTimelineMessageDefault timeline-message renderer; alias of renderOllamaTimelineMessage.
defaultRenderOllamaToolCallResultDefault tool-call-result renderer; alias of renderOllamaToolCallResult.

Functions

FunctionDescription
buildOllamaHistoryAssembles the complete native Ollama message history for a dispatch — system prompt and content buckets, the interleaved timeline of messages/thoughts/tool calls, and the collected opaque reasoning payloads — by delegating to the injected sub-renderers.
ollamaToolsFromToolsConvert ADK tools to the native Ollama tools[] wire. Native /api/chat uses the identical { type: 'function', function: { name, description, parameters } } shape as Chat Completions, so this is an alias of the shared renderer.
renderOllamaTimelineMessageRenders a single timeline @nhtio/adk!Message into a native Ollama message — flattening any media into the base64 images[] array, surfacing reasoning as thinking, and wrapping textual bodies in the appropriate trust envelope.
renderOllamaToolCallResultRender a tool-call result to native Ollama tool-message content (always a string). Media results are routed through the internal media renderer: images cannot ride on a tool-role message's content, so an image result is replaced with a short text marker (the image bytes are not re-sent on a tool message); non-image media use the same fallback-text path as elsewhere.

References

defaultDescriptionToChatCompletionsJsonSchema

Re-exports defaultDescriptionToChatCompletionsJsonSchema


defaultFilterThoughts

Re-exports defaultFilterThoughts


defaultRenderChatCompletionsSystemPrompt

Re-exports defaultRenderChatCompletionsSystemPrompt


defaultRenderFirstPartyRetrievables

Re-exports defaultRenderFirstPartyRetrievables


defaultRenderMemories

Re-exports defaultRenderMemories


defaultRenderRetrievables

Re-exports defaultRenderRetrievables


defaultRenderRetrievableSafetyDirective

Re-exports defaultRenderRetrievableSafetyDirective


defaultRenderStandingInstructions

Re-exports defaultRenderStandingInstructions


defaultRenderThirdPartyPrivateRetrievables

Re-exports defaultRenderThirdPartyPrivateRetrievables


defaultRenderThirdPartyPublicRetrievables

Re-exports defaultRenderThirdPartyPublicRetrievables


defaultRenderThought

Re-exports defaultRenderThought


defaultRenderTrustedContent

Re-exports defaultRenderTrustedContent


defaultRenderUntrustedContent

Re-exports defaultRenderUntrustedContent


defaultToolsToChatCompletionsTools

Re-exports defaultToolsToChatCompletionsTools


descriptionToChatCompletionsJsonSchema

Re-exports descriptionToChatCompletionsJsonSchema


filterThoughts

Re-exports filterThoughts


renderChatCompletionsSystemPrompt

Re-exports renderChatCompletionsSystemPrompt


renderFirstPartyRetrievables

Re-exports renderFirstPartyRetrievables


renderMemories

Re-exports renderMemories


renderRetrievables

Re-exports renderRetrievables


renderRetrievableSafetyDirective

Re-exports renderRetrievableSafetyDirective


renderStandingInstructions

Re-exports renderStandingInstructions


renderThirdPartyPrivateRetrievables

Re-exports renderThirdPartyPrivateRetrievables


renderThirdPartyPublicRetrievables

Re-exports renderThirdPartyPublicRetrievables


renderThought

Re-exports renderThought


renderTrustedContent

Re-exports renderTrustedContent


renderUntrustedContent

Re-exports renderUntrustedContent


toolsToChatCompletionsTools

Re-exports toolsToChatCompletionsTools