Variable: defaultBuildLiteRtConversationInput
ts
const defaultBuildLiteRtConversationInput: (input: {
audioModalityEnabled?: boolean;
bucketOrder: ChatCompletionsBucketOrder;
enableThinking?: boolean;
filterThoughts: (
thoughts: Iterable<Thought>,
mode: "all-self" | "latest-self" | "all",
selfIdentity: string,
replayCompatibility: readonly string[],
) => Thought[];
memories: Iterable<Memory>;
messages: Iterable<Message>;
renderChatCompletionsSystemPrompt: (input: {
bucketOrder: ChatCompletionsBucketOrder;
memories: Iterable<Memory>;
renderCtx?: unknown;
renderFirstPartyRetrievables: (
items: Iterable<{
attrs: RetrievableAttrs;
retrievable: Retrievable;
}>,
) => Promise<string>;
renderMemories: (
items: Iterable<{
attrs: MemoryAttrs;
memory: Memory;
}>,
) => string;
renderRetrievables: (
items: Iterable<{
attrs: RetrievableAttrs;
retrievable: Retrievable;
}>,
deps: {
renderFirstPartyRetrievables: (
items: Iterable<{
attrs: RetrievableAttrs;
retrievable: Retrievable;
}>,
) => Promise<string>;
renderRetrievableSafetyDirective: () => string;
renderThirdPartyPrivateRetrievables: (
items: Iterable<{
attrs: RetrievableAttrs;
retrievable: Retrievable;
}>,
deps: {
renderUntrustedContent: (
content: string,
attrs: UntrustedContentAttrs,
) => string;
},
) => Promise<string>;
renderThirdPartyPublicRetrievables: (
items: Iterable<{
attrs: RetrievableAttrs;
retrievable: Retrievable;
}>,
deps: {
renderUntrustedContent: (
content: string,
attrs: UntrustedContentAttrs,
) => string;
},
) => Promise<string>;
renderUntrustedContent: (
content: string,
attrs: UntrustedContentAttrs,
) => string;
},
) => Promise<string>;
renderRetrievableSafetyDirective: () => string;
renderStandingInstructions: (
items: Iterable<Tokenizable>,
attrs?: StandingInstructionAttrs,
) => string;
renderThirdPartyPrivateRetrievables: (
items: Iterable<{
attrs: RetrievableAttrs;
retrievable: Retrievable;
}>,
deps: {
renderUntrustedContent: (
content: string,
attrs: UntrustedContentAttrs,
) => string;
},
) => Promise<string>;
renderThirdPartyPublicRetrievables: (
items: Iterable<{
attrs: RetrievableAttrs;
retrievable: Retrievable;
}>,
deps: {
renderUntrustedContent: (
content: string,
attrs: UntrustedContentAttrs,
) => string;
},
) => Promise<string>;
renderUntrustedContent: (
content: string,
attrs: UntrustedContentAttrs,
) => string;
retrievables: Iterable<Retrievable>;
standingInstructions: Iterable<Tokenizable>;
systemPrompt: Tokenizable;
}) => Promise<string>;
renderCtx?: unknown;
renderedToolCallResults: Map<string, MessageContentItem>;
renderFirstPartyRetrievables: (
items: Iterable<{
attrs: RetrievableAttrs;
retrievable: Retrievable;
}>,
) => Promise<string>;
renderMediaToLiteRtContent?: (input: {
media: Media;
modalityEnabled: boolean;
nonce: string;
renderTrustedContent: (
content: string,
attrs: TrustedContentAttrs,
) => string;
renderUntrustedContent: (
content: string,
attrs: UntrustedContentAttrs,
) => string;
unsupportedMediaPolicy: UnsupportedMediaPolicy;
warn?: (msg: string) => void;
}) => Promise<MessageContentItem[]>;
renderMemories: (
items: Iterable<{
attrs: MemoryAttrs;
memory: Memory;
}>,
) => string;
renderRetrievables: (
items: Iterable<{
attrs: RetrievableAttrs;
retrievable: Retrievable;
}>,
deps: {
renderFirstPartyRetrievables: (
items: Iterable<{
attrs: RetrievableAttrs;
retrievable: Retrievable;
}>,
) => Promise<string>;
renderRetrievableSafetyDirective: () => string;
renderThirdPartyPrivateRetrievables: (
items: Iterable<{
attrs: RetrievableAttrs;
retrievable: Retrievable;
}>,
deps: {
renderUntrustedContent: (
content: string,
attrs: UntrustedContentAttrs,
) => string;
},
) => Promise<string>;
renderThirdPartyPublicRetrievables: (
items: Iterable<{
attrs: RetrievableAttrs;
retrievable: Retrievable;
}>,
deps: {
renderUntrustedContent: (
content: string,
attrs: UntrustedContentAttrs,
) => string;
},
) => Promise<string>;
renderUntrustedContent: (
content: string,
attrs: UntrustedContentAttrs,
) => string;
},
) => Promise<string>;
renderRetrievableSafetyDirective: () => string;
renderStandingInstructions: (
items: Iterable<Tokenizable>,
attrs?: StandingInstructionAttrs,
) => string;
renderThirdPartyPrivateRetrievables: (
items: Iterable<{
attrs: RetrievableAttrs;
retrievable: Retrievable;
}>,
deps: {
renderUntrustedContent: (
content: string,
attrs: UntrustedContentAttrs,
) => string;
},
) => Promise<string>;
renderThirdPartyPublicRetrievables: (
items: Iterable<{
attrs: RetrievableAttrs;
retrievable: Retrievable;
}>,
deps: {
renderUntrustedContent: (
content: string,
attrs: UntrustedContentAttrs,
) => string;
},
) => Promise<string>;
renderThought: (
content: string,
attrs: ThoughtAttrs,
payload?: unknown,
) => string;
renderToolsAsPromptText?: (
tools: readonly (Tool<SpooledArtifact> | ArtifactTool)[],
deps: {
descriptionToChatCompletionsJsonSchema: (
d: DescriptionLike,
) => JsonSchema;
},
) => string;
renderTrustedContent: (content: string, attrs: TrustedContentAttrs) => string;
renderUntrustedContent: (
content: string,
attrs: UntrustedContentAttrs,
) => string;
replayCompatibility: readonly string[];
retrievables: Iterable<Retrievable>;
selfIdentity: string;
standingInstructions: Iterable<Tokenizable>;
systemPrompt: Tokenizable;
thoughts: Iterable<Thought>;
thoughtSurfacing: "all-self" | "latest-self" | "all";
toolCalls: Iterable<ToolCall>;
toolDelivery?: "prompt" | "native";
tools: ToolRegistry;
toolsToLiteRtTools: (
tools: readonly (Tool<SpooledArtifact> | ArtifactTool)[],
deps: {
descriptionToChatCompletionsJsonSchema: (
d: DescriptionLike,
) => JsonSchema;
},
) => Tool[];
unsupportedMediaPolicy?: UnsupportedMediaPolicy;
visionModalityEnabled?: boolean;
warn?: (msg: string) => void;
}) => Promise<{
messages: Message[];
preface: Preface;
}> = buildLiteRtConversationInput;Defined in: src/batteries/llm/litert_lm/helpers.ts:626
Default buildLiteRtConversationInput.
Build the LiteRT conversation input from the ADK dispatch context buckets.
Parameters
| Parameter | Type | Description |
|---|---|---|
input | { audioModalityEnabled?: boolean; bucketOrder: ChatCompletionsBucketOrder; enableThinking?: boolean; filterThoughts: (thoughts: Iterable<Thought>, mode: "all-self" | "latest-self" | "all", selfIdentity: string, replayCompatibility: readonly string[]) => Thought[]; memories: Iterable<Memory>; messages: Iterable<Message>; renderChatCompletionsSystemPrompt: (input: { bucketOrder: ChatCompletionsBucketOrder; memories: Iterable<Memory>; renderCtx?: unknown; renderFirstPartyRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>) => Promise<string>; renderMemories: (items: Iterable<{ attrs: MemoryAttrs; memory: Memory; }>) => string; renderRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderFirstPartyRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>) => Promise<string>; renderRetrievableSafetyDirective: () => string; renderThirdPartyPrivateRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => Promise<string>; renderThirdPartyPublicRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => Promise<string>; renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => Promise<string>; renderRetrievableSafetyDirective: () => string; renderStandingInstructions: (items: Iterable<Tokenizable>, attrs?: StandingInstructionAttrs) => string; renderThirdPartyPrivateRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => Promise<string>; renderThirdPartyPublicRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => Promise<string>; renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; retrievables: Iterable<Retrievable>; standingInstructions: Iterable<Tokenizable>; systemPrompt: Tokenizable; }) => Promise<string>; renderCtx?: unknown; renderedToolCallResults: Map<string, MessageContentItem>; renderFirstPartyRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>) => Promise<string>; renderMediaToLiteRtContent?: (input: { media: Media; modalityEnabled: boolean; nonce: string; renderTrustedContent: (content: string, attrs: TrustedContentAttrs) => string; renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; unsupportedMediaPolicy: UnsupportedMediaPolicy; warn?: (msg: string) => void; }) => Promise<MessageContentItem[]>; renderMemories: (items: Iterable<{ attrs: MemoryAttrs; memory: Memory; }>) => string; renderRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderFirstPartyRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>) => Promise<string>; renderRetrievableSafetyDirective: () => string; renderThirdPartyPrivateRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => Promise<string>; renderThirdPartyPublicRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => Promise<string>; renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => Promise<string>; renderRetrievableSafetyDirective: () => string; renderStandingInstructions: (items: Iterable<Tokenizable>, attrs?: StandingInstructionAttrs) => string; renderThirdPartyPrivateRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => Promise<string>; renderThirdPartyPublicRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => Promise<string>; renderThought: (content: string, attrs: ThoughtAttrs, payload?: unknown) => string; renderToolsAsPromptText?: (tools: readonly ( | Tool<SpooledArtifact> | ArtifactTool)[], deps: { descriptionToChatCompletionsJsonSchema: (d: DescriptionLike) => JsonSchema; }) => string; renderTrustedContent: (content: string, attrs: TrustedContentAttrs) => string; renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; replayCompatibility: readonly string[]; retrievables: Iterable<Retrievable>; selfIdentity: string; standingInstructions: Iterable<Tokenizable>; systemPrompt: Tokenizable; thoughts: Iterable<Thought>; thoughtSurfacing: "all-self" | "latest-self" | "all"; toolCalls: Iterable<ToolCall>; toolDelivery?: "prompt" | "native"; tools: ToolRegistry; toolsToLiteRtTools: (tools: readonly ( | Tool<SpooledArtifact> | ArtifactTool)[], deps: { descriptionToChatCompletionsJsonSchema: (d: DescriptionLike) => JsonSchema; }) => Tool[]; unsupportedMediaPolicy?: UnsupportedMediaPolicy; visionModalityEnabled?: boolean; warn?: (msg: string) => void; } | - |
input.audioModalityEnabled? | boolean | - |
input.bucketOrder | ChatCompletionsBucketOrder | - |
input.enableThinking? | boolean | Whether the model's "thinking" mode is enabled. Passed EXPLICITLY into the chat template via preface.extra_context.enable_thinking so the template never decides for itself. Defaults to false. |
input.filterThoughts | (thoughts: Iterable<Thought>, mode: "all-self" | "latest-self" | "all", selfIdentity: string, replayCompatibility: readonly string[]) => Thought[] | - |
input.memories | Iterable<Memory> | - |
input.messages | Iterable<Message> | - |
input.renderChatCompletionsSystemPrompt | (input: { bucketOrder: ChatCompletionsBucketOrder; memories: Iterable<Memory>; renderCtx?: unknown; renderFirstPartyRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>) => Promise<string>; renderMemories: (items: Iterable<{ attrs: MemoryAttrs; memory: Memory; }>) => string; renderRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderFirstPartyRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>) => Promise<string>; renderRetrievableSafetyDirective: () => string; renderThirdPartyPrivateRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => Promise<string>; renderThirdPartyPublicRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => Promise<string>; renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => Promise<string>; renderRetrievableSafetyDirective: () => string; renderStandingInstructions: (items: Iterable<Tokenizable>, attrs?: StandingInstructionAttrs) => string; renderThirdPartyPrivateRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => Promise<string>; renderThirdPartyPublicRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => Promise<string>; renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; retrievables: Iterable<Retrievable>; standingInstructions: Iterable<Tokenizable>; systemPrompt: Tokenizable; }) => Promise<string> | - |
input.renderCtx? | unknown | The live dispatch context, threaded so DYNAMIC (evaluatable) Tokenizable content resolves against it at assembly via .render(renderCtx). Optional — a static Tokenizable ignores it, and callers outside a dispatch may omit it (the evaluator's no-context fallback applies). Typed loosely (the primitive types the arg as DispatchContext; this battery does not import that contract). |
input.renderedToolCallResults | Map<string, MessageContentItem> | - |
input.renderFirstPartyRetrievables | (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>) => Promise<string> | - |
input.renderMediaToLiteRtContent? | (input: { media: Media; modalityEnabled: boolean; nonce: string; renderTrustedContent: (content: string, attrs: TrustedContentAttrs) => string; renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; unsupportedMediaPolicy: UnsupportedMediaPolicy; warn?: (msg: string) => void; }) => Promise<MessageContentItem[]> | - |
input.renderMemories | (items: Iterable<{ attrs: MemoryAttrs; memory: Memory; }>) => string | - |
input.renderRetrievables | (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderFirstPartyRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>) => Promise<string>; renderRetrievableSafetyDirective: () => string; renderThirdPartyPrivateRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => Promise<string>; renderThirdPartyPublicRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => Promise<string>; renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => Promise<string> | - |
input.renderRetrievableSafetyDirective | () => string | - |
input.renderStandingInstructions | (items: Iterable<Tokenizable>, attrs?: StandingInstructionAttrs) => string | - |
input.renderThirdPartyPrivateRetrievables | (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => Promise<string> | - |
input.renderThirdPartyPublicRetrievables | (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => Promise<string> | - |
input.renderThought | (content: string, attrs: ThoughtAttrs, payload?: unknown) => string | - |
input.renderToolsAsPromptText? | (tools: readonly ( | Tool<SpooledArtifact> | ArtifactTool)[], deps: { descriptionToChatCompletionsJsonSchema: (d: DescriptionLike) => JsonSchema; }) => string | - |
input.renderTrustedContent | (content: string, attrs: TrustedContentAttrs) => string | - |
input.renderUntrustedContent | (content: string, attrs: UntrustedContentAttrs) => string | - |
input.replayCompatibility | readonly string[] | - |
input.retrievables | Iterable<Retrievable> | - |
input.selfIdentity | string | - |
input.standingInstructions | Iterable<Tokenizable> | - |
input.systemPrompt | Tokenizable | - |
input.thoughts | Iterable<Thought> | - |
input.thoughtSurfacing | "all-self" | "latest-self" | "all" | - |
input.toolCalls | Iterable<ToolCall> | - |
input.toolDelivery? | "prompt" | "native" | How tool definitions reach the model. 'prompt' (default) renders them as system-prompt text (the portable path — the Gemma-4 .litertlm template throws on native tools); 'native' uses preface.tools (the chat-template path — only for models whose template handles tools). |
input.tools | ToolRegistry | - |
input.toolsToLiteRtTools | (tools: readonly ( | Tool<SpooledArtifact> | ArtifactTool)[], deps: { descriptionToChatCompletionsJsonSchema: (d: DescriptionLike) => JsonSchema; }) => Tool[] | - |
input.unsupportedMediaPolicy? | UnsupportedMediaPolicy | - |
input.visionModalityEnabled? | boolean | - |
input.warn? | (msg: string) => void | - |
Returns
Promise<{ messages: Message[]; preface: Preface; }>
Remarks
Maps the ADK history model onto LiteRT's createConversation({ preface }) + per-turn sendMessage(messages) shape:
- Leading buckets (system prompt + standingInstructions / memories / retrievables before
timelineinbucketOrder) → a singlepreface.messagessystem message. - Tools →
preface.tools. - Timeline (messages, surviving thoughts, tool calls — chronological) → the
messagesarray sent for this turn, each a LiteRTMessage. Thoughts render via the sharedrenderThoughtinto assistant messages; tool calls render an assistanttool_callsmessage + atoolrole message carrying the pre-renderedtool_responsecontent item.
Returns { preface, messages } for engine.createConversation({ preface }) then conversation.sendMessageStreaming(messages).