/** * Testing API for langium-ai evaluations * * Provides a vitest-style API for defining evaluation test cases. */ import type { EvaluatorResult } from '../evaluator/evaluator.js'; /** * Standard data that can be expected from a case */ export type EvaluationData = { /** * Normalized score between 0 and 1 (0 = complete failure, 1 = full pass) */ score: number; /** * Whether this case was skipped (via .skip() or .only() filtering) */ skipped?: boolean; /** * When score is 0, expect an error here */ error?: Error | string; }; /** * Evaluation case result from running the lai cli * * A modified version of the baseline evaluator result, to accomodate for additional * requisite properties (certain metadat for cases + suites & a 'pass' result) */ export type EvaluationCaseResult = EvaluatorResult & { metadata: { /** * Containing evaluation file for the associated case */ evalFile: string; /** * Name of the suite that we ran under */ suiteName: string; /** * Evaluation case name */ caseName: string; /** * Duration of evaluation case from start to finish */ duration: number; }; }; export interface EvalContext { systemPrompt: string; project: { name: string; }; } /** * Evalutor function definition, takes some context & produce evaluation data */ export type EvaluatorFunction = (ctx: EvalContext) => Promise; interface EvalDefinition { name: string; fn: EvaluatorFunction; skip?: boolean; only?: boolean; } interface EvalSuite { name: string; evaluations: EvalDefinition[]; beforeAllHook?: () => void | Promise; afterAllHook?: () => void | Promise; beforeEachHook?: () => void | Promise; afterEachHook?: () => void | Promise; skip?: boolean; only?: boolean; } /** * Define a test suite */ export declare function describe(name: string, fn: () => void): void; export declare namespace describe { var skip: (name: string, fn: () => void) => void; var only: (name: string, fn: () => void) => void; } /** * Define an evaluation case */ export declare function evaluation(name: string, fn: EvaluatorFunction): void; export declare namespace evaluation { var skip: (name: string, fn: EvaluatorFunction) => void; var only: (name: string, fn: EvaluatorFunction) => void; var each: (cases: T[]) => (name: string, fn: (data: T) => EvaluatorFunction) => void; } /** * Define a hook that runs before each evaluation in the suite */ export declare function beforeEach(fn: () => void | Promise): void; /** * Define a hook that runs after each evaluation in the suite */ export declare function afterEach(fn: () => void | Promise): void; /** * Define a hook that runs once before all evaluations in the suite */ export declare function beforeAll(fn: () => void | Promise): void; /** * Define a hook that runs once after all evaluations in the suite */ export declare function afterAll(fn: () => void | Promise): void; /** * Export collected suites for runner */ export declare function getCollectedSuites(): EvalSuite[]; /** * Clear all collected suites */ export declare function clearSuites(): void; export { runEvalFile, type EvalProgressCallback } from './runner.js'; //# sourceMappingURL=index.d.ts.map