22from contextlib import AbstractAsyncContextManager , asynccontextmanager
33from typing import AsyncIterator , Callable , Optional
44
5+ from fastapi import FastAPI
56from httpx import ASGITransport , AsyncClient , Timeout
67from loguru import logger
78
@@ -34,12 +35,12 @@ def _build_timeout() -> Timeout:
3435 )
3536
3637
37- def _build_asgi_client (fastapi_app , timeout : Timeout ) -> AsyncClient :
38+ def _build_asgi_client (app : FastAPI , timeout : Timeout ) -> AsyncClient :
3839 """Create a local ASGI client for an already-prepared FastAPI app."""
3940 from basic_memory .workspace_context import workspace_permalink_headers
4041
4142 return AsyncClient (
42- transport = ASGITransport (app = fastapi_app ),
43+ transport = ASGITransport (app = app ),
4344 base_url = "http://test" ,
4445 timeout = timeout ,
4546 # Local ASGI calls still cross the HTTP boundary, so request handlers need
@@ -48,14 +49,14 @@ def _build_asgi_client(fastapi_app, timeout: Timeout) -> AsyncClient:
4849 )
4950
5051
51- async def _prepare_local_asgi_database (fastapi_app ) -> None :
52+ async def _prepare_local_asgi_database (app : FastAPI ) -> None :
5253 """Initialize local ASGI database state before the first request."""
5354 from basic_memory import db
5455
5556 config = ConfigManager ().config
5657 engine , session_maker = await db .get_or_create_db (config .database_path )
57- fastapi_app .state .engine = engine
58- fastapi_app .state .session_maker = session_maker
58+ app .state .engine = engine
59+ app .state .session_maker = session_maker
5960
6061
6162@asynccontextmanager
0 commit comments