34 lines
1.0 KiB
Python
34 lines
1.0 KiB
Python
from fastapi import FastAPI
|
|
from contextlib import asynccontextmanager
|
|
from app.api.routes.health import router as health_router
|
|
from app.api.routes.workflow import router as workflow_router
|
|
from app.core.config import settings
|
|
from app.core.logging import setup_logging
|
|
from app.repositories.qdrant_repository import QdrantRepository
|
|
|
|
setup_logging()
|
|
|
|
@asynccontextmanager
|
|
async def lifespan(app: FastAPI):
|
|
print("[Startup] Initialisation automatique de Qdrant dans Docker...")
|
|
qdrant_repo = QdrantRepository()
|
|
try:
|
|
await qdrant_repo.init_collection(vector_size=1024)
|
|
except Exception as e:
|
|
print(f"[Startup] Erreur lors de l'initialisation de Qdrant : {e}")
|
|
yield
|
|
|
|
print("[Shutdown] Fermeture propre de la connexion Qdrant...")
|
|
await qdrant_repo.close()
|
|
|
|
|
|
app = FastAPI(
|
|
title=settings.app_name,
|
|
docs_url=None,
|
|
redoc_url=None,
|
|
openapi_url=None,
|
|
lifespan=lifespan
|
|
)
|
|
|
|
app.include_router(health_router, prefix="/api")
|
|
app.include_router(workflow_router, prefix="/api") |