UNPKG

adk-typescript

Version:

TypeScript port of Google's Agent Development Kit (ADK)

98 lines (97 loc) 2.95 kB
import { BaseLlmConnection } from './BaseLlmConnection'; import { LlmResponse } from './LlmResponse'; import { Blob, Content } from './types'; /** * TypeScript equivalents of the Google genai live types */ interface LiveClientContent { turns: Content[]; turn_complete: boolean; } interface LiveClientToolResponse { function_responses: any[]; } interface ServerContent { model_turn?: Content; output_transcription?: { text: string; }; turn_complete: boolean; interrupted: boolean; } interface ToolCall { function_calls: any[]; } interface LiveMessage { server_content?: ServerContent; tool_call?: ToolCall; } /** * AsyncSession interface for the Google genai live SDK */ interface AsyncSession { send(input: LiveClientContent | LiveClientToolResponse | Blob): Promise<void>; receive(): AsyncGenerator<LiveMessage, void, unknown>; close(): Promise<void>; } /** * The Gemini model connection. */ export declare class GeminiLlmConnection extends BaseLlmConnection { private geminiSession; /** * Constructor for GeminiLlmConnection * @param geminiSession The Gemini async session */ constructor(geminiSession: AsyncSession); /** * Sends the conversation history to the gemini model. * * You call this method right after setting up the model connection. * The model will respond if the last content is from user, otherwise it will * wait for new user input before responding. * * @param history The conversation history to send to the model. */ sendHistory(history: Content[]): Promise<void>; /** * Sends a user content to the gemini model. * * The model will respond immediately upon receiving the content. * If you send function responses, all parts in the content should be function * responses. * * @param content The content to send to the model. */ sendContent(content: Content): Promise<void>; /** * Sends a chunk of audio or a frame of video to the model in realtime. * * The model may not respond immediately upon receiving the blob. It will do * voice activity detection and decide when to respond. * * @param blob The blob to send to the model. */ sendRealtime(blob: Blob): Promise<void>; /** * Builds a full text response. * * The text is not partial and the returned LlmResponse is not be * partial. * * @param text The text to be included in the response. * @returns An LlmResponse containing the full text. */ private buildFullTextResponse; /** * Receives the model response using the llm server connection. * * @returns An async generator yielding LlmResponse objects. */ receive(): AsyncGenerator<LlmResponse, void, unknown>; /** * Closes the llm server connection. */ close(): Promise<void>; } export {};