(args: list[str])
| 1526 | |
| 1527 | |
| 1528 | def _cmd_feedback(args: list[str]) -> None: |
| 1529 | from uncommon_route.calibration import get_active_route_confidence_calibrator |
| 1530 | from uncommon_route.router.classifier import ( |
| 1531 | _get_online_model_path, |
| 1532 | rollback_online_model, |
| 1533 | ) |
| 1534 | from uncommon_route.stats import RouteStats |
| 1535 | |
| 1536 | if not args: |
| 1537 | args = ["status"] |
| 1538 | |
| 1539 | sub = args[0] |
| 1540 | calibrator = get_active_route_confidence_calibrator() |
| 1541 | |
| 1542 | if sub == "status": |
| 1543 | online_path = _get_online_model_path() |
| 1544 | active = online_path.exists() |
| 1545 | print(f" Online model: {'active' if active else 'inactive (using base model)'}") |
| 1546 | if active: |
| 1547 | import os |
| 1548 | size_kb = os.path.getsize(online_path) / 1024 |
| 1549 | mtime = os.path.getmtime(online_path) |
| 1550 | ts = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(mtime)) |
| 1551 | print(f" Path: {online_path}") |
| 1552 | print(f" Size: {size_kb:.0f} KB") |
| 1553 | print(f" Last updated: {ts}") |
| 1554 | print() |
| 1555 | calibration = calibrator.status() |
| 1556 | print( |
| 1557 | " Route confidence calibration: " |
| 1558 | f"{'active' if calibration['active'] else 'inactive'}" |
| 1559 | ) |
| 1560 | print(f" Labels: {calibration['labeled_examples']}") |
| 1561 | if calibration.get("training_examples"): |
| 1562 | print( |
| 1563 | " Split: " |
| 1564 | f"{calibration['training_examples']} train / {calibration['holdout_examples']} holdout" |
| 1565 | ) |
| 1566 | if calibration.get("selected_strategy"): |
| 1567 | print(f" Strategy: {calibration['selected_strategy']}") |
| 1568 | print(f" Temperature: {calibration['temperature']:.2f}") |
| 1569 | if calibration["version"]: |
| 1570 | print(f" Version: {calibration['version']}") |
| 1571 | print( |
| 1572 | " ECE: " |
| 1573 | f"{calibration['raw_ece']:.3f} -> {calibration['calibrated_ece']:.3f}" |
| 1574 | ) |
| 1575 | if calibration.get("holdout_examples"): |
| 1576 | print( |
| 1577 | " Holdout ECE: " |
| 1578 | f"{calibration['holdout_raw_ece']:.3f} -> {calibration['holdout_calibrated_ece']:.3f}" |
| 1579 | ) |
| 1580 | if calibration.get("stale"): |
| 1581 | print(" Snapshot: stale (waiting for fresher labeled traces)") |
| 1582 | print() |
| 1583 | print(" How feedback works:") |
| 1584 | print(" 1. Run `uncommon-route route <prompt>` and rate the tier") |
| 1585 | print(" 2. Your feedback updates a local model overlay (~/.uncommon-route/model_online.json)") |
nothing calls this directly
no test coverage detected