Spaces:
Paused
Paused
Download app/main.py from MuhammadSaad16/chat: direct link, hf CLI and curl.
- Browser
- Download file 880 Bytes
-
https://huggingface.co/spaces/MuhammadSaad16/chat/resolve/main/app/main.py
- Command line
-
hf download hf://spaces/MuhammadSaad16/chat/app/main.py
-
curl -L -o main.py https://huggingface.co/spaces/MuhammadSaad16/chat/resolve/main/app/main.py
880 Bytes
| from dotenv import load_dotenv | |
| # Load environment variables FIRST | |
| load_dotenv() | |
| from fastapi import FastAPI | |
| from fastapi.middleware.cors import CORSMiddleware | |
| from app.routes import chat, translate, personalize | |
| from app.database import engine, Base | |
| from app.qdrant_client import init_qdrant_collection | |
| app = FastAPI(title="RAG Chatbot API") | |
| # CORS Configuration | |
| app.add_middleware( | |
| CORSMiddleware, | |
| allow_origins=["http://localhost:3000", "http://127.0.0.1:3000","http://localhost:3001", "http://127.0.0.1:3001"], | |
| allow_credentials=True, | |
| allow_methods=["*"], | |
| allow_headers=["*"], | |
| ) | |
| # Include routers | |
| app.include_router(chat.router) | |
| app.include_router(translate.router) | |
| app.include_router(personalize.router) | |
| async def root(): | |
| return {"message": "RAG Chatbot API"} | |
| async def health(): | |
| return {"status": "ok"} |