Update app.py
Browse files
app.py
CHANGED
|
@@ -25,22 +25,3 @@ if st.button("Ask") and query:
|
|
| 25 |
answer = ask_question(query)
|
| 26 |
st.write("**Answer:**", answer)
|
| 27 |
|
| 28 |
-
# api.py
|
| 29 |
-
from fastapi import FastAPI, UploadFile, File, Form
|
| 30 |
-
from model import load_vectorstore, ask_question
|
| 31 |
-
import shutil
|
| 32 |
-
|
| 33 |
-
app = FastAPI()
|
| 34 |
-
|
| 35 |
-
@app.post("/upload")
|
| 36 |
-
async def upload(file: UploadFile = File(...)):
|
| 37 |
-
with open("document.pdf", "wb") as buffer:
|
| 38 |
-
shutil.copyfileobj(file.file, buffer)
|
| 39 |
-
load_vectorstore("document.pdf")
|
| 40 |
-
return {"message": "File indexed successfully."}
|
| 41 |
-
|
| 42 |
-
@app.post("/ask")
|
| 43 |
-
async def ask(question: str = Form(...)):
|
| 44 |
-
answer = ask_question(question)
|
| 45 |
-
return {"question": question, "answer": answer}
|
| 46 |
-
|
|
|
|
| 25 |
answer = ask_question(query)
|
| 26 |
st.write("**Answer:**", answer)
|
| 27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|