1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
//! Evaluations for [Rig](https://github.com/0xPlaygrounds/rig) agents.
//!
//! An [`Experiment`] runs a [`Target`] (a Rig agent, an async function, or,
//! with the `multiagent` feature, a swarm or graph) on every [`Case`] of a
//! [`Dataset`], scores each run with [`Evaluator`]s, and hands the
//! [`Report`] to [`Sink`]s.
//!
//! ```no_run
//! use rig_evals::{Dataset, Experiment, JunitFile, evaluators};
//!
//! async fn run(agent: rig_agent::Agent) -> Result<(), Box<dyn std::error::Error>> {
//! let report = Experiment::new("support-bot")
//! .dataset(Dataset::load("evals/cases.jsonl")?)
//! .target(agent)
//! .evaluator(evaluators::contains("refund"))
//! .evaluator(evaluators::no_error())
//! .repetitions(3)
//! .threshold("contains", 0.8)
//! .sink(JunitFile::new("target/evals/junit.xml"))
//! .run()
//! .await?;
//! std::process::exit(if report.passed() { 0 } else { 1 });
//! }
//! ```
//!
//! A dataset is a `.jsonl` file (one case per line) or a `.json` array. A case
//! has an `id` and either an `input` (one prompt) or `turns` (a conversation).
//! `expected`, `trajectory` (`name` and optional `args` per tool call),
//! `assertions` and `metadata` are optional references. A three-case file:
//!
//! ```jsonl
//! {"id": "refund", "input": "Order 7 arrived broken.", "expected": "A refund was issued.", "trajectory": [{"name": "lookup_order", "args": {"id": 7}}, {"name": "refund"}], "assertions": ["apologizes"]}
//! {"id": "hours", "input": "What are your opening hours?", "expected": "We are open 9 to 5.", "assertions": ["gives the hours"]}
//! {"id": "city", "turns": ["My favourite city is Lisbon.", "What is my favourite city?"], "expected": "Lisbon"}
//! ```
//!
//! With the `agentcore` feature, `AgentCore` makes a runtime on AWS Bedrock
//! AgentCore a target, and AgentCore Evaluations' evaluators evaluators.
//!
//! Each run is a `tracing` span `eval.trial` inside an `eval.experiment` span,
//! and each score an OpenTelemetry GenAI `gen_ai.evaluation.result` event on
//! it, so a tracing exporter (such as rig-otel) puts the results on the
//! evaluated agent's trace. The agent's prompts and replies reach that trace
//! only when it records content, with `AgentBuilder::record_content_telemetry(true)`.
//! A score's explanation (the judge's text) is recorded only with
//! `Experiment::record_content(true)`.
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
// The README's AgentCore example needs the `agentcore` feature, so the
// README is compile-checked only with it enabled (CI uses --all-features).