This commit is contained in:
Timothy Jaeryang Baek committed 2026-02-16 13:10:01 -06:00
1 parent 8adf2b33b4
commit 337109e99c
1 file changed
+22 -19
+22 -19
View File
@@ -639,25 +639,28 @@ async def lifespan(app: FastAPI):
asyncio.create_task(periodic_session_pool_cleanup()) asyncio.create_task(periodic_session_pool_cleanup())
if app.state.config.ENABLE_BASE_MODELS_CACHE: if app.state.config.ENABLE_BASE_MODELS_CACHE:
await get_all_models( try:
Request( await get_all_models(
# Creating a mock request object to pass to get_all_models Request(
{ # Creating a mock request object to pass to get_all_models
"type": "http", {
"asgi.version": "3.0", "type": "http",
"asgi.spec_version": "2.0", "asgi.version": "3.0",
"method": "GET", "asgi.spec_version": "2.0",
"path": "/internal", "method": "GET",
"query_string": b"", "path": "/internal",
"headers": Headers({}).raw, "query_string": b"",
"client": ("127.0.0.1", 12345), "headers": Headers({}).raw,
"server": ("127.0.0.1", 80), "client": ("127.0.0.1", 12345),
"scheme": "http", "server": ("127.0.0.1", 80),
"app": app, "scheme": "http",
} "app": app,
), }
None, ),
) None,
)
except Exception as e:
log.warning(f"Failed to pre-fetch models at startup: {e}")
# Pre-fetch tool server specs so the first request doesn't pay the latency cost # Pre-fetch tool server specs so the first request doesn't pay the latency cost
if len(app.state.config.TOOL_SERVER_CONNECTIONS) > 0: if len(app.state.config.TOOL_SERVER_CONNECTIONS) > 0: