Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
|
@@ -13,7 +13,7 @@ load_dotenv()
|
|
| 13 |
app = FastAPI()
|
| 14 |
|
| 15 |
|
| 16 |
-
@app.post("/upload
|
| 17 |
async def upload_pdfs(background_tasks: BackgroundTasks, files: list[UploadFile] = File(...)):
|
| 18 |
session_id = str(uuid4())
|
| 19 |
raw_text = await extract_text_from_pdfs(files)
|
|
@@ -35,7 +35,7 @@ async def upload_pdfs(background_tasks: BackgroundTasks, files: list[UploadFile]
|
|
| 35 |
}
|
| 36 |
|
| 37 |
|
| 38 |
-
@app.post("/query
|
| 39 |
async def query_pdf(session_id: str = Form(...), question: str = Form(...)):
|
| 40 |
try:
|
| 41 |
response = query_vector_store(session_id, question)
|
|
@@ -46,7 +46,7 @@ async def query_pdf(session_id: str = Form(...), question: str = Form(...)):
|
|
| 46 |
raise HTTPException(status_code=500, detail=str(e))
|
| 47 |
|
| 48 |
|
| 49 |
-
@app.post("/clear
|
| 50 |
async def clear_session(session_id: str = Form(...)):
|
| 51 |
try:
|
| 52 |
delete_vector_store(session_id)
|
|
|
|
| 13 |
app = FastAPI()
|
| 14 |
|
| 15 |
|
| 16 |
+
@app.post("/upload")
|
| 17 |
async def upload_pdfs(background_tasks: BackgroundTasks, files: list[UploadFile] = File(...)):
|
| 18 |
session_id = str(uuid4())
|
| 19 |
raw_text = await extract_text_from_pdfs(files)
|
|
|
|
| 35 |
}
|
| 36 |
|
| 37 |
|
| 38 |
+
@app.post("/query")
|
| 39 |
async def query_pdf(session_id: str = Form(...), question: str = Form(...)):
|
| 40 |
try:
|
| 41 |
response = query_vector_store(session_id, question)
|
|
|
|
| 46 |
raise HTTPException(status_code=500, detail=str(e))
|
| 47 |
|
| 48 |
|
| 49 |
+
@app.post("/clear")
|
| 50 |
async def clear_session(session_id: str = Form(...)):
|
| 51 |
try:
|
| 52 |
delete_vector_store(session_id)
|