Write an eval that runs an agent or a tool on test cases and scores each answer with metrics. Run it after every change to catch a worse answer before you publish.
Before you start
You need an agent. See Create an agent.
Write an eval
- In a project from the AI Agent template (see Build your first agent), create an eval for its
assistant. The file name becomes its ID, so this one isdivide:evals/divide.eval.tsimport { datasets, evalAgent, metrics } from 'veryfront/eval' export default evalAgent({ name: 'Divide', target: 'agent:assistant', dataset: datasets.inline([{ id: 'divide', input: 'What is 128 divided by 8?' }]), metrics: [metrics.agent.calledTool('calculator').gate(), metrics.answer.contains({ text: '16' }).gate()],}) - Run it:
Shell
npm run eval -- divide - Read the result. You should now see
1/1 passed.
Try it in a sandbox
Create the project
Go into it
Create the eval
Check it