UNPKG

@ai2070/l0

Version:

L0: The Missing Reliability Substrate for AI

101 lines 3.08 kB
import type { z } from "zod"; export interface EvaluationOptions<T = any> { expected: T | z.ZodTypeAny; actual: any; style?: ComparisonStyle; threshold?: number; numericTolerance?: number; ignoreArrayOrder?: boolean; ignoreExtraFields?: boolean; customComparisons?: Record<string, ComparisonFunction>; metadata?: Record<string, any>; } export type ComparisonStyle = "strict" | "lenient"; export type ComparisonFunction = (expected: any, actual: any) => boolean | number; export interface EvaluationResult { match: boolean; score: number; differences: Difference[]; details: EvaluationDetails; metadata?: Record<string, any>; } export interface EvaluationDetails { exactMatch: boolean; schemaValid: boolean; structureMatch: boolean; contentSimilarity: number; fieldsCompared: number; fieldsMatched: number; comparisonType: ComparisonType; } export type ComparisonType = "exact" | "schema" | "structural" | "fuzzy" | "numeric" | "mixed"; export interface Difference { path: string; expected: any; actual: any; type: DifferenceType; severity: DifferenceSeverity; message: string; similarity?: number; } export type DifferenceType = "missing" | "extra" | "different" | "type-mismatch" | "structure-mismatch" | "schema-violation"; export type DifferenceSeverity = "error" | "warning" | "info"; export interface EvaluationTest<T = any> { name: string; expected: T | z.ZodTypeAny; actual: any; style?: ComparisonStyle; threshold?: number; metadata?: Record<string, any>; } export interface BatchEvaluationResult { passed: boolean; passCount: number; failCount: number; total: number; averageScore: number; results: EvaluationTestResult[]; summary: { exactMatches: number; schemaValid: number; fuzzyMatches: number; totalDifferences: number; }; } export interface EvaluationTestResult { name: string; passed: boolean; result: EvaluationResult; metadata?: Record<string, any>; } export interface StringComparisonOptions { caseSensitive?: boolean; normalizeWhitespace?: boolean; algorithm?: "levenshtein" | "jaro-winkler" | "cosine"; threshold?: number; } export interface ObjectComparisonOptions { style: ComparisonStyle; ignoreExtraFields: boolean; ignoreArrayOrder: boolean; numericTolerance: number; customComparisons?: Record<string, ComparisonFunction>; } export interface SchemaValidationResult { valid: boolean; data?: any; errors?: z.ZodError; differences: Difference[]; } export interface EvaluationPreset { name: string; style: ComparisonStyle; threshold: number; ignoreArrayOrder: boolean; ignoreExtraFields: boolean; numericTolerance: number; } export declare const strictEvaluation: Partial<EvaluationOptions>; export declare const lenientEvaluation: Partial<EvaluationOptions>; export declare const testingEvaluation: Partial<EvaluationOptions>; //# sourceMappingURL=evaluate.d.ts.map