|
38 | 38 | ) |
39 | 39 | from .lane_registry import get_provider_lane_binding, get_route_add_recommendations |
40 | 40 | from .metrics import MetricsStore, calc_cost |
| 41 | +from .provider_availability import ( |
| 42 | + record_availability_from_config, |
| 43 | + refresh_local_model_availability, |
| 44 | +) |
41 | 45 | from .provider_catalog import ( |
42 | 46 | build_provider_catalog_report, |
43 | 47 | build_provider_discovery_view, |
|
74 | 78 | _provider_catalog_refresh_task: asyncio.Task[None] | None = None |
75 | 79 |
|
76 | 80 |
|
| 81 | +def _provider_catalog_config_path() -> str: |
| 82 | + return str(os.environ.get("FAIGATE_CONFIG_FILE") or "config.yaml") |
| 83 | + |
| 84 | + |
77 | 85 | class PayloadTooLargeError(ValueError): |
78 | 86 | """Raised when one request or upload exceeds configured size limits.""" |
79 | 87 |
|
@@ -204,6 +212,21 @@ async def _refresh_provider_source_catalog(*, force: bool = False) -> list[dict[ |
204 | 212 | provider_ids=target_ids, |
205 | 213 | timeout_seconds=float(source_refresh_cfg.get("timeout_seconds") or 10.0), |
206 | 214 | ) |
| 215 | + await asyncio.to_thread( |
| 216 | + record_availability_from_config, |
| 217 | + _provider_catalog_store, |
| 218 | + config_path=_provider_catalog_config_path(), |
| 219 | + health_payload={ |
| 220 | + "providers": {item["name"]: item for item in _build_provider_inventory()} |
| 221 | + }, |
| 222 | + ) |
| 223 | + await asyncio.to_thread( |
| 224 | + refresh_local_model_availability, |
| 225 | + _provider_catalog_store, |
| 226 | + config_path=_provider_catalog_config_path(), |
| 227 | + provider_ids=target_ids, |
| 228 | + timeout_seconds=float(source_refresh_cfg.get("timeout_seconds") or 10.0), |
| 229 | + ) |
207 | 230 | ok_count = sum(1 for item in refresh_results if item.ok) |
208 | 231 | logger.info( |
209 | 232 | "Provider source refresh completed: %s/%s source endpoints succeeded (%s)", |
@@ -1908,6 +1931,14 @@ async def provider_catalog(): |
1908 | 1931 | "priority_next": {}, |
1909 | 1932 | } |
1910 | 1933 | if _provider_catalog_store is not None: |
| 1934 | + await asyncio.to_thread( |
| 1935 | + record_availability_from_config, |
| 1936 | + _provider_catalog_store, |
| 1937 | + config_path=_provider_catalog_config_path(), |
| 1938 | + health_payload={ |
| 1939 | + "providers": {item["name"]: item for item in _build_provider_inventory()} |
| 1940 | + }, |
| 1941 | + ) |
1911 | 1942 | source_catalog = build_catalog_summary( |
1912 | 1943 | _provider_catalog_store, |
1913 | 1944 | provider_ids=list(_config.provider_source_refresh.get("providers") or []), |
|
0 commit comments