-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Include evals report averages in span attributes #3053
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
7fdab58
53b4af4
1c1c804
52af873
2002a26
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -324,6 +324,8 @@ async def _handle_case(case: Case[InputsT, OutputT, MetadataT], report_case_name | |
| trace_id=trace_id, | ||
| ) | ||
| if (averages := report.averages()) is not None and averages.assertions is not None: | ||
| experiment_metadata = {'n_cases': len(self.cases), 'averages': averages} | ||
| eval_span.set_attribute('experiment.metadata', experiment_metadata) | ||
|
||
| eval_span.set_attribute('assertion_pass_rate', averages.assertions) | ||
| return report | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1496,10 +1496,36 @@ async def mock_async_task(inputs: TaskInput) -> TaskOutput: | |
| 'assertion_pass_rate': 1.0, | ||
| 'logfire.msg_template': 'evaluate {name}', | ||
| 'logfire.msg': 'evaluate mock_async_task', | ||
| 'experiment.metadata': { | ||
| 'n_cases': 2, | ||
| 'averages': { | ||
|
||
| 'name': 'Averages', | ||
| 'scores': {'confidence': 1.0}, | ||
| 'labels': {}, | ||
| 'metrics': {}, | ||
| 'assertions': 1.0, | ||
| 'task_duration': 1.0, | ||
| 'total_duration': 9.0, | ||
| }, | ||
| }, | ||
| 'logfire.span_type': 'span', | ||
| 'logfire.json_schema': { | ||
| 'type': 'object', | ||
| 'properties': {'name': {}, 'n_cases': {}, 'assertion_pass_rate': {}}, | ||
| 'properties': { | ||
| 'name': {}, | ||
| 'n_cases': {}, | ||
| 'experiment.metadata': { | ||
| 'type': 'object', | ||
| 'properties': { | ||
| 'averages': { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd expect There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's normal, schemas for primitives only appear at the top level. |
||
| 'type': 'object', | ||
| 'title': 'ReportCaseAggregate', | ||
| 'x-python-datatype': 'PydanticModel', | ||
| } | ||
| }, | ||
| }, | ||
| 'assertion_pass_rate': {}, | ||
| }, | ||
| }, | ||
| }, | ||
| ), | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the test below, it looks like we already had
n_casesin here, do we need to repeat it? Or could we drop it there and have it just under the metadata?