UNPKG

route-claudecode

Version:

Advanced routing and transformation system for Claude Code outputs to multiple AI providers

132 lines 3.94 kB
/** * Provider Response Correction Engine * 基于 OpenAI 响应修正 CodeWhisperer 输出 * Project owner: Jason Zhang */ import { BaseRequest, BaseResponse } from '@/types'; import { ComparisonResult, ResponseDifference } from './analysis-engine'; export interface CorrectionResult { requestId: string; timestamp: Date; originalResponse: BaseResponse; referenceResponse: BaseResponse; correctedResponse: BaseResponse; appliedCorrections: AppliedCorrection[]; correctionMetrics: CorrectionMetrics; success: boolean; errors: string[]; } export interface AppliedCorrection { type: 'content' | 'structure' | 'metadata' | 'tools' | 'formatting'; description: string; originalValue: any; correctedValue: any; confidence: number; method: string; } export interface CorrectionMetrics { totalCorrections: number; successfulCorrections: number; failedCorrections: number; confidenceScore: number; improvementScore: number; processingTime: number; } export interface CorrectionStrategy { name: string; priority: number; canCorrect: (difference: ResponseDifference) => boolean; apply: (original: BaseResponse, reference: BaseResponse, difference: ResponseDifference) => Promise<CorrectionOperation>; } export interface CorrectionOperation { success: boolean; correctedValue: any; confidence: number; method: string; error?: string; } export interface CorrectionConfig { enableContentCorrection: boolean; enableStructuralCorrection: boolean; enableToolCorrection: boolean; enableMetadataCorrection: boolean; confidenceThreshold: number; maxCorrections: number; strategies: { content: { useReferenceLength: boolean; preserveOriginalStyle: boolean; similarityThreshold: number; }; structure: { normalizeFields: boolean; preserveOriginalData: boolean; }; tools: { fixFormat: boolean; validateParameters: boolean; }; }; } export declare class CorrectionEngine { private config; private correctionHistory; private strategies; private readonly maxHistorySize; constructor(config: CorrectionConfig); /** * 应用修正到 CodeWhisperer 响应 */ correctResponse(request: BaseRequest, codewhispererResponse: BaseResponse, openaiReference: BaseResponse, comparisonResult: ComparisonResult): Promise<CorrectionResult>; /** * 批量修正模式 */ correctResponseBatch(corrections: Array<{ request: BaseRequest; codewhispererResponse: BaseResponse; openaiReference: BaseResponse; comparisonResult: ComparisonResult; }>): Promise<CorrectionResult[]>; /** * 应用单个修正 */ private applyCorrection; /** * 将操作应用到响应对象 */ private applyOperationToResponse; /** * 初始化修正策略 */ private initializeStrategies; private getDifferencePriority; private extractTextContent; private extractToolCalls; private normalizeContent; private calculateImprovementScore; private calculateResponseSimilarity; private addToHistory; /** * 获取修正历史 */ getCorrectionHistory(limit?: number): CorrectionResult[]; /** * 获取修正统计 */ getCorrectionStatistics(): { totalCorrections: number; averageConfidence: number; averageImprovement: number; successRate: number; commonCorrectionTypes: Record<string, number>; performanceMetrics: { averageProcessingTime: number; correctionsPerSecond: number; }; }; /** * 学习并更新策略(简化版机器学习) */ learnFromHistory(): Promise<void>; } //# sourceMappingURL=correction-engine.d.ts.map