@eval decorator marks functions as evaluations. Here’s a complete example:
Configuration Options
Dataset
Groups related evaluations together:If not specified, dataset defaults to the filename (e.g.,
evals.py → evals).Labels
Tags for filtering:Pre-populated Fields
Set context fields directly in the decorator:Default Score Key
Specify the key for scores (used when assertions fail or withstore(scores=...)):
Timeout
Set a maximum execution time:Target Hook
Run a function before the evaluation body:Evaluators
Post-processing functions that add scores:Input Loader
Load test examples dynamically from external sources (databases, APIs):- Return a list of dicts with
input,reference, and/ormetadatakeys - Or return objects with
.input,.reference,.metadataattributes
input_loader cannot be combined with input=, reference=, or cases=.Sync and Async
Both sync and async functions work—just useasync def if your code uses await.
Returning Multiple Results
Return a list ofEvalResult objects for batch evaluations:

