File size: 1,021 Bytes
70ca5d4
d8e0023
70ca5d4
d8e0023
70ca5d4
d8e0023
 
 
 
 
70ca5d4
d8e0023
 
 
a54cd3a
d8e0023
 
 
 
 
a54cd3a
d8e0023
 
a54cd3a
 
d8e0023
a54cd3a
d8e0023
 
 
 
 
 
 
 
 
 
 
635eaa1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import random
from textblob import TextBlob

# Your response dictionaries
responses = {
    "sadness": [...],
    "anger":   [...],
    "love":    [...],
    "happiness": [...],
    "neutral": [...]
}
relax_resources = {
    "exercise": "Try the 5-4-3-2-1 grounding method: ...",
    "video":      "https://youtu.be/O-6f5wQXSu8"
}
help_kw    = [...]
neg_inputs = [...]
thx_inputs = [...]
bye_inputs = [...]
awaiting   = False

def correct_spelling(text):
    return str(TextBlob(text).correct())

def get_response(emotion, user_input):
    global awaiting
    ui = user_input.lower()
    # 1) exit
    if any(b in ui for b in bye_inputs): return "Take care!", True
    # 2) thanks
    if any(t in ui for t in thx_inputs): return "You're welcome!", False
    # 3) tip flow
    if awaiting:
        # ...same logic...
    if any(k in ui for k in help_kw):
        awaiting = True
        return "Video or exercise?", False
    # 4) emotion reply
    return random.choice(responses.get(emotion, responses['neutral'])), False