/** * LLM Configuration Module - Browser-Safe Provider Configuration Management * * Features: * - Browser-safe configuration storage for all LLM providers * - Type-safe configuration interfaces for each provider * - Configuration injection and validation functions * - Clear error messages for missing configuration * - Zero Node.js dependencies for browser compatibility * * Provider Configuration Support: * - OpenAI: API key configuration * - Anthropic: API key configuration * - Google: API key configuration * - Azure: API key, resource name, and deployment configuration (API version optional) * - XAI: API key configuration * - OpenAI-Compatible: API key and base URL configuration * - Ollama: Base URL configuration * * Usage: * - configureLLMProvider: Set configuration for a specific provider * - getLLMProviderConfig: Get configuration for a specific provider * - validateProviderConfig: Validate that required configuration is present * - clearAllConfiguration: Clear all provider configurations (for testing) * * Implementation Details: * - Global configuration store with provider-specific sections * - Type-safe interfaces prevent configuration errors * - Validation functions ensure required settings are present * - No external dependencies for maximum browser compatibility * - Clear error messages guide users to correct configuration issues * * Recent Changes: * - Initial implementation with all provider configuration interfaces * - Added configuration injection and validation functions * - Implemented browser-safe global configuration store * - Added comprehensive error handling and validation */ import { LLMProvider } from './types.js'; /** * Provider-specific configuration interfaces - Enhanced with TypeScript Utility Types */ /** * Base configuration interface for all providers */ export interface BaseLLMConfig { apiKey?: string; baseUrl?: string; endpoint?: string; deployment?: string; apiVersion?: string; } /** * OpenAI configuration - requires only API key */ export type OpenAIConfig = Required>; /** * Anthropic configuration - requires only API key */ export type AnthropicConfig = Required>; /** * Google configuration - requires only API key */ export type GoogleConfig = Required>; /** * Azure configuration - requires API key, resource name, and deployment; optionally API version */ export type AzureConfig = Required> & { resourceName: string; apiVersion?: string; }; /** * XAI configuration - requires only API key */ export type XAIConfig = Required>; /** * OpenAI-Compatible configuration - requires API key and base URL */ export type OpenAICompatibleConfig = Required>; /** * Ollama configuration - requires only base URL */ export type OllamaConfig = Required>; /** * Provider configuration mapping for type-safe access */ export type ProviderConfigMap = { [LLMProvider.OPENAI]: OpenAIConfig; [LLMProvider.ANTHROPIC]: AnthropicConfig; [LLMProvider.GOOGLE]: GoogleConfig; [LLMProvider.AZURE]: AzureConfig; [LLMProvider.XAI]: XAIConfig; [LLMProvider.OPENAI_COMPATIBLE]: OpenAICompatibleConfig; [LLMProvider.OLLAMA]: OllamaConfig; }; /** * Union type for all provider configurations */ export type ProviderConfig = ProviderConfigMap[keyof ProviderConfigMap]; /** * Configure a specific LLM provider with type-safe configuration */ export declare function configureLLMProvider(provider: T, config: ProviderConfigMap[T]): void; /** * Get configuration for a specific provider */ export declare function getLLMProviderConfig(provider: T): ProviderConfigMap[T]; /** * Validate provider configuration */ export declare function validateProviderConfig(provider: LLMProvider, config: any): void; /** * Check if a provider is configured */ export declare function isProviderConfigured(provider: LLMProvider): boolean; /** * Get list of all configured providers */ export declare function getConfiguredProviders(): LLMProvider[]; /** * Clear all provider configurations (useful for testing) */ export declare function clearAllConfiguration(): void; /** * Get configuration status for debugging */ export declare function getConfigurationStatus(): Record;