Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -33,36 +33,39 @@ if 'previous_responses' not in st.session_state:
|
|
33 |
|
34 |
# Function to generate a more empathetic and focused response
|
35 |
def generate_response(user_input):
|
36 |
-
#
|
37 |
-
|
38 |
-
"
|
39 |
-
|
40 |
-
|
41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
|
43 |
# Tailored coping suggestions based on the user's input
|
44 |
activity_suggestions = {
|
45 |
-
"journaling": "Journaling
|
46 |
-
"
|
47 |
-
"
|
48 |
-
"
|
49 |
-
"
|
50 |
-
"art": "Art can be a healing outlet for your emotions. Whether it’s drawing, painting, or even crafting, creating something with your hands allows you to express what might be too difficult to say in words. Try to let go of perfection and simply let your feelings guide your creativity.",
|
51 |
-
"nature": "Spending time in nature can be incredibly therapeutic. Even a brief walk outside can help refresh your mind and bring clarity. Nature has a way of reminding us that life continues, even when we feel stuck. Try to spend a few minutes listening to the birds or feeling the breeze – it may bring a sense of calm."
|
52 |
}
|
53 |
|
54 |
-
#
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
activity_suggestion = "Creating art can help you express your feelings of loss. You might try drawing or painting something that reminds you of your pet. Art can offer a safe space to express grief when words feel too heavy."
|
61 |
-
elif "overwhelmed" in user_input.lower() or "stressed" in user_input.lower():
|
62 |
-
activity = "journaling"
|
63 |
-
activity_suggestion = "Journaling can be a helpful way to process your thoughts and emotions. Writing down everything you’re feeling can allow you to see things more clearly and release some of the weight you’re carrying."
|
64 |
else:
|
|
|
65 |
activity = random.choice(list(activity_suggestions.keys()))
|
|
|
66 |
activity_suggestion = activity_suggestions[activity]
|
67 |
|
68 |
# Add the tailored coping activity suggestion to the response
|
|
|
33 |
|
34 |
# Function to generate a more empathetic and focused response
|
35 |
def generate_response(user_input):
|
36 |
+
# Empathy responses categorized by emotion
|
37 |
+
emotion_responses = {
|
38 |
+
"sadness": [
|
39 |
+
"I'm truly sorry you're going through this difficult time. Grief and sadness can weigh heavy, but you're not alone in your feelings. It's okay to take things one step at a time, and together we can explore ways to help you cope and find peace.",
|
40 |
+
"I can only imagine how overwhelming things must feel right now. When we’re grieving or under stress, it can be hard to see the light at the end of the tunnel, but you don’t have to carry the burden alone. I’m here for you.",
|
41 |
+
"I'm really sorry you're feeling this way. It’s completely understandable to feel sad, and it's okay to let those emotions flow. Grief can be exhausting, and it’s normal to need time to process everything."
|
42 |
+
],
|
43 |
+
"anger": [
|
44 |
+
"It sounds like you're feeling really frustrated, and that’s totally valid. Sometimes, our anger is a way of protecting us from pain or stress. If you’d like, I’m here to help you work through these feelings and find ways to release some of that tension.",
|
45 |
+
"I understand that things may feel frustrating and intense right now. Anger can be a difficult emotion to manage, but it’s completely natural. Sometimes, taking a step back and focusing on deep breathing or a calming activity can help.",
|
46 |
+
"It’s okay to feel angry – sometimes it’s our body’s way of telling us that something needs to change or that we need to release pent-up stress. You’re not alone in this, and there are healthy ways we can work through it together."
|
47 |
+
]
|
48 |
+
}
|
49 |
|
50 |
# Tailored coping suggestions based on the user's input
|
51 |
activity_suggestions = {
|
52 |
+
"journaling": "Journaling can be a helpful way to process your thoughts and emotions. Writing down everything you’re feeling can allow you to see things more clearly and release some of the weight you’re carrying.",
|
53 |
+
"deep breathing": "Deep breathing can help calm your mind and ease tension. Try taking a few slow, deep breaths, focusing on each inhale and exhale. It can help you feel grounded and in control of your emotions.",
|
54 |
+
"exercise": "Physical activity is a wonderful way to release built-up tension and boost your mood. Taking a walk in nature or doing some light stretching can help ground you in the present moment and relieve stress.",
|
55 |
+
"talking to someone": "Sometimes, sharing how you’re feeling with someone you trust can relieve some of the burden. Talking through your emotions with a friend or loved one can provide comfort and help you feel supported.",
|
56 |
+
"art": "Art can be a therapeutic outlet for your emotions. Creating something with your hands, like drawing or painting, allows you to express what might be too difficult to put into words."
|
|
|
|
|
57 |
}
|
58 |
|
59 |
+
# Determine emotion based on keywords in user input
|
60 |
+
if "angry" in user_input.lower() or "frustrated" in user_input.lower():
|
61 |
+
emotion = "anger"
|
62 |
+
activity = "deep breathing"
|
63 |
+
response = random.choice(emotion_responses[emotion])
|
64 |
+
activity_suggestion = activity_suggestions[activity]
|
|
|
|
|
|
|
|
|
65 |
else:
|
66 |
+
emotion = "sadness"
|
67 |
activity = random.choice(list(activity_suggestions.keys()))
|
68 |
+
response = random.choice(emotion_responses[emotion])
|
69 |
activity_suggestion = activity_suggestions[activity]
|
70 |
|
71 |
# Add the tailored coping activity suggestion to the response
|