text
stringlengths
0
59.1k
output: result.text,
};
},
scorers: [scorers.levenshtein],
});
```
By default, scorers have a **threshold of 0**, meaning every item passes regardless of the score. The scorer produces a numeric score (0.0 to 1.0), but without a threshold, it doesn't affect pass/fail status.
## Step 3: Set a Threshold
Make the scorer meaningful by adding a `threshold`. Items fail if their score falls below this value.
```ts
import { createExperiment } from "@voltagent/evals";
import { Agent } from "@voltagent/core";
import { openai } from "@ai-sdk/openai";
import { scorers } from "@voltagent/scorers";
export default createExperiment({
id: "offline-smoke",
dataset: {
items: [
{
id: "1",
input: "The color of the sky",
expected: "blue",
},
{
id: "2",
input: "2+2",
expected: "4",
},
],
},
runner: async ({ item }) => {
const supportAgent = new Agent({
name: "offline-evals-support",
instructions: "You are a helpful assistant. Answer questions very short.",
model: openai("gpt-4o-mini"),
});
const result = await supportAgent.generateText(item.input);
return {
output: result.text,
};
},
scorers: [
{
scorer: scorers.levenshtein,
threshold: 0.5,
},
],
});
```
Now, if the levenshtein score is below 0.5, the item is marked as `failed`. You can also assign a custom `id` to reference this scorer in pass criteria:
```ts
scorers: [
{
id: "my-custom-scorer-id",
scorer: scorers.levenshtein,
threshold: 0.5,
},
],
```
## Step 4: Add Pass Criteria
While individual scorers determine if each item passes or fails, **pass criteria** define whether the **entire experiment** succeeds. Use `passCriteria` to set overall success conditions.
There are two types of criteria:
- **`meanScore`**: Average score across all items must meet a minimum
- **`passRate`**: Percentage of passed items must meet a minimum
```ts
import { createExperiment } from "@voltagent/evals";
import { Agent } from "@voltagent/core";
import { openai } from "@ai-sdk/openai";
import { scorers } from "@voltagent/scorers";
export default createExperiment({
id: "offline-smoke",
dataset: {
items: [
{
id: "1",
input: "The color of the sky",
expected: "blue",
},
{
id: "2",
input: "2+2",
expected: "4",
},
],
},
runner: async ({ item }) => {
const supportAgent = new Agent({