UNPKG

@juspay/neurolink

Version:

Universal AI Development Platform with working MCP integration, multi-provider support, voice (TTS/STT/realtime), and professional CLI. 58+ external MCP servers discoverable, multimodal file processing, RAG pipelines. Build, test, and deploy AI applicatio

157 lines (156 loc) 4.79 kB
/** * @file EvaluationAggregator - Aggregates and analyzes evaluation results. * Provides statistical analysis, trend detection, and summary generation. */ import type { AggregationResult, EvaluationData, ScoreDistribution, ScoreStatistics, TrendAnalysis } from "../types/index.js"; /** * EvaluationAggregator - Aggregates evaluation results and provides analytics. * Supports statistical analysis, trend detection, and quality monitoring. * * @example * ```typescript * const aggregator = new EvaluationAggregator(); * * // Add evaluations * aggregator.addEvaluation(evaluation1); * aggregator.addEvaluation(evaluation2); * * // Get aggregation * const result = aggregator.aggregate({ threshold: 7 }); * console.log(`Average score: ${result.statistics.mean}`); * console.log(`Passing rate: ${result.passingRate}%`); * * // Get trend analysis * const trend = aggregator.analyzeSequenceTrend(); * console.log(`Quality is ${trend.direction}`); * ``` */ export declare class EvaluationAggregator { private evaluations; /** * Adds an evaluation to the aggregator. * * @param evaluation - The evaluation data to add */ addEvaluation(evaluation: EvaluationData): void; /** * Adds multiple evaluations to the aggregator. * * @param evaluations - Array of evaluation data to add */ addEvaluations(evaluations: EvaluationData[]): void; /** * Clears all evaluations from the aggregator. */ clear(): void; /** * Gets the current number of evaluations. */ getCount(): number; /** * Gets all evaluations. */ getEvaluations(): EvaluationData[]; /** * Aggregates all evaluations and returns comprehensive statistics. * * @param options - Aggregation options * @returns Comprehensive aggregation result */ aggregate(options?: { threshold?: number; }): AggregationResult; /** * Calculates statistical summary for a set of scores. * * @param scores - Array of scores * @returns Statistical summary */ calculateStatistics(scores: number[]): ScoreStatistics; /** * Calculates the distribution of scores across quality ranges. * * @param scores - Array of scores * @returns Score distribution */ calculateDistribution(scores: number[]): ScoreDistribution; /** * Analyzes sequence-based trends in evaluation scores (based on insertion order, not time). * * @param windowSize - Moving average window size (default: 5) * @returns Trend analysis */ analyzeSequenceTrend(windowSize?: number): TrendAnalysis; /** * Analyzes each evaluation dimension separately. * * @param relevance - Relevance scores * @param accuracy - Accuracy scores * @param completeness - Completeness scores * @param overall - Overall scores * @returns Dimension analysis */ private analyzeDimensions; /** * Summarizes alert information from evaluations. * * @returns Alert summary */ private summarizeAlerts; /** * Calculates a specific percentile from sorted data. * * @param sorted - Sorted array of numbers * @param p - Percentile (0-100) * @returns The value at the percentile */ private percentile; /** * Calculates Pearson correlation between two arrays. * * @param x - First array * @param y - Second array * @returns Correlation coefficient (-1 to 1) */ private correlation; /** * Gets evaluations that failed to meet the threshold. * * @param threshold - The passing threshold * @returns Array of failing evaluations */ getFailingEvaluations(threshold?: number): EvaluationData[]; /** * Gets evaluations with high severity alerts. * * @returns Array of high-alert evaluations */ getHighAlertEvaluations(): EvaluationData[]; /** * Gets evaluations marked as off-topic. * * @returns Array of off-topic evaluations */ getOffTopicEvaluations(): EvaluationData[]; /** * Gets the top N performing evaluations. * * @param n - Number of evaluations to return * @returns Array of top evaluations */ getTopEvaluations(n?: number): EvaluationData[]; /** * Gets the bottom N performing evaluations. * * @param n - Number of evaluations to return * @returns Array of bottom evaluations */ getBottomEvaluations(n?: number): EvaluationData[]; /** * Generates a text summary of the aggregation. * * @param threshold - The passing threshold * @returns Human-readable summary */ generateSummary(threshold?: number): string; }