Evaluate a case using hardcoded invoice-specific comparators (legacy fallback).
(
case_id: str,
gt: dict,
agent: dict,
decision: dict,
tolerance: float,
)
| 740 | |
| 741 | |
| 742 | def _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 | |
| 780 | def _collect_field_mismatches(section: dict, labels: list[str]) -> list[str]: |
no test coverage detected