22 lines
582 B
Python
22 lines
582 B
Python
from contextlib import asynccontextmanager
|
|
|
|
from fastapi import FastAPI
|
|
|
|
from src.api.external import router as ws_router
|
|
from src.agent import AgentService
|
|
from src.agent.checkpointer import create_checkpointer
|
|
|
|
from src.core.logger import get_logger
|
|
|
|
logger = get_logger(__name__)
|
|
|
|
@asynccontextmanager
|
|
async def lifespan(app: FastAPI):
|
|
async with create_checkpointer():
|
|
AgentService() # инициализируем синглтон
|
|
yield
|
|
|
|
|
|
app = FastAPI(lifespan=lifespan)
|
|
logger.info("FastAPI инициализирован")
|
|
app.include_router(ws_router)
|