MCPcopy Create free account
hub / github.com/CommonstackAI/UncommonRoute / _cmd_stats

Function _cmd_stats

uncommon_route/cli.py:1397–1525  ·  view source on GitHub ↗
(args: list[str])

Source from the content-addressed store, hash-verified

1395
1396
1397def _cmd_stats(args: list[str]) -> None:
1398 from uncommon_route.stats import RouteStats
1399
1400 rs = RouteStats()
1401 if not args:
1402 args = ["summary"]
1403 sub = args[0]
1404
1405 if sub == "summary":
1406 s = rs.summary()
1407 if s.total_requests == 0:
1408 print(" No routing data recorded yet.")
1409 print(" Start the proxy with `uncommon-route serve` and send requests.")
1410 return
1411 hours = s.time_range_s / 3600
1412 print(f"\n Routing Statistics ({hours:.1f}h window, {s.total_requests} requests)")
1413 print(f" {'─' * 50}")
1414 print(f" Avg confidence: {s.avg_confidence:.2f}")
1415 print(f" Avg savings: {s.avg_savings:.0%}")
1416 print(f" Avg latency: {s.avg_latency_us / 1000.0:.3f}ms")
1417 print(f" Avg reduction: {s.avg_input_reduction_ratio:.0%}")
1418 print(f" Avg cache hit: {s.avg_cache_hit_ratio:.0%}")
1419 print(f" Total cost: ${s.total_actual_cost:.4f} (estimated: ${s.total_estimated_cost:.4f})")
1420 print(
1421 f" Input tokens: {s.total_input_tokens_before} -> {s.total_input_tokens_after}"
1422 f" | artifacts: {s.total_artifacts_created}"
1423 f" | compacted: {s.total_compacted_messages}"
1424 )
1425 print(
1426 f" Upstream usage: in {s.total_usage_input_tokens}"
1427 f" | out {s.total_usage_output_tokens}"
1428 f" | cache-read {s.total_cache_read_input_tokens}"
1429 f" | cache-write {s.total_cache_write_input_tokens}"
1430 f" | breakpoints {s.total_cache_breakpoints}"
1431 )
1432 print(
1433 f" Semantic: calls {s.total_semantic_calls}"
1434 f" | summaries {s.total_semantic_summaries}"
1435 f" | checkpoints {s.total_checkpoints_created}"
1436 f" | rehydrated {s.total_rehydrated_artifacts}"
1437 f" | failures {s.total_semantic_failures}"
1438 f" | quality-fallbacks {s.total_semantic_quality_fallbacks}"
1439 )
1440
1441 if s.by_tier:
1442 print("\n By Tier:")
1443 for tier in ("SIMPLE", "MEDIUM", "COMPLEX"):
1444 ts = s.by_tier.get(tier)
1445 if not ts:
1446 continue
1447 pct = ts.count / s.total_requests * 100
1448 print(
1449 f" {tier:<10} │ {ts.count:>5} ({pct:4.1f}%)"
1450 f" │ conf: {ts.avg_confidence:.2f}"
1451 f" │ savings: {ts.avg_savings:.0%}"
1452 f" │ ${ts.total_cost:.4f}"
1453 )
1454

Callers

nothing calls this directly

Calls 6

summaryMethod · 0.95
historyMethod · 0.95
resetMethod · 0.95
RouteStatsClass · 0.90
_parse_flagsFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected