Skip to content
4 min read · 775 words

@nhtio/adk/batteries/llm/litert_lm/helpers

Translation helpers for the LiteRT-LM adapter.

Remarks

Two layers:

  1. Re-exported format-agnostic helpers from chat_common — they operate on ADK primitives and produce plain strings / trust envelopes / a JSON-Schema from a joi description, with no wire-format coupling. LiteRT reuses them verbatim (the same way the WebLLM battery does).
  2. LiteRT-native mappers defined here — the wire-shape functions the chat-completions batteries implement against the OpenAI wire format, rewritten against LiteRT's Message / Tool / tool_response / Preface shapes.

Interfaces

InterfaceDescription
LiteRtStreamAccumulatorA streaming accumulator over LiteRT ReadableStream<Message> chunks.

Variables

VariableDescription
defaultBuildLiteRtConversationInputDefault buildLiteRtConversationInput.
defaultCreateLiteRtStreamAccumulatorDefault createLiteRtStreamAccumulator.
defaultRenderLiteRtToolResultDefault renderLiteRtToolResult.
defaultRenderToolsAsPromptTextDefault renderToolsAsPromptText.
defaultToolsToLiteRtToolsDefault toolsToLiteRtTools.

Functions

FunctionDescription
buildLiteRtConversationInputBuild the LiteRT conversation input from the ADK dispatch context buckets.
createLiteRtStreamAccumulatorCreate a LiteRtStreamAccumulator.
renderLiteRtToolResultRender a @nhtio/adk!ToolCall's results into a LiteRT tool_response content item.
renderMediaToLiteRtContentRender a media kind/mime/filename into a LiteRT content item, or fall back per unsupportedMediaPolicy.
renderToolsAsPromptTextRender tool definitions as a SYSTEM-PROMPT text block (the prompt-injection tool-delivery path), rather than the native preface.tools field.
toolsToLiteRtToolsConvert ADK @nhtio/adk!Tool / @nhtio/adk!ArtifactTool instances into LiteRT LiteRtTool definitions.

References

barePythonicToolCallParser

Re-exports barePythonicToolCallParser


BatteryLifecycleBattery

Re-exports BatteryLifecycleBattery


BatteryLifecycleCallback

Re-exports BatteryLifecycleCallback


BatteryLifecycleHooks

Re-exports BatteryLifecycleHooks


BatteryLifecyclePhase

Re-exports BatteryLifecyclePhase


BatteryLifecycleReport

Re-exports BatteryLifecycleReport


buildBundledReasoningParsers

Re-exports buildBundledReasoningParsers


BUNDLED_REASONING_PARSERS

Re-exports BUNDLED_REASONING_PARSERS


BUNDLED_TOOL_CALL_PARSERS

Re-exports BUNDLED_TOOL_CALL_PARSERS


ChatGenerationOptions

Re-exports ChatGenerationOptions


ChatSampler

Re-exports ChatSampler


createAutoReasoningParser

Re-exports createAutoReasoningParser


createAutoToolCallParser

Re-exports createAutoToolCallParser


DEFAULT_REASONING_PARSER_ORDER

Re-exports DEFAULT_REASONING_PARSER_ORDER


DEFAULT_TOOL_CALL_PARSER_ORDER

Re-exports DEFAULT_TOOL_CALL_PARSER_ORDER


defaultBarePythonicToolCallParser

Re-exports defaultBarePythonicToolCallParser


defaultCreateAutoReasoningParser

Re-exports defaultCreateAutoReasoningParser


defaultCreateAutoToolCallParser

Re-exports defaultCreateAutoToolCallParser


defaultDescriptionToChatCompletionsJsonSchema

Re-exports defaultDescriptionToChatCompletionsJsonSchema


defaultEmitLifecycle

Re-exports defaultEmitLifecycle


defaultFilterThoughts

Re-exports defaultFilterThoughts


defaultGemmaChannelReasoningParser

Re-exports defaultGemmaChannelReasoningParser


defaultGemmaToolCallParser

Re-exports defaultGemmaToolCallParser


defaultGptOssToolCallParser

Re-exports defaultGptOssToolCallParser


defaultHarmonyAnalysisReasoningParser

Re-exports defaultHarmonyAnalysisReasoningParser


