/** * ThinkHive SDK v3.0 - Deterministic Graders API * * API for running deterministic (code-based) evaluations */ export type RuleType = 'regex' | 'contains' | 'not_contains' | 'json_valid' | 'json_schema' | 'length' | 'pii_check' | 'sentiment' | 'latency' | 'token_count'; export interface DeterministicEvalResult { passed: boolean; score: number; reasoning: string; ruleResults?: RuleResult[]; metadata?: Record; } export interface RuleResult { ruleId: string; ruleName: string; ruleType: RuleType; passed: boolean; score: number; details?: string; } export interface EvaluateOptions { traceId: string; criterionId: string; } export interface BulkEvaluateOptions { evaluations: Array<{ traceId: string; criterionId: string; }>; } export interface BulkEvaluateResult { results: Array<{ traceId: string; criterionId: string; passed: boolean; score: number; error?: string; }>; summary: { total: number; passed: number; failed: number; passRate: number; }; } export interface RuleTypeInfo { id: RuleType; name: string; description: string; configFields: string[]; } export interface RuleTemplate { id: string; name: string; description: string; ruleType: RuleType; config: Record; } /** * Deterministic Graders API client for code-based evaluations */ export declare const deterministicGraders: { /** * Run deterministic evaluation on a single trace * * @example * ```typescript * const result = await deterministicGraders.evaluate({ * traceId: 'trace_123', * criterionId: 'criterion_456', * }); * console.log(`Passed: ${result.passed}, Score: ${result.score}`); * ``` */ evaluate(options: EvaluateOptions): Promise; /** * Run deterministic evaluations on multiple traces * * @example * ```typescript * const { results, summary } = await deterministicGraders.bulkEvaluate({ * evaluations: [ * { traceId: 'trace_1', criterionId: 'criterion_456' }, * { traceId: 'trace_2', criterionId: 'criterion_456' }, * { traceId: 'trace_3', criterionId: 'criterion_456' }, * ], * }); * console.log(`Pass rate: ${summary.passRate * 100}%`); * ``` */ bulkEvaluate(options: BulkEvaluateOptions): Promise; /** * Get available rule types with descriptions * * @example * ```typescript * const ruleTypes = await deterministicGraders.getRuleTypes(); * for (const type of ruleTypes) { * console.log(`${type.name}: ${type.description}`); * } * ``` */ getRuleTypes(): Promise; /** * Get rule templates * * @example * ```typescript * const templates = await deterministicGraders.getTemplates(); * const noPiiTemplate = templates.find(t => t.id === 'no_pii'); * ``` */ getTemplates(): Promise; }; /** * Named rule configuration with type, name, and config */ export interface NamedRuleConfig { type: RuleType; name: string; config: Record; } /** * Create a regex rule configuration * * @param name - Rule name for identification * @param field - Field to check ('output', 'input', etc.) * @param pattern - Regular expression pattern * @param flags - Regex flags (default: 'gi') * @returns Named rule configuration object * * @example * ```typescript * const rule = createRegexRule('email_check', 'output', '\\w+@\\w+\\.\\w+'); * ``` */ export declare function createRegexRule(name: string, field: string, pattern: string, flags?: string): NamedRuleConfig; /** * Create a contains rule configuration * * @param name - Rule name for identification * @param field - Field to check ('output', 'input', etc.) * @param values - Strings to check for * @param caseSensitive - Whether comparison is case-sensitive * @returns Named rule configuration object * * @example * ```typescript * const rule = createContainsRule('greeting', 'output', ['hello', 'hi', 'hey']); * ``` */ export declare function createContainsRule(name: string, field: string, values: string[], caseSensitive?: boolean): NamedRuleConfig; /** * Create a length rule configuration * * @param name - Rule name for identification * @param min - Minimum length (optional) * @param max - Maximum length (optional) * @returns Named rule configuration object * * @example * ```typescript * const rule = createLengthRule('response_length', 50, 1000); * ``` */ export declare function createLengthRule(name: string, min?: number, max?: number): NamedRuleConfig; /** * Create a JSON schema rule configuration * * @param name - Rule name for identification * @param schema - JSON Schema object * @returns Named rule configuration object * * @example * ```typescript * const rule = createJsonSchemaRule('response_format', { * type: 'object', * required: ['name', 'email'], * properties: { * name: { type: 'string' }, * email: { type: 'string', format: 'email' }, * }, * }); * ``` */ export declare function createJsonSchemaRule(name: string, schema: Record): NamedRuleConfig; /** * Check if all rule results passed * * @param results - Array of rule results (or any objects with a `passed` boolean) * @returns Whether all rules passed */ export declare function allRulesPassed(results: Array<{ passed: boolean; }>): boolean; /** * Get failed rules from results * * @param results - Array of rule results (or any objects with a `passed` boolean) * @returns Array of failed rule results */ export declare function getFailedRules(results: T[]): T[]; /** * Calculate average score from rule results * * @param results - Array of rule results * @returns Average score (0-100) */ export declare function calculateAverageScore(results: Array<{ score: number; }>): number;