()
| 2931 | return False, {"error": "Failed to reload primary connection", "detail": str(exc)} |
| 2932 | |
| 2933 | async def _on_startup() -> None: |
| 2934 | # ─── v2 lifecycle startup ─── |
| 2935 | try: |
| 2936 | from uncommon_route.v2_lifecycle import on_startup as v2_startup |
| 2937 | v2_startup() |
| 2938 | except Exception as e: |
| 2939 | logger.warning("v2 lifecycle startup failed: %s", e) |
| 2940 | |
| 2941 | if not upstream: |
| 2942 | return |
| 2943 | count = await _mapper.discover(_primary_api_key or None) |
| 2944 | if count > 0: |
| 2945 | gw_tag = " (gateway)" if _mapper.is_gateway else "" |
| 2946 | print(f"[UncommonRoute] Discovered {count} models from {_mapper.provider}{gw_tag}") |
| 2947 | print(f"[UncommonRoute] Model pool: {count} models with live pricing + inferred capabilities") |
| 2948 | _refresh_active_pricing() |
| 2949 | unresolved = _mapper.unresolved_models() |
| 2950 | if unresolved: |
| 2951 | names = ", ".join(unresolved[:5]) |
| 2952 | extra = f" (+{len(unresolved) - 5} more)" if len(unresolved) > 5 else "" |
| 2953 | print(f"[UncommonRoute] Note: {len(unresolved)} legacy model(s) not matched upstream: {names}{extra}") |
| 2954 | elif _mapper.provider != "unknown": |
| 2955 | print(f"[UncommonRoute] Warning: could not discover models from {_mapper.provider} — using static config") |
| 2956 | |
| 2957 | try: |
| 2958 | from uncommon_route.benchmark import get_benchmark_cache |
| 2959 | bm_cache = get_benchmark_cache() |
| 2960 | bm_count = await bm_cache.refresh() |
| 2961 | if bm_count > 0: |
| 2962 | print(f"[UncommonRoute] Benchmark quality: {bm_count} models from {bm_cache.source_summary()}") |
| 2963 | else: |
| 2964 | seed_count = bm_cache.model_count() |
| 2965 | if seed_count > 0: |
| 2966 | print(f"[UncommonRoute] Benchmark quality: {seed_count} models from seed data (API fetch pending)") |
| 2967 | except Exception as exc: |
| 2968 | logger.warning("Benchmark quality fetch failed: %s", exc) |
| 2969 | |
| 2970 | _rediscovery_task = None |
| 2971 | _benchmark_refresh_task = None |
no test coverage detected