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

Function _evaluate_legacy

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

Evaluate a case using hardcoded invoice-specific comparators (legacy fallback).

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

Source from the content-addressed store, hash-verified

740
741
742def _evaluate_legacy(
743 case_id: str,
744 gt: dict,
745 agent: dict,
746 decision: dict,
747 tolerance: float,
748) -> dict:
749 """Evaluate a case using hardcoded invoice-specific comparators (legacy fallback)."""
750 financials = compare_financials(gt, agent, tolerance)
751 vendor = compare_vendor(gt, agent)
752 header = compare_header(gt, agent)
753 line_items = compare_line_items(gt, agent, tolerance)
754
755 all_correct = (
756 decision["match"]
757 and financials["all_match"]
758 and vendor["all_match"]
759 and header["all_match"]
760 and line_items["all_match"]
761 )
762
763 mismatches = _collect_legacy_mismatches(
764 decision, financials, vendor, header, line_items
765 )
766
767 return {
768 "case_id": case_id,
769 "status": "PASS" if all_correct else "FAIL",
770 "all_correct": all_correct,
771 "decision": decision,
772 "financials": financials,
773 "vendor": vendor,
774 "header": header,
775 "line_items": line_items,
776 "mismatches": mismatches,
777 }
778
779
780def _collect_field_mismatches(section: dict, labels: list[str]) -> list[str]:

Callers 1

evaluate_caseFunction · 0.85

Calls 5

compare_financialsFunction · 0.85
compare_vendorFunction · 0.85
compare_headerFunction · 0.85
compare_line_itemsFunction · 0.85

Tested by

no test coverage detected