#[non_exhaustive]pub struct Case {
pub id: String,
pub input: String,
pub turns: Vec<String>,
pub expected: Option<String>,
pub trajectory: Option<Vec<ExpectedCall>>,
pub assertions: Vec<String>,
pub metadata: Map<String, Value>,
}Expand description
One input to run the target on, with the references evaluators check the run against: the expected answer, the expected tool calls, and assertions in plain language (for an LLM judge).
A case is single-turn (input) or multi-turn (turns): see
Case::turns. The same three references as AWS Bedrock AgentCore’s
evaluation reference inputs and Strands Evals’ cases.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.id: StringNames the case in reports; unique within a dataset.
input: StringThe prompt the target gets. Empty for a multi-turn case, which sets
turns instead; a case sets one or the other.
turns: Vec<String>The user turns of a multi-turn case, sent in order on one conversation. Empty for a single-turn case.
expected: Option<String>The expected answer.
trajectory: Option<Vec<ExpectedCall>>The tool calls the target is expected to make.
assertions: Vec<String>Statements the answer must satisfy, in plain language.
metadata: Map<String, Value>Anything else, kept in reports.
Implementations§
Source§impl Case
impl Case
Sourcepub fn new(id: impl Into<String>, input: impl Into<String>) -> Self
pub fn new(id: impl Into<String>, input: impl Into<String>) -> Self
A case id with prompt input and no references.
Sourcepub fn multi_turn<I, S>(id: impl Into<String>, turns: I) -> Self
pub fn multi_turn<I, S>(id: impl Into<String>, turns: I) -> Self
A multi-turn case id: each of turns is a user message, sent in
order on one conversation, so a turn can refer to the answers before
it. The target answers the last turn; evaluators see the whole
transcript as well (see Trial::transcript).
use rig_evals::Case;
let case = Case::multi_turn("trip", ["Plan a trip to Lisbon.", "Which month is best?"]);
assert_eq!(case.prompts().len(), 2);Sourcepub fn turns<I, S>(self, turns: I) -> Self
pub fn turns<I, S>(self, turns: I) -> Self
Make this a multi-turn case with turns, replacing input.
Sourcepub fn prompts(&self) -> Vec<&str>
pub fn prompts(&self) -> Vec<&str>
The user turns, in order: turns of a multi-turn case, else the one
input.
Sourcepub fn trajectory(self, calls: impl IntoIterator<Item = ExpectedCall>) -> Self
pub fn trajectory(self, calls: impl IntoIterator<Item = ExpectedCall>) -> Self
Set the expected tool calls.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Case
impl<'de> Deserialize<'de> for Case
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl FromIterator<Case> for Dataset
impl FromIterator<Case> for Dataset
impl StructuralPartialEq for Case
Auto Trait Implementations§
impl Forget for Case
impl Freeze for Casewhere
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
PhantomData<String>: Freeze,
PhantomData<ExpectedCall>: Freeze,
*const LeafNode<String, Value> is !null: Freeze,
PhantomData<(Owned, LeafOrInternal)>: Freeze,
PhantomData<Box<(String, Value)>>: Freeze,
impl Move for Case
impl RefUnwindSafe for Case
impl Send for Case
impl Sync for Case
impl Unpin for Case
impl UnsafeUnpin for Casewhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<String>: UnsafeUnpin,
PhantomData<ExpectedCall>: UnsafeUnpin,
*const LeafNode<String, Value> is !null: UnsafeUnpin,
PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin,
PhantomData<Box<(String, Value)>>: UnsafeUnpin,
impl UnwindSafe for Case
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more