(
record: RouteRecord, known_routes: set[str], min_confidence: float
)
| 488 | |
| 489 | |
| 490 | def _classify_route( |
| 491 | record: RouteRecord, known_routes: set[str], min_confidence: float |
| 492 | ) -> tuple[Outcome, str]: |
| 493 | decision, reason = _parse_decision(record, ChoiceDecision) |
| 494 | if not isinstance(decision, ChoiceDecision): |
| 495 | return "failed", reason |
| 496 | if decision.choice not in known_routes: |
| 497 | return "failed", f"choice {decision.choice!r} is not a known route" |
| 498 | if decision.confidence < min_confidence: |
| 499 | return ( |
| 500 | "abstained", |
| 501 | f"confidence {decision.confidence} below min_confidence {min_confidence}", |
| 502 | ) |
| 503 | outcome: Outcome = ( |
| 504 | "correct" if decision.choice == record.expected_route else "incorrect" |
| 505 | ) |
| 506 | return ( |
| 507 | outcome, |
| 508 | f"confidence {decision.confidence} meets min_confidence {min_confidence}", |
| 509 | ) |
| 510 | |
| 511 | |
| 512 | def _classify_guardrail( |
no test coverage detected