/** * AI Service Interface for multiple AI providers * Provides a unified interface for OpenAI, Claude, and other AI services */ import { EventEmitter } from "events"; /** * Custom AI Error class that preserves structured error information */ export declare class AIError extends Error { statusCode: number; errorType: string; provider: string; constructor(message: string, statusCode?: number, errorType?: string, provider?: string); } export interface AIConfig { provider: "openai" | "anthropic" | "mock"; apiKey?: string; model?: string; temperature?: number; maxTokens?: number; baseURL?: string; enableCaching?: boolean; enableLogging?: boolean; models?: { chat?: string; template?: string; fileAnalysis?: string; validation?: string; }; } export interface AIMessage { role: "system" | "user" | "assistant"; content: string; } export interface AIResponse { content: string; model: string; usage?: { promptTokens: number; completionTokens: number; totalTokens: number; }; cost?: number; cached?: boolean; } export interface TemplateResponse extends AIResponse { template?: any; } export interface FileAnalysisResponse extends AIResponse { analysis?: string; dataPoints?: any[]; } export interface AIAnalysisOptions { analysisType?: string; requiresStructuredOutput?: boolean; requiresReasoning?: boolean; temperature?: number; maxTokens?: number; systemPrompt?: string; responseFormat?: { type: string; }; } /** * Abstract base class for AI providers */ export declare abstract class AIProvider { protected config: AIConfig; constructor(config: AIConfig); abstract analyze(prompt: string, options?: AIAnalysisOptions): Promise; abstract chat(messages: AIMessage[], options?: AIAnalysisOptions): Promise; abstract validateConfig(): boolean; } /** * OpenAI Provider Implementation */ export declare class OpenAIProvider extends AIProvider { private client; private models; constructor(config: AIConfig); private initializeClient; validateConfig(): boolean; analyze(prompt: string, options?: AIAnalysisOptions): Promise; chat(messages: AIMessage[], options?: AIAnalysisOptions): Promise; private calculateCost; private handleOpenAIError; } /** * Mock Provider for testing */ export declare class MockAIProvider extends AIProvider { validateConfig(): boolean; analyze(prompt: string, _options?: AIAnalysisOptions): Promise; chat(messages: AIMessage[], _options?: AIAnalysisOptions): Promise; } /** * Main AI Service with caching and model routing */ export declare class AIService extends EventEmitter { private providers; private cache; private fileHandler; private defaultProvider; constructor(); /** * Register an AI provider */ registerProvider(name: string, config: AIConfig): void; /** * Set default provider */ setDefaultProvider(name: string): void; /** * Analyze content using AI */ analyze(prompt: string, options?: AIAnalysisOptions & { provider?: string; useCache?: boolean; }): Promise; /** * Chat with AI */ chat(messages: AIMessage[], options?: AIAnalysisOptions & { provider?: string; useCache?: boolean; }): Promise; /** * Generate template from conversation */ generateTemplate(messages: AIMessage[], options?: AIAnalysisOptions & { provider?: string; }): Promise; /** * Analyze uploaded file */ analyzeFile(fileContent: string, fileType: string, deviceInfo?: Record, options?: AIAnalysisOptions & { provider?: string; }): Promise; /** * Select best model for task */ selectModel(criteria: { contentLength?: number; complexity?: "low" | "medium" | "high"; requiresReasoning?: boolean; requiresStructuredOutput?: boolean; costSensitive?: boolean; }): { provider: string; model: string; reason: string; }; /** * Generate cache key */ private getCacheKey; /** * Log AI usage for tracking */ private logUsage; /** * Clear cache */ clearCache(): void; /** * Get usage statistics */ getUsageStats(_startDate?: Date, _endDate?: Date): Promise<{ totalTokens: number; totalCost: number; byProvider: Record; }>; } export declare function getAIService(): AIService; export declare const aiService: AIService; export default AIService; //# sourceMappingURL=aiService.d.ts.map