Spaces:
Sleeping
Sleeping
File size: 1,056 Bytes
ee9de9c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | 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
@asynccontextmanager
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)
@app.get("/api/health", response_model=HealthOut, tags=["health"])
def health() -> HealthOut:
return HealthOut(status="ok", app=settings.app_name, environment=settings.app_env)
|