defaultHermesToolCallParser

Re-exports defaultHermesToolCallParser


defaultLlama3JsonToolCallParser

Re-exports defaultLlama3JsonToolCallParser


defaultLooseKeyedToolCallParser

Re-exports defaultLooseKeyedToolCallParser


defaultMistralToolCallParser

Re-exports defaultMistralToolCallParser


defaultNoneReasoningParser

Re-exports defaultNoneReasoningParser


defaultNoneToolCallParser

Re-exports defaultNoneToolCallParser


defaultPhiToolCallParser

Re-exports defaultPhiToolCallParser


defaultPythonicToolCallParser

Re-exports defaultPythonicToolCallParser


defaultQwen3CoderToolCallParser

Re-exports defaultQwen3CoderToolCallParser


defaultRenderArtifactHandleBody

Re-exports defaultRenderArtifactHandleBody


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


defaultResolveGenerationOptions

Re-exports defaultResolveGenerationOptions


defaultResolveReasoningParser

Re-exports defaultResolveReasoningParser


defaultResolveToolCallParser

Re-exports defaultResolveToolCallParser


defaultThinkTagReasoningParser

Re-exports defaultThinkTagReasoningParser


descriptionToChatCompletionsJsonSchema

Re-exports descriptionToChatCompletionsJsonSchema


emitLifecycle

Re-exports emitLifecycle


extractReasoningFields

Re-exports extractReasoningFields


filterThoughts

Re-exports filterThoughts


gemmaChannelReasoningParser

Re-exports gemmaChannelReasoningParser


gemmaToolCallParser

Re-exports gemmaToolCallParser


GENERATION_DEFAULTS

Re-exports GENERATION_DEFAULTS


gptOssToolCallParser

Re-exports gptOssToolCallParser


GpuBudget

Re-exports GpuBudget


GpuBufferInstrument

Re-exports GpuBufferInstrument


GpuBufferSample

Re-exports GpuBufferSample


harmonyAnalysisReasoningParser

Re-exports harmonyAnalysisReasoningParser


hermesToolCallParser

Re-exports hermesToolCallParser


instrumentGpuBuffers

Re-exports instrumentGpuBuffers


isGpuOutOfMemoryError

Re-exports isGpuOutOfMemoryError


JsonValue

Re-exports JsonValue


llama3JsonToolCallParser

Re-exports llama3JsonToolCallParser


looksLikeSpooledArtifact

Re-exports looksLikeSpooledArtifact


looseKeyedToolCallParser

Re-exports looseKeyedToolCallParser


makeGemmaChannelReasoningParser

Re-exports makeGemmaChannelReasoningParser


makeHarmonyAnalysisReasoningParser

Re-exports makeHarmonyAnalysisReasoningParser


makeThinkTagReasoningParser

Re-exports makeThinkTagReasoningParser


mistralToolCallParser

Re-exports mistralToolCallParser


noneReasoningParser

Re-exports noneReasoningParser


noneToolCallParser

Re-exports noneToolCallParser


ParsedToolCall

Re-exports ParsedToolCall


phiToolCallParser

Re-exports phiToolCallParser


probeGpuBudget

Re-exports probeGpuBudget


pythonicToolCallParser

Re-exports pythonicToolCallParser


qwen3CoderToolCallParser

Re-exports qwen3CoderToolCallParser


ReasoningParseResult

Re-exports ReasoningParseResult


ReasoningParserFn

Re-exports ReasoningParserFn


ReasoningParserName

Re-exports ReasoningParserName


ReasoningParserOptions

Re-exports ReasoningParserOptions


renderArtifactHandleBody

Re-exports renderArtifactHandleBody


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


ResolvedGenerationOptions

Re-exports ResolvedGenerationOptions


resolveGenerationOptions

Re-exports resolveGenerationOptions


resolveReasoningParser

Re-exports resolveReasoningParser


resolveToolCallParser

Re-exports resolveToolCallParser


thinkTagReasoningParser

Re-exports thinkTagReasoningParser


ToolCallParserContext

Re-exports ToolCallParserContext


ToolCallParseResult

Re-exports ToolCallParseResult


ToolCallParserFn

Re-exports ToolCallParserFn


ToolCallParserName

Re-exports ToolCallParserName