opinder2906 commited on
Commit
a54cd3a
·
verified ·
1 Parent(s): 6afd016

Update src/responses.py

Browse files
Files changed (1) hide show
  1. src/responses.py +61 -9
src/responses.py CHANGED
@@ -1,14 +1,66 @@
1
  import random
2
 
3
- # Hardcoded emotion→response mapping
4
  responses = {
5
- "happiness": ["That's wonderful! 😊", "Great to hear! 😃"],
6
- "sadness": ["I'm sorry you're feeling sad. 😔", "I hope things get better soon.😢"],
7
- "anger": ["I understand you're upset. 😠", "Let's take a deep breath.😊"],
8
- "fear": ["I hear your concern. 😟", "It's okay to feel anxious.😔"],
9
- "neutral": ["Tell me more.", "Go on..."]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  }
11
 
12
- # Return one random reply per emotion
13
- def get_response(emotion):
14
- return random.choice(responses.get(emotion, responses["neutral"]))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import random
2
 
3
+ # Copied directly from your script’s dictionaries
4
  responses = {
5
+ "sadness": [
6
+ "It’s okay to feel down sometimes. I’m here to support you.",
7
+ "I'm really sorry you're going through this. Want to talk more about it?",
8
+ "You're not alone I’m here for you."
9
+ ],
10
+ "anger": [
11
+ "That must have been frustrating. Want to vent about it?",
12
+ "It's okay to feel this way. I'm listening.",
13
+ "Would it help to talk through it?"
14
+ ],
15
+ "love": [
16
+ "That’s beautiful to hear! What made you feel that way?",
17
+ "It’s amazing to experience moments like that.",
18
+ "Sounds like something truly meaningful."
19
+ ],
20
+ "happiness": [
21
+ "That's awesome! What’s bringing you joy today?",
22
+ "I love hearing good news. 😊",
23
+ "Yay! Want to share more about it?"
24
+ ],
25
+ "neutral": [
26
+ "Got it. I’m here if you want to dive deeper.",
27
+ "Thanks for sharing that. Tell me more if you’d like.",
28
+ "I’m listening. How else can I support you?"
29
+ ]
30
  }
31
 
32
+ # Tip & goodbye logic copied from your script
33
+ relaxation_resources = {
34
+ "exercise": "Try this 5-4-3-2-1 grounding method: ...",
35
+ "video": "Short calming video: https://youtu.be/O-6f5wQXSu8"
36
+ }
37
+ help_keywords = ["suggest","help","calm","exercise","relax","any tips","can you"]
38
+ negative_inputs = ["not good","feel bad","feel sad","anxious","depressed","upset","stress","worried"]
39
+ thank_you_inputs = ["thank","thanks","thank you"]
40
+ bye_inputs = ["bye","goodbye","exit","quit"]
41
+
42
+ awaiting_tip_type = False
43
+
44
+ def get_response(emotion, user_input):
45
+ global awaiting_tip_type
46
+ ui = user_input.lower()
47
+ # 1) Exit
48
+ if any(b in ui for b in bye_inputs):
49
+ return "Take care! I’m here whenever you want to talk. 🌿", True
50
+ # 2) Thanks
51
+ if any(t in ui for t in thank_you_inputs):
52
+ return "You're most welcome! 💙", False
53
+ # 3) Tip request
54
+ if awaiting_tip_type:
55
+ if "video" in ui:
56
+ awaiting_tip_type = False
57
+ return relaxation_resources["video"], False
58
+ if "exercise" in ui:
59
+ awaiting_tip_type = False
60
+ return relaxation_resources["exercise"], False
61
+ return "Would you prefer a short video or a simple exercise?", False
62
+ if any(k in ui for k in help_keywords):
63
+ awaiting_tip_type = True
64
+ return "Prefer a brief video or an exercise?", False
65
+ # 4) Emotion-based reply
66
+ return random.choice(responses.get(emotion, responses["neutral"])), False