Spaces:
Runtime error
Runtime error
| # File : app/main.py | |
| # Purpose : FastAPI application entry point for Banking RAG Platform | |
| import os | |
| from contextlib import asynccontextmanager | |
| from fastapi import FastAPI | |
| from fastapi.middleware.cors import CORSMiddleware | |
| from app.config import get_settings | |
| settings = get_settings() | |
| os.environ["LANGCHAIN_TRACING_V2"] = settings.langchain_tracing_v2 | |
| os.environ["LANGCHAIN_ENDPOINT"] = settings.langchain_endpoint | |
| os.environ["LANGCHAIN_API_KEY"] = settings.langchain_api_key | |
| os.environ["LANGCHAIN_PROJECT"] = settings.langchain_project | |
| async def lifespan(app: FastAPI): | |
| print("[STARTUP] Banking RAG Platform starting...") | |
| from app.database.connection import init_db | |
| await init_db() | |
| print("[STARTUP] Database ready") | |
| yield | |
| print("[SHUTDOWN] Banking RAG Platform shutting down...") | |
| app = FastAPI( | |
| title="Banking RAG Platform", | |
| description="Enterprise RAG system for RBI and Finance documents", | |
| version="1.0.0", | |
| lifespan=lifespan, | |
| ) | |
| app.add_middleware( | |
| CORSMiddleware, | |
| allow_origins=["*"], | |
| allow_credentials=True, | |
| allow_methods=["*"], | |
| allow_headers=["*"], | |
| ) | |
| # Register routers | |
| from app.auth.router import router as auth_router | |
| from app.documents.router import router as documents_router | |
| from app.rag.router import router as rag_router | |
| app.include_router(auth_router) | |
| app.include_router(documents_router) | |
| app.include_router(rag_router) | |
| async def root(): | |
| return { | |
| "status": "ok", | |
| "app": "Banking RAG Platform", | |
| "version": "1.0.0", | |
| "env": settings.app_env, | |
| } | |
| async def health(): | |
| return {"status": "healthy"} |