Spaces:
Sleeping
Sleeping
Commit
·
89dc8b2
1
Parent(s):
6017dce
deepnote update
Browse files
app.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI
|
| 2 |
+
from pydantic import BaseModel
|
| 3 |
+
import faq as faq
|
| 4 |
+
import uvicorn
|
| 5 |
+
|
| 6 |
+
app = FastAPI()
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class Request(BaseModel):
|
| 10 |
+
question: str
|
| 11 |
+
sheet_url: str
|
| 12 |
+
page_content_column: str
|
| 13 |
+
k: int
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
@app.post("/api/v1/ask")
|
| 17 |
+
async def ask(request: Request):
|
| 18 |
+
vectordb = faq.load_vectordb(request.sheet_url, request.page_content_column)
|
| 19 |
+
result = faq.similarity_search(vectordb, request.question, k=request.k)
|
| 20 |
+
return result
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
if __name__ == "__main__":
|
| 24 |
+
uvicorn.run(app, host="0.0.0.0", port=7860)
|