MCPcopy Create free account
hub / github.com/google/adk-samples / _evaluate_schema_driven

Function _evaluate_schema_driven

python/agents/invoice-processing/eval/eval.py:708–739  ·  view source on GitHub ↗

Evaluate a case using schema-driven comparison groups from master data.

(
    case_id: str,
    gt: dict,
    agent: dict,
    decision: dict,
    master: MasterData,
    tolerance: float,
)

Source from the content-addressed store, hash-verified

706
707
708def _evaluate_schema_driven(
709 case_id: str,
710 gt: dict,
711 agent: dict,
712 decision: dict,
713 master: MasterData,
714 tolerance: float,
715) -> dict:
716 """Evaluate a case using schema-driven comparison groups from master data."""
717 group_results = _run_comparison_groups(gt, agent, master, tolerance)
718 mismatches = _collect_schema_mismatches(decision, group_results)
719
720 all_correct = decision["match"] and all(
721 r.get("all_match", True) for r in group_results.values()
722 )
723
724 result_dict = {
725 "case_id": case_id,
726 "status": "PASS" if all_correct else "FAIL",
727 "all_correct": all_correct,
728 "decision": decision,
729 "mismatches": mismatches,
730 }
731 for gid, result in group_results.items():
732 result_dict[gid] = result
733
734 # Keep backward-compatible keys for the standard invoice groups
735 for compat_key in ("financials", "vendor", "header", "line_items"):
736 if compat_key in group_results:
737 result_dict[compat_key] = group_results[compat_key]
738
739 return result_dict
740
741
742def _evaluate_legacy(

Callers 1

evaluate_caseFunction · 0.85

Calls 4

_run_comparison_groupsFunction · 0.85
itemsMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected