File size: 521 Bytes
2fd2129
 
b713a11
b6d77d3
772c22e
b713a11
 
98b93b7
b713a11
2fd2129
772c22e
 
 
2fd2129
b6d77d3
 
2fd2129
b6d77d3
772c22e
2fd2129
772c22e
 
2fd2129
 
 
 
 
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
# 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


@app.get("/", response_class=HTMLResponse)
def index():
    with open("frontend/index.html", "r", encoding="utf-8") as f:
        return f.read()


@app.post("/chat")
def chat(q: Query):
    answer, status = ask_rag_with_status(q.question)
    return {
        "answer": answer,
        "status": status,
    }