@dooor-ai/toolkit
Version:
Guards, Evals & Observability for AI applications - works seamlessly with LangChain/LangGraph
46 lines • 1.56 kB
TypeScript
import { Eval } from "./base";
import { EvalResult, EvalConfig } from "../core/types";
export interface ContextualRecallConfig extends EvalConfig {
/** Expected answer or ground truth */
expectedAnswer?: string;
/** Retrieved context/documents */
context?: string;
}
/**
* ContextualRecallEval - Measures if the retrieval system found all relevant information
*
* Evaluates whether the retrieved context contains all the information needed to
* answer the question correctly. High recall means nothing important was missed.
*
* Example:
* ```typescript
* const eval = new ContextualRecallEval({
* threshold: 0.8,
* expectedAnswer: "Paris is the capital and was founded in 3rd century BC.",
* context: "Paris is the capital of France."
* });
* const result = await eval.evaluate(
* "What is the capital of France and when was it founded?",
* "The capital is Paris."
* );
* // result.score = 0.5 (missed founding date info), result.passed = false
* ```
*/
export declare class ContextualRecallEval extends Eval {
private expectedAnswer?;
private context?;
constructor(config?: ContextualRecallConfig);
get name(): string;
/**
* Set expected answer dynamically
*/
setExpectedAnswer(answer: string): void;
/**
* Set context dynamically
*/
setContext(context: string): void;
evaluate(input: string, output: string, metadata?: Record<string, any>): Promise<EvalResult>;
private buildPrompt;
private parseScore;
}
//# sourceMappingURL=contextual-recall.d.ts.map