Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -54,17 +54,16 @@ def load_user_data():
|
|
| 54 |
def save_user_data(data):
|
| 55 |
with open(USER_DATA_FILE, "w") as f:
|
| 56 |
json.dump(data, f)
|
| 57 |
-
|
| 58 |
-
|
| 59 |
@app.route("/chat", methods=["POST"])
|
| 60 |
-
def
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
|
|
|
| 68 |
# Emotion detection
|
| 69 |
inputs = tokenizer(message, return_tensors="pt")
|
| 70 |
with torch.no_grad():
|
|
|
|
| 54 |
def save_user_data(data):
|
| 55 |
with open(USER_DATA_FILE, "w") as f:
|
| 56 |
json.dump(data, f)
|
|
|
|
|
|
|
| 57 |
@app.route("/chat", methods=["POST"])
|
| 58 |
+
def chat():
|
| 59 |
+
user_input = request.json.get("message", "")
|
| 60 |
+
bot_text, emotion = generate_response(user_input)
|
| 61 |
+
|
| 62 |
+
# ✅ Make sure to return both fields exactly like this:
|
| 63 |
+
return jsonify({
|
| 64 |
+
"text": bot_text,
|
| 65 |
+
"emotion": emotion
|
| 66 |
+
})
|
| 67 |
# Emotion detection
|
| 68 |
inputs = tokenizer(message, return_tensors="pt")
|
| 69 |
with torch.no_grad():
|