@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
83 lines (82 loc) • 2.6 kB
TypeScript
/**
* @file Abstract base scorer class providing common functionality
* All scorers extend this class for consistent behavior
*/
import type { JsonObject, ScoreResult, Scorer, ScorerConfig, ScorerInput, ScorerMetadata, ScoreScale } from "../../types/index.js";
/**
* Default score scale (0-10)
*/
export declare const DEFAULT_SCORE_SCALE: ScoreScale;
/**
* Default scorer configuration
*/
export declare const DEFAULT_SCORER_CONFIG: ScorerConfig;
/**
* Abstract base class for all scorers
* Provides common functionality and enforces interface compliance
*/
export declare abstract class BaseScorer implements Scorer {
protected _config: ScorerConfig;
protected _metadata: ScorerMetadata;
constructor(metadata: ScorerMetadata, config?: ScorerConfig);
/**
* Get scorer metadata
*/
get metadata(): ScorerMetadata;
/**
* Get current configuration
*/
get config(): ScorerConfig;
/**
* Main scoring method - must be implemented by subclasses
*/
abstract score(input: ScorerInput): Promise<ScoreResult>;
/**
* Validate input has required fields
*/
validateInput(input: ScorerInput): {
valid: boolean;
errors: string[];
};
/**
* Update configuration
*/
configure(config: Partial<ScorerConfig>): void;
/**
* Normalize a score to 0-1 scale
*/
protected normalizeScore(score: number, scale?: ScoreScale): number;
/**
* Convert normalized score back to scale
*/
protected denormalizeScore(normalizedScore: number, scale?: ScoreScale): number;
/**
* Check if score passes threshold
*/
protected checkThreshold(normalizedScore: number): boolean;
/**
* Create a standardized score result
*/
protected createScoreResult(score: number, reasoning: string, options?: {
scale?: ScoreScale;
confidence?: number;
metadata?: JsonObject;
error?: string;
}): ScoreResult;
/**
* Create an error score result
*/
protected createErrorResult(error: Error | string): ScoreResult;
/**
* Execute scoring with timing and error handling
*/
protected executeWithTiming(scoringFn: () => Promise<Omit<ScoreResult, "computeTime">>): Promise<ScoreResult>;
/**
* Execute scoring with timeout
*/
protected executeWithTimeout<T>(fn: () => Promise<T>, timeoutMs: number, operationName: string): Promise<T>;
/**
* Execute with retry logic
*/
protected executeWithRetry<T>(operation: () => Promise<T>, retries?: number): Promise<T>;
}