/** * Google model provider implementation. * * This module provides integration with Google's Gemini API, * supporting streaming responses and configurable model parameters. * * @see https://ai.google.dev/docs */ import { Model } from '../model.js'; import type { CountTokensOptions, StreamOptions } from '../model.js'; import type { Message } from '../../types/messages.js'; import type { ModelStreamEvent } from '../streaming.js'; import type { GoogleModelConfig, GoogleModelOptions } from './types.js'; export type { GoogleModelConfig, GoogleModelOptions }; /** * Google model provider implementation. * * Implements the Model interface for Google GenAI using the Generative AI API. * Supports streaming responses and comprehensive configuration. * * @example * ```typescript * const provider = new GoogleModel({ * apiKey: 'your-api-key', * modelId: 'gemini-2.5-flash', * params: { temperature: 0.7, maxOutputTokens: 1024 } * }) * * const messages: Message[] = [ * { role: 'user', content: [{ type: 'textBlock', text: 'Hello!' }] } * ] * * for await (const event of provider.stream(messages)) { * if (event.type === 'modelContentBlockDeltaEvent' && event.delta.type === 'textDelta') { * process.stdout.write(event.delta.text) * } * } * ``` */ export declare class GoogleModel extends Model { private _config; private _client; /** * Creates a new GoogleModel instance. * * @param options - Configuration for model and client * * @example * ```typescript * // Minimal configuration with API key * const provider = new GoogleModel({ * apiKey: 'your-api-key' * }) * * // With model configuration * const provider = new GoogleModel({ * apiKey: 'your-api-key', * modelId: 'gemini-2.5-flash', * params: { temperature: 0.8, maxOutputTokens: 2048 } * }) * * // Using environment variable for API key * const provider = new GoogleModel({ * modelId: 'gemini-2.5-flash' * }) * * // Using a pre-configured client instance * const client = new GoogleGenAI({ apiKey: 'your-api-key' }) * const provider = new GoogleModel({ * client * }) * ``` */ constructor(options?: GoogleModelOptions); /** * Updates the model configuration. * Merges the provided configuration with existing settings. * * @param modelConfig - Configuration object with model-specific settings to update * * @example * ```typescript * // Update model parameters * provider.updateConfig({ * params: { temperature: 0.9, maxOutputTokens: 2048 } * }) * ``` */ updateConfig(modelConfig: GoogleModelConfig): void; /** * Retrieves the current model configuration. * * @returns The current configuration object * * @example * ```typescript * const config = provider.getConfig() * console.log(config.modelId) * ``` */ getConfig(): GoogleModelConfig; /** * Count tokens using Gemini's native countTokens API. * * Uses the Gemini countTokens API for message contents. System instructions and tools * are estimated via the base class heuristic because the Gemini API (non-Vertex backend) * does not support these in CountTokensConfig. * Falls back to the base class heuristic on failure. * * @param messages - Array of conversation messages to count tokens for * @param options - Optional options containing system prompt and tool specs * @returns Total input token count */ countTokens(messages: Message[], options?: CountTokensOptions): Promise; /** * Streams a conversation with the Google model. * Returns an async iterable that yields streaming events as they occur. * * @param messages - Array of conversation messages * @param options - Optional streaming configuration * @returns Async iterable of streaming events * * @throws \{ContextWindowOverflowError\} When input exceeds the model's context window * * @example * ```typescript * const provider = new GoogleModel({ apiKey: 'your-api-key' }) * const messages: Message[] = [ * { role: 'user', content: [{ type: 'textBlock', text: 'What is 2+2?' }] } * ] * * for await (const event of provider.stream(messages)) { * if (event.type === 'modelContentBlockDeltaEvent' && event.delta.type === 'textDelta') { * process.stdout.write(event.delta.text) * } * } * ``` */ stream(messages: Message[], options?: StreamOptions): AsyncIterable; /** * Gets API key from environment variables. */ private static _getEnvApiKey; /** * Formats a request for the Google GenAI API. */ private _formatRequest; } //# sourceMappingURL=model.d.ts.map