File size: 415 Bytes
1beff3e
 
 
643a4d6
 
d1bbc1c
643a4d6
 
 
 
 
6f57f13
 
 
 
643a4d6
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# backend.py (in root of Space repo)

from fastapi import FastAPI
from pydantic import BaseModel
from qabot import llm_chain
#cheese
app = FastAPI()

class Query(BaseModel):
    query: str

@app.get("/")
def root():
    return {"message": "FastAPI backend is running!"}

@app.post("/ask")
def ask_question(query: Query):
    result = llm_chain.invoke({"query": query.query})
    return {"answer": result["result"]}