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

75 lines (74 loc) 2.63 kB
/** * workflow/utils/workflowMetrics.ts * Metrics tracking and collection for workflow execution */ import type { JsonValue, EnsembleResponse, WorkflowResult, SummaryStats, WorkflowComparison, WorkflowExecutionMetrics } from "../../types/index.js"; /** * Workflow metrics tracker */ export declare class WorkflowMetrics { /** * Record a workflow execution */ recordExecution(workflowId: string, result: WorkflowResult): void; /** * Record a workflow failure */ recordFailure(workflowId: string, error: Error): void; /** * Get metrics for a specific workflow */ getMetrics(workflowId: string): WorkflowExecutionMetrics | undefined; /** * Get all workflow metrics */ getAllMetrics(): WorkflowExecutionMetrics[]; /** * Clear metrics for a workflow */ clearMetrics(workflowId: string): void; /** * Clear all metrics */ clearAllMetrics(): void; /** * Export metrics as JSON */ exportMetrics(): string; } /** * Calculate model-specific metrics from ensemble responses */ export declare function calculateModelMetrics(responses: EnsembleResponse[]): Record<string, { successRate: number; avgResponseTime: number; }>; /** * Calculate consensus level between responses * NOTE: Placeholder implementation - uses response length similarity * TODO: Implement semantic similarity in Phase 2 */ export declare function calculateConsensus(responses: EnsembleResponse[]): number; /** * Calculate confidence score from judge results and ensemble data */ export declare function calculateConfidence(ensembleResponses: EnsembleResponse[], judgeConfidence?: number, scores?: Record<string, number>): number; /** * Format metrics for logging * @param result - Workflow result to format * @returns Formatted metrics as JSON-compatible record */ export declare function formatMetricsForLogging(result: WorkflowResult): Record<string, JsonValue>; /** * Generate summary statistics for multiple executions * @param results - Array of workflow results to analyze * @returns Summary statistics including averages and success rate */ export declare function generateSummaryStats(results: WorkflowResult[]): SummaryStats; /** * Compare two workflows based on metrics * @param workflow1Results - Results from first workflow * @param workflow2Results - Results from second workflow * @returns Comparison with stats for both workflows and winner determination */ export declare function compareWorkflows(workflow1Results: WorkflowResult[], workflow2Results: WorkflowResult[]): WorkflowComparison;