Download app/main.py from nvikou/corrective-rag-data-assistant: direct link, hf CLI and curl.
- Browser
- Download file 1.51 kB
-
https://huggingface.co/spaces/nvikou/corrective-rag-data-assistant/resolve/main/app/main.py
- Command line
-
hf download hf://spaces/nvikou/corrective-rag-data-assistant/app/main.py
-
curl -L -o main.py https://huggingface.co/spaces/nvikou/corrective-rag-data-assistant/resolve/main/app/main.py
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") | |
| 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." | |
| ) | |
| def serve_ui() -> FileResponse: | |
| return FileResponse("static/index.html") | |