Update app.py
Browse files
app.py
CHANGED
|
@@ -767,10 +767,15 @@ def chat():
|
|
| 767 |
except Exception:
|
| 768 |
return Response("Cohere non-json response", mimetype="text/plain", status=500)
|
| 769 |
|
| 770 |
-
ai_text =
|
| 771 |
-
|
| 772 |
-
|
| 773 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 774 |
|
| 775 |
return Response(ai_text, mimetype="text/plain")
|
| 776 |
# =====================================================
|
|
|
|
| 767 |
except Exception:
|
| 768 |
return Response("Cohere non-json response", mimetype="text/plain", status=500)
|
| 769 |
|
| 770 |
+
ai_text = ""
|
| 771 |
+
if (
|
| 772 |
+
isinstance(res_json, dict)
|
| 773 |
+
and "message" in res_json
|
| 774 |
+
and "content" in res_json["message"]
|
| 775 |
+
and isinstance(res_json["message"]["content"], list)
|
| 776 |
+
and len(res_json["message"]["content"]) > 0
|
| 777 |
+
):
|
| 778 |
+
ai_text = res_json["message"]["content"][0].get("text", "")
|
| 779 |
|
| 780 |
return Response(ai_text, mimetype="text/plain")
|
| 781 |
# =====================================================
|