opinder2906 commited on
Commit
d8e0023
·
verified ·
1 Parent(s): b1bca3c

Update src/responses.py

Browse files
Files changed (1) hide show
  1. src/responses.py +30 -57
src/responses.py CHANGED
@@ -1,66 +1,39 @@
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
 
1
  import random
2
+ from textblob import TextBlob
3
 
4
+ # Your response dictionaries
5
  responses = {
6
+ "sadness": [...],
7
+ "anger": [...],
8
+ "love": [...],
9
+ "happiness": [...],
10
+ "neutral": [...]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  }
12
+ relax_resources = {
13
+ "exercise": "Try the 5-4-3-2-1 grounding method: ...",
14
+ "video": "https://youtu.be/O-6f5wQXSu8"
 
 
15
  }
16
+ help_kw = [...]
17
+ neg_inputs = [...]
18
+ thx_inputs = [...]
19
+ bye_inputs = [...]
20
+ awaiting = False
21
 
22
+ def correct_spelling(text):
23
+ return str(TextBlob(text).correct())
24
 
25
  def get_response(emotion, user_input):
26
+ global awaiting
27
  ui = user_input.lower()
28
+ # 1) exit
29
+ if any(b in ui for b in bye_inputs): return "Take care!", True
30
+ # 2) thanks
31
+ if any(t in ui for t in thx_inputs): return "You're welcome!", False
32
+ # 3) tip flow
33
+ if awaiting:
34
+ # ...same logic...
35
+ if any(k in ui for k in help_kw):
36
+ awaiting = True
37
+ return "Video or exercise?", False
38
+ # 4) emotion reply
39
+ return random.choice(responses.get(emotion, responses['neutral'])), False