feat(evaluation): add option to save eval results to CSV#6182
Open
vaibhav-patel wants to merge 2 commits into
Open
feat(evaluation): add option to save eval results to CSV#6182vaibhav-patel wants to merge 2 commits into
vaibhav-patel wants to merge 2 commits into
Conversation
Add an optional `output_file` parameter to `AgentEvaluator.evaluate` and `AgentEvaluator.evaluate_eval_set`. When set, per-invocation evaluation results for every metric (both passing and failing) are flattened and written to the given path as a CSV file, making it easy to persist and inspect results from pytest-based eval runs. The option is disabled by default, so existing behavior is unchanged. The parent directory is created if needed, and rows are appended so results from a directory of test files accumulate in a single file. CSV writing reuses the existing text/tool-call formatting helpers and relies on pandas, which is already part of the `eval` optional dependencies. Fixes google#2652.
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Author
|
@googlebot I signed it! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an optional, opt-in way to persist
AgentEvaluatorresults to a CSV file, as requested in #2652. A newoutput_fileparameter is added to bothAgentEvaluator.evaluateandAgentEvaluator.evaluate_eval_set. When provided, per-invocation results for every metric (both passing and failing) are written to the given path; when omitted (the default), behavior is unchanged.Motivation
Running agent evals from pytest currently only prints detailed tables (and only for failing metrics). Users want to save results to disk for later inspection/tracking. This implements the CSV suggestion from #2652, adapted to the current evaluation architecture (the codebase has changed substantially since the issue was filed).
What changed
output_file: Optional[str] = NoneonAgentEvaluator.evaluateandevaluate_eval_set.eval_set_id, eval_id, metric_name, threshold, score, eval_status, prompt, expected_response, actual_response, expected_tool_calls, actual_tool_calls..test.jsonfiles accumulates results in a single file.pandas, already declared in theevaloptional dependencies.Backward compatibility
Fully backward-compatible. The feature is disabled unless
output_fileis set.Testing
Added
tests/unittests/evaluation/test_agent_evaluator.pycovering row flattening, the missing-expected-invocation case, single-file writing with directory creation, and append-without-duplicate-header. All pass; the fulltests/unittests/evaluation/suite still collects cleanly.Fixes #2652.