/** * @license * Copyright 2026 Google LLC * SPDX-License-Identifier: Apache-2.0 */ import { Content, GenerateContentConfig, GoogleGenAI, Interactions, Part } from '@google/genai'; import { LlmRequest } from './llm_request.js'; import { LlmResponse } from './llm_response.js'; export interface ExtendedInteraction extends Interactions.Interaction { error?: { code: string; message: string; }; } export interface ExtendedInteractionStatusUpdate extends Omit { error?: { code: string; message: string; }; } export interface ExtendedFunctionCallStep extends Interactions.FunctionCallStep { signature?: string; } export interface ExtendedInteractionSSEEvent extends Omit { event_type?: string; eventType?: string; delta?: { type: string; text?: string; name?: string; id?: string; arguments?: Record; thought_signature?: string; signature?: string; data?: string; uri?: string; mime_type: string; }; status?: string; error?: { code: string; message: string; }; code?: string; message?: string; interaction_id?: string; interactionId?: string; interaction?: { id: string; }; id?: string; } /** * Extracts the latest turn contents for interactions API. */ export declare function getLatestUserContents(contents: Content[]): Content[]; /** * Convert a Content to a list of Steps. */ export declare function convertContentToSteps(content: Content): Interactions.Step[]; /** * Convert a Step to a list of Parts. */ export declare function convertStepToParts(step: Interactions.Step): Part[]; /** * Convert tools config to interactions format. */ export declare function convertToolsConfigToInteractionsFormat(config: GenerateContentConfig): Interactions.Tool[]; /** * Extract the latest model generated parts from a list of steps. */ export declare function getLatestModelParts(steps: Interactions.Step[]): Part[]; /** * Convert Interaction response to an LlmResponse. */ export declare function convertInteractionToLlmResponse(interaction: ExtendedInteraction): LlmResponse; /** * Convert InteractionSSEEvent to LlmResponse. */ export declare function convertInteractionEventToLlmResponse(event: ExtendedInteractionSSEEvent, aggregatedParts: Part[], interactionId?: string): LlmResponse | null; /** * Build generation config. */ export declare function buildGenerationConfig(config: GenerateContentConfig): Record; /** * Extract system instruction. */ export declare function extractSystemInstruction(config: GenerateContentConfig): string | undefined; /** * Generate content using the interactions API. */ export declare function generateContentViaInteractions(apiClient: GoogleGenAI, llmRequest: LlmRequest, stream: boolean): AsyncGenerator;