Spaces:
Sleeping
Sleeping
Download apps/api/app/main.py from quantumsquatan/Adala-ai: direct link, hf CLI and curl.
- Browser
- Download file 1.06 kB
-
https://huggingface.co/spaces/quantumsquatan/Adala-ai/resolve/main/apps/api/app/main.py
- Command line
-
hf download hf://spaces/quantumsquatan/Adala-ai/apps/api/app/main.py
-
curl -L -o main.py https://huggingface.co/spaces/quantumsquatan/Adala-ai/resolve/main/apps/api/app/main.py
1.06 kB
| from contextlib import asynccontextmanager | |
| from fastapi import FastAPI | |
| from fastapi.middleware.cors import CORSMiddleware | |
| from app import db | |
| from app.api import chat, documents, model | |
| from app.config import settings | |
| from app.models import HealthOut | |
| from app.seed import seed_documents | |
| async def lifespan(_: FastAPI): | |
| db.init_db() | |
| seed_documents() | |
| yield | |
| app = FastAPI( | |
| title=settings.app_name, | |
| version="1.0.0", | |
| description="RAG API for grounded Egyptian legal research over uploaded PDFs.", | |
| lifespan=lifespan, | |
| ) | |
| app.add_middleware( | |
| CORSMiddleware, | |
| allow_origins=settings.cors_origins, | |
| allow_credentials=True, | |
| allow_methods=["*"], | |
| allow_headers=["*"], | |
| ) | |
| app.include_router(documents.router) | |
| app.include_router(chat.router) | |
| app.include_router(model.router) | |
| def health() -> HealthOut: | |
| return HealthOut(status="ok", app=settings.app_name, environment=settings.app_env) | |