Skip to content
7 min read · 1,345 words

Interface: GeminiGenerateContentHelpers ​

Defined in: src/batteries/llm/gemini_generate_content/types.ts:277

The injectable translation seam.

Remarks ​

Mirrors the other batteries: every function here has a default* implementation and can be replaced per-adapter. buildGeminiRequest is the one that matters for ordering work — it is where ADK primitives become contents[], so a consumer whose vendor needs a different shape overrides it rather than forking the battery.

Extends ​

Properties ​

PropertyTypeDescriptionInherited fromDefined in
buildGeminiRequest(input: GeminiRequestBuildInput) => Promise<GeminiGenerateContentRequest>Assemble the full request from turn state. The primary ordering seam.-src/batteries/llm/gemini_generate_content/types.ts:291
descriptionToChatCompletionsJsonSchema(d: DescriptionLike) => JsonSchemaConverts a validator describe() envelope into the Chat-Completions JSON-Schema subset.ChatHelpersCommon.descriptionToChatCompletionsJsonSchemasrc/batteries/llm/chat_common/types.ts:511
filterThoughts(thoughts: Iterable<Thought>, mode: "all" | "all-self" | "latest-self", selfIdentity: string, replayCompatibility: readonly string[]) => Thought[]Selects which thoughts to surface, by surfacing mode, self identity, and replay compatibility.ChatHelpersCommon.filterThoughtssrc/batteries/llm/chat_common/types.ts:599
renderArtifactHandleBody?(input: { artifact: unknown; byteLength: number; callId: string; encoding?: string; estimatedTokens?: number; lineCount: number; }) => stringRenders the directions-bearing "handle" body for a non-inlined @nhtio/adk!SpooledArtifact tool result: metadata (callId/kind/byteLength/lineCount) plus the forged artifact_* tools the model should call to read it incrementally. Remarks Optional override seam. When omitted the battery uses the shared defaultRenderArtifactHandleBody. A consumer overrides it to change WHICH reader the model is steered toward first — e.g. promoting the JSON content-readers (artifact_json_get / artifact_json_keys) ahead of the metadata-only artifact_json_type for a small model that grabs the first listed tool. The tool list itself comes from the artifact's constructor.toolMethods; an override typically reorders or re-annotates that list before delegating to the default renderer.ChatHelpersCommon.renderArtifactHandleBodysrc/batteries/llm/chat_common/types.ts:571
renderChatCompletionsSystemPrompt(input: { bucketOrder: ChatCompletionsBucketOrder; memories: Iterable<Memory>; renderCtx?: unknown; renderFirstPartyRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, renderRetrievableHandleBody?: (input: { artifact: unknown; byteLength: number; callId: string; encoding?: string; estimatedTokens?: number; lineCount: number; }) => string) => Promise<string>; renderMemories: (items: Iterable<{ attrs: MemoryAttrs; memory: Memory; }>) => string; renderRetrievableHandleBody?: (input: { artifact: unknown; byteLength: number; callId: string; encoding?: string; estimatedTokens?: number; lineCount: number; }) => string; renderRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderFirstPartyRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, renderRetrievableHandleBody?: (input: { artifact: unknown; byteLength: number; callId: string; encoding?: string; estimatedTokens?: number; lineCount: number; }) => string) => Promise<string>; renderRetrievableHandleBody?: (input: { artifact: unknown; byteLength: number; callId: string; encoding?: string; estimatedTokens?: number; lineCount: number; }) => string; renderRetrievableSafetyDirective: () => string; renderThirdPartyPrivateRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderRetrievableHandleBody?: (input: { artifact: unknown; byteLength: number; callId: string; encoding?: string; estimatedTokens?: number; lineCount: number; }) => string; renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => Promise<string>; renderThirdPartyPublicRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderRetrievableHandleBody?: (input: { artifact: unknown; byteLength: number; callId: string; encoding?: string; estimatedTokens?: number; lineCount: number; }) => string; 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: { renderRetrievableHandleBody?: (input: { artifact: unknown; byteLength: number; callId: string; encoding?: string; estimatedTokens?: number; lineCount: number; }) => string; renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => Promise<string>; renderThirdPartyPublicRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderRetrievableHandleBody?: (input: { artifact: unknown; byteLength: number; callId: string; encoding?: string; estimatedTokens?: number; lineCount: number; }) => string; renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => Promise<string>; renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; retrievables: Iterable<Retrievable>; standingInstructions: Iterable<Tokenizable>; systemPrompt: Tokenizable; }) => Promise<string>Assembles the system-prompt message from its constituent buckets in ChatCompletionsBucketOrder.ChatHelpersCommon.renderChatCompletionsSystemPromptsrc/batteries/llm/chat_common/types.ts:611
renderFirstPartyRetrievables(items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, renderRetrievableHandleBody?: (input: { artifact: unknown; byteLength: number; callId: string; encoding?: string; estimatedTokens?: number; lineCount: number; }) => string) => Promise<string>Renders first-party (trusted) retrievables into a single prompt block.ChatHelpersCommon.renderFirstPartyRetrievablessrc/batteries/llm/chat_common/types.ts:526
renderGeminiToolResult(input: { renderTrustedContent: (content: string, attrs: TrustedContentAttrs) => string; renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; results: | Tokenizable | SpooledArtifact | Media | Media[] | SpooledArtifact[]; tool: | Tool<SpooledArtifact> | ArtifactTool | undefined; toolCall: ToolCall; unsupportedMediaPolicy: | UnsupportedMediaPolicy | undefined; warn?: (message: string) => void; }) => Promise<Record<string, unknown>>Render one tool result into a functionResponse.response object.-src/batteries/llm/gemini_generate_content/types.ts:281
renderMemories(items: Iterable<{ attrs: MemoryAttrs; memory: Memory; }>) => stringRenders memories (each with its attribute bag) into a single prompt block.ChatHelpersCommon.renderMemoriessrc/batteries/llm/chat_common/types.ts:522
renderRetrievableHandleBody?(input: { artifact: unknown; byteLength: number; callId: string; encoding?: string; estimatedTokens?: number; lineCount: number; }) => stringRenders the directions-bearing "handle" body for a non-inlined @nhtio/adk!Retrievable whose content is a @nhtio/adk!SpooledArtifact: metadata (callId/kind/byteLength/lineCount) plus the forged artifact_* tools the model should call to read it incrementally. Remarks Optional override seam, the retrievable-side counterpart to renderArtifactHandleBody. When omitted the battery uses the shared defaultRenderRetrievableHandleBody.ChatHelpersCommon.renderRetrievableHandleBodysrc/batteries/llm/chat_common/types.ts:588
renderRetrievables(items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderFirstPartyRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, renderRetrievableHandleBody?: (input: { artifact: unknown; byteLength: number; callId: string; encoding?: string; estimatedTokens?: number; lineCount: number; }) => string) => Promise<string>; renderRetrievableHandleBody?: (input: { artifact: unknown; byteLength: number; callId: string; encoding?: string; estimatedTokens?: number; lineCount: number; }) => string; renderRetrievableSafetyDirective: () => string; renderThirdPartyPrivateRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderRetrievableHandleBody?: (input: { artifact: unknown; byteLength: number; callId: string; encoding?: string; estimatedTokens?: number; lineCount: number; }) => string; renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => Promise<string>; renderThirdPartyPublicRetrievables: (items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderRetrievableHandleBody?: (input: { artifact: unknown; byteLength: number; callId: string; encoding?: string; estimatedTokens?: number; lineCount: number; }) => string; renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => Promise<string>; renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => Promise<string>Assembles the full retrievables block: safety directive plus the trust-tiered sub-renderers.ChatHelpersCommon.renderRetrievablessrc/batteries/llm/chat_common/types.ts:547
renderRetrievableSafetyDirective() => stringRenders the safety directive that precedes any retrievable content.ChatHelpersCommon.renderRetrievableSafetyDirectivesrc/batteries/llm/chat_common/types.ts:524
renderStandingInstructions(items: Iterable<Tokenizable>, attrs?: StandingInstructionAttrs) => stringRenders standing instructions into a single prompt block.ChatHelpersCommon.renderStandingInstructionssrc/batteries/llm/chat_common/types.ts:517
renderThirdPartyPrivateRetrievables(items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderRetrievableHandleBody?: (input: { artifact: unknown; byteLength: number; callId: string; encoding?: string; estimatedTokens?: number; lineCount: number; }) => string; renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => Promise<string>Renders third-party private retrievables, wrapping each in the untrusted-content envelope.ChatHelpersCommon.renderThirdPartyPrivateRetrievablessrc/batteries/llm/chat_common/types.ts:539
renderThirdPartyPublicRetrievables(items: Iterable<{ attrs: RetrievableAttrs; retrievable: Retrievable; }>, deps: { renderRetrievableHandleBody?: (input: { artifact: unknown; byteLength: number; callId: string; encoding?: string; estimatedTokens?: number; lineCount: number; }) => string; renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; }) => Promise<string>Renders third-party public retrievables, wrapping each in the untrusted-content envelope.ChatHelpersCommon.renderThirdPartyPublicRetrievablessrc/batteries/llm/chat_common/types.ts:531
renderThought(content: string, attrs: ThoughtAttrs, payload?: unknown) => stringRenders a single thought into its prompt block, optionally carrying an opaque replay payload.ChatHelpersCommon.renderThoughtsrc/batteries/llm/chat_common/types.ts:597
renderTrustedContent(content: string, attrs: TrustedContentAttrs) => stringWraps trusted (first-party) text in the trusted-content trust envelope.ChatHelpersCommon.renderTrustedContentsrc/batteries/llm/chat_common/types.ts:515
renderUntrustedContent(content: string, attrs: UntrustedContentAttrs) => stringWraps untrusted (third-party) text in the untrusted-content trust envelope.ChatHelpersCommon.renderUntrustedContentsrc/batteries/llm/chat_common/types.ts:513
toolsToChatCompletionsTools(tools: readonly ( | Tool<SpooledArtifact> | ArtifactTool)[], deps: { descriptionToChatCompletionsJsonSchema: (d: DescriptionLike) => JsonSchema; }) => ChatCompletionsTool[]Translates the tool registry into the function-tool wire array advertised to the model.ChatHelpersCommon.toolsToChatCompletionsToolssrc/batteries/llm/chat_common/types.ts:606
toolsToGeminiTools(tools: Iterable< | Tool<SpooledArtifact> | ArtifactTool>) => GeminiTool[]ADK tools → native functionDeclarations.-src/batteries/llm/gemini_generate_content/types.ts:279