Shresthh03 commited on
Commit
f933f3a
·
verified ·
1 Parent(s): c429d8c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -10
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 respond():
61
- data = request.get_json()
62
- message = data.get("message", "")
63
- user_name = data.get("name", "friend")
64
- user_age = data.get("age", "unknown")
65
-
66
- user_data = load_user_data()
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():