route-claudecode
Version:
Advanced routing and transformation system for Claude Code outputs to multiple AI providers
157 lines • 4.24 kB
TypeScript
/**
* Provider Comparison Analysis Engine
* 对比分析 CodeWhisperer 与 OpenAI 响应差异
* Project owner: Jason Zhang
*/
import { BaseRequest, BaseResponse } from '@/types';
export interface ComparisonResult {
requestId: string;
timestamp: Date;
request: BaseRequest;
responses: {
codewhisperer: ProviderResponse;
openai: ProviderResponse;
};
analysis: ResponseAnalysis;
differences: ResponseDifference[];
qualityScore: QualityScore;
recommendations: CorrectionRecommendation[];
}
export interface ProviderResponse {
response: BaseResponse;
metadata: {
responseTime: number;
tokenCount: {
input: number;
output: number;
};
errors: string[];
warnings: string[];
};
}
export interface ResponseAnalysis {
contentComparison: {
similarity: number;
lengthDifference: number;
structuralDifference: number;
};
qualityComparison: {
completeness: {
codewhisperer: number;
openai: number;
};
accuracy: {
codewhisperer: number;
openai: number;
};
coherence: {
codewhisperer: number;
openai: number;
};
};
performanceComparison: {
responseTime: {
codewhisperer: number;
openai: number;
difference: number;
};
tokenEfficiency: {
codewhisperer: number;
openai: number;
};
};
}
export interface ResponseDifference {
type: 'content' | 'structure' | 'metadata' | 'tools' | 'formatting';
severity: 'critical' | 'major' | 'minor';
description: string;
codewhispererValue: any;
openaiValue: any;
impact: string;
fixable: boolean;
}
export interface QualityScore {
overall: number;
dimensions: {
completeness: number;
accuracy: number;
consistency: number;
performance: number;
};
recommendation: 'use_codewhisperer' | 'use_openai' | 'needs_correction' | 'equivalent';
}
export interface CorrectionRecommendation {
type: 'content' | 'structure' | 'metadata' | 'tools' | 'formatting';
priority: 'high' | 'medium' | 'low';
action: string;
implementation: string;
expectedImpact: string;
}
export declare class ComparisonAnalysisEngine {
private config;
private analysisHistory;
private readonly maxHistorySize;
constructor(config: {
enableContentAnalysis: boolean;
enablePerformanceAnalysis: boolean;
enableStructuralAnalysis: boolean;
qualityThresholds: {
critical: number;
major: number;
minor: number;
};
});
/**
* 对比分析两个 provider 的响应
*/
analyzeProviderResponses(request: BaseRequest, codewhispererResponse: ProviderResponse, openaiResponse: ProviderResponse): Promise<ComparisonResult>;
/**
* 分析内容差异
*/
private analyzeContentDifferences;
/**
* 分析质量差异
*/
private analyzeQualityDifferences;
/**
* 分析性能差异
*/
private analyzePerformanceDifferences;
/**
* 识别具体差异
*/
private identifyDifferences;
/**
* 计算综合质量分数
*/
private calculateQualityScore;
/**
* 生成修正建议
*/
private generateRecommendations;
private extractTextContent;
private calculateContentSimilarity;
private calculateStructuralDifference;
private analyzeResponseStructure;
private extractToolCalls;
private assessCompleteness;
private assessAccuracy;
private assessCoherence;
private assessContentDifferenceSeverity;
private calculatePerformanceScore;
private addToHistory;
/**
* 获取分析历史
*/
getAnalysisHistory(limit?: number): ComparisonResult[];
/**
* 获取质量统计
*/
getQualityStatistics(): {
averageScore: number;
totalComparisons: number;
recommendationDistribution: Record<string, number>;
commonIssues: string[];
};
}
//# sourceMappingURL=analysis-engine.d.ts.map