Spaces:
No application file
No application file
File size: 864 Bytes
a0c847a | 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 | from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from app.routes import chat
from app.database import engine, Base
from app.qdrant_client import init_qdrant_collection
app = FastAPI(title="RAG Chatbot API")
# CORS Configuration - Allow frontend to connect
app.add_middleware(
CORSMiddleware,
allow_origins=["http://localhost:3000", "http://127.0.0.1:3000"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# Include routers
app.include_router(chat.router)
@app.on_event("startup")
async def startup_event():
# Create database tables
Base.metadata.create_all(bind=engine)
# Initialize Qdrant collection
init_qdrant_collection()
@app.get("/")
async def root():
return {"message": "RAG Chatbot API"}
@app.get("/api/health")
async def health():
return {"status": "ok"} |