nvikou's picture
Upgrade CRAG: embeddings, SQL SQLite, pro UI, 60-eval, local data
98aa813 verified
Raw History Blame Contribute Delete
1.51 kB
from __future__ import annotations
import logging
from fastapi import FastAPI
from fastapi.responses import FileResponse
from fastapi.staticfiles import StaticFiles
from app.api.routes import router as api_router
from app.core.config import get_settings
from app.sql.seed import ensure_company_db
settings = get_settings()
logging.basicConfig(level=settings.log_level)
logger = logging.getLogger(__name__)
app = FastAPI(
title="Corrective RAG Data Assistant",
description=(
"Assistant d'analyse documentaire avec pipeline Corrective RAG "
"(évaluation de pertinence, filtrage, réécriture de requête, "
"SQL sécurisé, vérification de la réponse)."
),
version="1.1.0",
)
app.include_router(api_router, prefix="/api")
app.mount("/static", StaticFiles(directory="static"), name="static")
@app.on_event("startup")
def on_startup() -> None:
ensure_company_db()
if settings.app_api_key == "change-me-please":
logger.warning(
"APP_API_KEY non configurée (valeur par défaut) : l'API /api/chat "
"est accessible sans clé. Définissez APP_API_KEY avant un "
"déploiement partagé."
)
if settings.llm_provider == "mock":
logger.warning(
"LLM_PROVIDER=mock : les réponses ne sont PAS générées par "
"DeepSeek-V4.1-Flash. Configurez HF_TOKEN puis LLM_PROVIDER=hf."
)
@app.get("/")
def serve_ui() -> FileResponse:
return FileResponse("static/index.html")