@dooor-ai/toolkit
Version:
Guards, Evals & Observability for AI applications - works seamlessly with LangChain/LangGraph
38 lines • 1.23 kB
TypeScript
import { Eval } from "./base";
import { EvalResult, EvalConfig } from "../core/types";
export interface FaithfulnessConfig extends EvalConfig {
/** Context/retrieved documents to check against */
context?: string;
}
/**
* FaithfulnessEval - Measures if the LLM's answer is grounded in the provided context
*
* Critical for RAG systems to prevent hallucination. Checks if claims in the answer
* are supported by the retrieved context.
*
* Example:
* ```typescript
* const eval = new FaithfulnessEval({
* threshold: 0.8,
* context: "The Eiffel Tower is 330 meters tall."
* });
* const result = await eval.evaluate(
* "How tall is the Eiffel Tower?",
* "The Eiffel Tower is 330 meters tall."
* );
* // result.score = 1.0, result.passed = true
* ```
*/
export declare class FaithfulnessEval extends Eval {
private context?;
constructor(config?: FaithfulnessConfig);
get name(): string;
/**
* Set context dynamically (useful for RAG pipelines)
*/
setContext(context: string): void;
evaluate(input: string, output: string, metadata?: Record<string, any>): Promise<EvalResult>;
private buildPrompt;
private parseScore;
}
//# sourceMappingURL=faithfulness.d.ts.map