Loading...
const answer = await summarize(sampleText);
console.log(answer); // looks goodconst cases = [
{ input: refundEmail, expect: (out) => out.category === 'refund' },
{ input: emptyEmail, expect: (out) => out.category === 'unknown' },
];
for (const c of cases) {
const out = await classify(c.input);
if (!c.expect(out)) failed.push(c);
}
console.log(`${cases.length - failed.length}/${cases.length} passed`);A fixed set of cases with pass checks, including edge cases, gives a score you can compare after every prompt or model change.
Unit tests expect the same output every time. Evals measure how often a non-deterministic model passes, so results are scores, not just pass or fail.
Start with a few dozen real cases, including hard and edge cases, and add every bug found in production as a new case.
Use check functions where possible, and an LLM judge with a clear rubric for the rest, validated against human labels.