text stringlengths 0 59.1k |
|---|
runner: async ({ item }) => { |
const docs = await retriever.retrieve(item.input); |
const answer = await agent.generateText(item.input, { context: docs }); |
return { |
output: answer.text, |
metadata: { |
docs: docs.map((d) => d.id), |
tokens: answer.usage?.total_tokens, |
}, |
}; |
}, |
scorers: [ |
{ scorer: scorers.answerCorrectness, threshold: 0.8 }, |
{ scorer: scorers.contextRelevancy, threshold: 0.7 }, |
], |
passCriteria: [ |
{ type: "meanScore", min: 0.75 }, |
{ type: "passRate", min: 0.9 }, |
], |
}); |
``` |
## Next Steps |
- [Prebuilt Scorers](/evaluation-docs/prebuilt-scorers) - Full catalog of prebuilt scorers |
- [Building Custom Scorers](/evaluation-docs/building-custom-scorers) - Create your own evaluation scorers |
<|endoftext|> |
# source: VoltAgent__voltagent/website/evaluation-docs/live-evaluations.md type: docs |
--- |
title: Live Evaluations |
sidebar_position: 3 |
--- |
# Live Evaluations |
Live evaluations run scorers against real-time agent interactions. Attach scorers to agents during initialization to sample production traffic, enforce safety guardrails, and monitor conversation quality without running separate evaluation jobs. |
## Configuring Live Scorers |
Define scorers in the `eval` config when creating an agent: |
```ts |
import { Agent, VoltAgentObservability } from "@voltagent/core"; |
import { createModerationScorer } from "@voltagent/scorers"; |
import { openai } from "@ai-sdk/openai"; |
const observability = new VoltAgentObservability(); |
const agent = new Agent({ |
name: "support-agent", |
instructions: "Answer customer questions about products.", |
model: openai("gpt-4o"), |
eval: { |
triggerSource: "production", |
environment: "prod-us-east", |
sampling: { type: "ratio", rate: 0.1 }, |
scorers: { |
moderation: { |
scorer: createModerationScorer({ |
model: openai("gpt-4o-mini"), |
threshold: 0.5, |
}), |
}, |
}, |
}, |
}); |
``` |
Scorers execute asynchronously after the agent response is generated. Scoring does not block the user-facing response. |
## Where live scores show up |
Live scorer results are recorded as OTLP trace spans with `eval.scorer.*` attributes. They appear in VoltOps Live Scores and telemetry views. They do not create Eval Runs, are not attached to datasets, and do not trigger annotation automation. If you need reproducible runs, pass/fail criteria, or annotations, use datas... |
## Eval Configuration |
### Required Fields |
None - all fields are optional. If no scorers are defined, evaluation is disabled. |
### Optional Fields |
#### `triggerSource` |
Tags the evaluation run with a trigger identifier. Use to distinguish between environments or traffic sources. |
```ts |
triggerSource: "production"; // live traffic |
triggerSource: "staging"; // pre-production |
triggerSource: "manual"; // manual testing |
``` |
Default: `"live"` when unspecified. |
#### `environment` |
Labels the evaluation with an environment tag. Appears in telemetry and VoltOps dashboards. |
```ts |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.