Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -22,15 +22,12 @@ def upload_pdf(file):
|
|
| 22 |
})
|
| 23 |
if response.status_code != 200:
|
| 24 |
return "❌ Failed to get presigned URL"
|
| 25 |
-
|
| 26 |
data = response.json()
|
| 27 |
presigned_url = data["url"]
|
| 28 |
content_type = data.get("content_type", "application/pdf")
|
| 29 |
|
| 30 |
-
# Step 2: Upload to S3
|
| 31 |
with open(file.name, "rb") as f:
|
| 32 |
upload_resp = requests.put(presigned_url, data=f, headers={"Content-Type": content_type})
|
| 33 |
-
|
| 34 |
if upload_resp.status_code == 200:
|
| 35 |
upload_success = True
|
| 36 |
return f"✅ Uploaded and indexing triggered! You can now ask questions."
|
|
@@ -50,12 +47,9 @@ def chat_with_doc(message, history):
|
|
| 50 |
"session_id": session_id,
|
| 51 |
"chat_history": history
|
| 52 |
}
|
| 53 |
-
|
| 54 |
-
resp = requests.post(INFERENCE_API_URL, json=payload)
|
| 55 |
-
|
| 56 |
if resp.status_code != 200:
|
| 57 |
return "❌ Error calling LLM. Try again later.", history
|
| 58 |
-
|
| 59 |
answer = resp.json()["answer"]
|
| 60 |
history.append((message, answer))
|
| 61 |
return "", history
|
|
|
|
| 22 |
})
|
| 23 |
if response.status_code != 200:
|
| 24 |
return "❌ Failed to get presigned URL"
|
|
|
|
| 25 |
data = response.json()
|
| 26 |
presigned_url = data["url"]
|
| 27 |
content_type = data.get("content_type", "application/pdf")
|
| 28 |
|
|
|
|
| 29 |
with open(file.name, "rb") as f:
|
| 30 |
upload_resp = requests.put(presigned_url, data=f, headers={"Content-Type": content_type})
|
|
|
|
| 31 |
if upload_resp.status_code == 200:
|
| 32 |
upload_success = True
|
| 33 |
return f"✅ Uploaded and indexing triggered! You can now ask questions."
|
|
|
|
| 47 |
"session_id": session_id,
|
| 48 |
"chat_history": history
|
| 49 |
}
|
| 50 |
+
resp = requests.post(INFERENCE_API_URL, json=payload)
|
|
|
|
|
|
|
| 51 |
if resp.status_code != 200:
|
| 52 |
return "❌ Error calling LLM. Try again later.", history
|
|
|
|
| 53 |
answer = resp.json()["answer"]
|
| 54 |
history.append((message, answer))
|
| 55 |
return "", history
|