Update app.py
Browse files
app.py
CHANGED
|
@@ -25,14 +25,20 @@ def chat():
|
|
| 25 |
print("β οΈ Empty input received!")
|
| 26 |
return jsonify({"error": "Empty input"}), 400
|
| 27 |
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
if __name__ == "__main__":
|
| 38 |
print("π Starting Flask app on port 7860")
|
|
|
|
| 25 |
print("β οΈ Empty input received!")
|
| 26 |
return jsonify({"error": "Empty input"}), 400
|
| 27 |
|
| 28 |
+
try:
|
| 29 |
+
response = llm.create_chat_completion(
|
| 30 |
+
messages=[{"role": "user", "content": user_input}]
|
| 31 |
+
)
|
| 32 |
+
|
| 33 |
+
print(f"π Full response object: {response}") # Debugging
|
| 34 |
+
bot_reply = response["choices"][0]["message"]["content"]
|
| 35 |
+
print(f"π€ Bot response: {bot_reply}")
|
| 36 |
+
|
| 37 |
+
return jsonify({"response": bot_reply})
|
| 38 |
+
|
| 39 |
+
except Exception as e:
|
| 40 |
+
print(f"β Error generating response: {e}")
|
| 41 |
+
return jsonify({"error": "Model failed to generate response"}), 500
|
| 42 |
|
| 43 |
if __name__ == "__main__":
|
| 44 |
print("π Starting Flask app on port 7860")
|