Write an eval

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

  1. 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 is divide:
    evals/divide.eval.ts
    import { 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()],})
  2. Run it:
    Shell
    npm run eval -- divide
  3. Read the result. You should now see 1/1 passed.

Try it in a sandbox

  1. Create the project

  2. Go into it

  3. Create the eval

  4. Check it

Try it out

Next steps