Repository navigation
feat: add rubric_with_history multi-turn evaluator - #12
sowndappan5 wants to merge 2 commits into
Conversation
|
added only conversation_history and earlier turns evidence rule. matched adk's format. added pre-sample exception handling, removed .pyc. fixed typo pre-sample to per-sample. set defaults to turn index, num_samples. @krisztianfekete |
krisztianfekete
left a comment
There was a problem hiding this comment.
Added some comments, also please update the description.
| <available_tools> | ||
| {{ | ||
| 'name': 'load_hr_data_from_file', | ||
| 'description': 'Reads a data file from the company\\'s HR database into a Pandas DataFrame.' |
There was a problem hiding this comment.
Nit: \\' here and \\n on L159/L232 put a literal \' and \n into the prompt, where ADK has a plain ' and a real newline. Please drop the extra backslashes to match ADK exactly.
|
|
||
| answered_ids = {v.rubric_id for v in parsed if v.score is not None} | ||
| if any(r.rubric_id not in answered_ids for r in rubrics): | ||
| return [] |
There was a problem hiding this comment.
Dropping the whole sample when the judge skips one rubric is fine, but please mention it in the docstring so a NOT_EVALUATED with several rubrics isn't a surprise for the users.
| def select_target_indices(invocations: list[InvocationData], config: dict[str, Any]) -> list[int]: | ||
| """Resolve which invocation indices to grade (defaults to the final turn ``-1``).""" | ||
| n = len(invocations) | ||
| all_turns = bool(config.get("all_turns", False)) |
There was a problem hiding this comment.
bool("false") is True, so all_turns: "false" grades every turn. Please require an actual bool, as turn_index already does for ints.
| judge_model = str(input.config.get("judge_model") or DEFAULT_JUDGE_MODEL) | ||
| judge_base_url = input.config.get("judge_base_url") or input.config.get("base_url") | ||
| raw_samples = input.config.get("num_samples") | ||
| num_samples = DEFAULT_NUM_SAMPLES if raw_samples is None else int(raw_samples) |
There was a problem hiding this comment.
num_samples: "five" raises an uncaught ValueError (same for float() on L616), so the run crashes instead of returning NOT_EVALUATED. Validate these the same way as turn_index.
|
|
||
| samples: list[list[RubricVerdict]] = [] | ||
| sample_errors: list[str] = [] | ||
| for _ in range(num_samples): |
There was a problem hiding this comment.
The samples run one after another, so all_turns will quickly go over the 120s timeout. Consider running them concurrently with a small ThreadPoolExecutor.
| sample_errors.append(f"{type(exc).__name__}: {exc}") | ||
| continue | ||
| parsed = parse_judge_response(raw_reply, rubrics) | ||
| if parsed: |
There was a problem hiding this comment.
Replies that fail to parse are dropped without a trace. Add them to sample_errors (e.g. "unparseable judge reply") so you can see when a verdict rests on 1 of 5 samples.
| status=EvalStatus.NOT_EVALUATED, | ||
| per_invocation_scores=per_invocation_scores, | ||
| details={ | ||
| "error": "Judge returned no parseable rubric verdicts for the evaluated turn(s).", |
There was a problem hiding this comment.
If every sample raised (e.g. a 401), this message hides the cause. Include the first sample_errors entry in error.
What it does: Grades a selected turn (turn_index or invocation_id) or every turn against rubrics using preceding turns (0..i-1) as context while excluding future turns.
Key behavior: Uses ADK's dialogue format, treats earlier user turns and sound tool outputs as proof, and treats earlier assistant text replies as context only (not factual proof).
Files included: evaluator.yaml, rubric_with_history.py, and requirements.txt (litellm>=1.0.0).