Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -117,15 +117,15 @@ async def ask(request: Request):
|
|
117 |
else:
|
118 |
print("⚠️ No token usage info returned from API")
|
119 |
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
|
130 |
return {"status": "ok"}
|
131 |
|
|
|
117 |
else:
|
118 |
print("⚠️ No token usage info returned from API")
|
119 |
|
120 |
+
except Exception as e:
|
121 |
+
print("❌ OpenAI Error:", e)
|
122 |
+
answer = "Sorry, I'm having trouble answering right now."
|
123 |
+
|
124 |
+
if answer == "I'm not sure about that. Let me connect you with a human agent.":
|
125 |
+
stop_reply_conversations.add(conversation_id)
|
126 |
+
print(f"🚫 Fallback answer, disabling AI for conversation {conversation_id}")
|
127 |
+
|
128 |
+
await send_chatwoot_message(conversation_id, answer)
|
129 |
|
130 |
return {"status": "ok"}
|
131 |
|