Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -140,14 +140,32 @@ def call_payer_api(payload):
|
|
| 140 |
PAYER_URL = "https://pilayar-payer-auth-sim.hf.space/agent-chat"
|
| 141 |
|
| 142 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 143 |
|
| 144 |
-
response = requests.post(PAYER_URL, json=payload, timeout=15)
|
| 145 |
|
| 146 |
-
return response.json()
|
| 147 |
|
| 148 |
-
except:
|
| 149 |
|
| 150 |
-
return {"agent_response": "Payer Agent is currently unavailable."}
|
| 151 |
|
| 152 |
def render_summary(inner_monologue, last_payer_msg):
|
| 153 |
st.subheader("🏁 Negotiation Outcome")
|
|
|
|
| 140 |
PAYER_URL = "https://pilayar-payer-auth-sim.hf.space/agent-chat"
|
| 141 |
|
| 142 |
try:
|
| 143 |
+
# 1. Increased timeout to 45 seconds to allow for potential Hugging Face spin-up
|
| 144 |
+
response = requests.post(PAYER_URL, json=payload, timeout=45)
|
| 145 |
+
|
| 146 |
+
# 2. Raises an HTTPError if the HTTP request returned an unsuccessful status code
|
| 147 |
+
response.raise_for_status()
|
| 148 |
+
|
| 149 |
+
return response.json()
|
| 150 |
+
|
| 151 |
+
except requests.exceptions.Timeout as e:
|
| 152 |
+
print(f"Timeout Error: {e}")
|
| 153 |
+
return {"agent_response": "Payer Agent request timed out."}
|
| 154 |
+
|
| 155 |
+
except requests.exceptions.RequestException as e:
|
| 156 |
+
# This will catch connection errors, HTTP errors, etc., and print the exact cause
|
| 157 |
+
print(f"Request failed: {e}")
|
| 158 |
+
return {"agent_response": "Payer Agent is currently unavailable."}
|
| 159 |
+
|
| 160 |
+
# try:
|
| 161 |
|
| 162 |
+
# response = requests.post(PAYER_URL, json=payload, timeout=15)
|
| 163 |
|
| 164 |
+
# return response.json()
|
| 165 |
|
| 166 |
+
# except:
|
| 167 |
|
| 168 |
+
# return {"agent_response": "Payer Agent is currently unavailable."}
|
| 169 |
|
| 170 |
def render_summary(inner_monologue, last_payer_msg):
|
| 171 |
st.subheader("🏁 Negotiation Outcome")
|