/** * LLM Provider Factory * * Factory pattern for creating LLM providers with automatic fallback. * Tries providers in order: Ollama → OpenAI → Anthropic → Mock. * * Usage: * const provider = await createLLMProvider(); * // Returns first available provider */ import type { LLMProvider, GenerationRequest, GenerationResponse } from './index.js'; /** * Provider priority order for fallback * DeepSeek (best value) → Ollama (local, free) → OpenAI → Anthropic → Mock (always available) */ export declare const PROVIDER_CHAIN: readonly ["deepseek", "ollama", "openai", "anthropic", "mock"]; export type ProviderType = typeof PROVIDER_CHAIN[number]; /** * Provider factory configuration */ export interface ProviderFactoryConfig { /** * Preferred provider (will be tried first) */ preferred?: ProviderType; /** * Ordered list of providers to try (overrides default chain) */ chain?: ProviderType[]; /** * Skip specific providers */ skip?: ProviderType[]; /** * Ollama configuration */ ollama?: { baseUrl?: string; model?: string; timeout?: number; }; /** * OpenAI configuration */ openai?: { apiKey?: string; baseURL?: string; model?: string; timeout?: number; }; /** * Anthropic configuration */ anthropic?: { apiKey?: string; baseURL?: string; model?: string; timeout?: number; }; /** * DeepSeek configuration */ deepseek?: { apiKey?: string; baseURL?: string; model?: string; timeout?: number; }; /** * Mock configuration */ mock?: { delay?: number; responses?: Record; }; } /** * Provider selection result */ export interface ProviderSelection { provider: LLMProvider; type: ProviderType; reason: string; skipped: ProviderType[]; } /** * Fallback provider that wraps the selected provider */ export declare class FallbackProvider implements LLMProvider { name: string; models: string[]; private readonly provider; private readonly providerType; constructor(provider: LLMProvider, providerType: ProviderType); isAvailable(): Promise; generate(request: GenerationRequest): Promise; stream(request: GenerationRequest): AsyncIterable; countTokens(text: string): number; /** * Get the underlying provider type */ getProviderType(): ProviderType; } /** * Create LLM provider with automatic fallback * * Tries providers in order until one is available. * Logs which provider was selected and why. */ export declare function createLLMProvider(config?: ProviderFactoryConfig): Promise; /** * Get provider availability status for all providers */ export declare function getProviderStatus(config?: ProviderFactoryConfig): Promise>; /** * Auto-detect best available provider * Priority: DeepSeek (best value) → Ollama (free local) → OpenAI → Anthropic → Mock */ export declare function detectBestProvider(config?: ProviderFactoryConfig): Promise; /** * Create the best available provider automatically * This is the recommended way to get a provider for most use cases. * * Selection criteria: * 1. DeepSeek - Best value, GPT-4 level at 95% lower cost * 2. Ollama - Free, local, privacy-preserving * 3. OpenAI - Reliable, widely-used * 4. Anthropic - High quality, Claude models * 5. Mock - Fallback for testing * * @example * const provider = await createBest(); * const response = await provider.generate({ * prompt: 'Generate tests for login form' * }); */ export declare function createBest(config?: ProviderFactoryConfig): Promise; /** * Get provider information for display */ export interface ProviderInfo { type: ProviderType; name: string; available: boolean; description: string; costLevel: 'free' | 'low' | 'medium' | 'high'; capabilities: string[]; } export declare function getProviderInfo(config?: ProviderFactoryConfig): Promise; /** * Create provider with automatic retry on failure * * If the selected provider fails, automatically falls back * to the next available provider in the chain. */ export declare function createResilientLLMProvider(config?: ProviderFactoryConfig): Promise; /** * Quick check if any LLM provider is available */ export declare function hasAnyProvider(config?: ProviderFactoryConfig): Promise;