| # app.py | |
| from fastapi import FastAPI | |
| from fastapi.responses import HTMLResponse | |
| from pydantic import BaseModel | |
| from rag import ask_rag_with_status | |
| app = FastAPI() | |
| class Query(BaseModel): | |
| question: str | |
| def index(): | |
| with open("frontend/index.html", "r", encoding="utf-8") as f: | |
| return f.read() | |
| def chat(q: Query): | |
| answer, status = ask_rag_with_status(q.question) | |
| return { | |
| "answer": answer, | |
| "status": status, | |
| } |