import { evaluate, type EvalContext } from "ezvals";
async function runAgent(ctx: EvalContext) {
const result = await ragAgent(String(ctx.input));
ctx.store({ output: result.answer, metadata: { source_docs: result.docs } });
}
evaluate("test_rag", {
target: runAgent,
dataset: "rag_qa",
cases: [
{ input: "What is our refund policy?", reference: "30-day money-back guarantee" },
{ input: "How do I reset my password?", reference: "Click 'Forgot password' on the login page" },
{ input: "How long does shipping take?", reference: "3-5 business days" },
],
}, async (ctx) => {
const grounding = await groundingJudge(ctx.output, ctx.metadata.source_docs);
const correctness = await correctnessJudge(ctx.output, ctx.reference);
ctx.store({
scores: [
{ key: "grounded", passed: grounding.passed, notes: grounding.why },
{ key: "correct", passed: correctness.passed, notes: correctness.reason },
],
});
});