Sairii commited on
Commit
a05cbfa
·
verified ·
1 Parent(s): 3c216cd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +574 -600
app.py CHANGED
@@ -1,601 +1,575 @@
1
-
2
- # Import require files
3
- import torch
4
- import gradio as gr
5
- import random
6
-
7
- from typing import Dict
8
- from transformers import pipeline
9
-
10
- # Define model path
11
- model_path = "Sairii/mood_classifier_distilbert"
12
-
13
- # Define vibe map
14
- vibe_map = {
15
- "sad": {
16
- "playlists": [
17
- "https://open.spotify.com/playlist/5DVUEqRL1EV8I9n65eBaAw?si=73e861e180b34945",
18
- "https://open.spotify.com/playlist/6yYA6aUGp8qUTgQWWYkPkP?si=4f18ea62db574b89",
19
- "https://open.spotify.com/playlist/2ZnAWYy4AOs8tpRUCGF6Py?si=fdc856b767e84fd1",
20
- "https://open.spotify.com/playlist/5tXGgf59I0CYYLSKoXyj55?si=0aaf98afaee544f9"
21
- ],
22
- "memes":[
23
- "https://images3.memedroid.com/images/UPLOADED24/6422c709a474e.webp",
24
- "https://cdn.verbub.com/images/cuando-estas-triste-y-escuchas-musica-triste-para-estar-mas-triste-219947.jpg",
25
- "https://cdn.memegenerator.es/imagenes/memes/full/29/24/29241765.jpg",
26
- "https://cdn.verbub.com/images/cuando-comes-porque-estas-triste-pero-ahora-estas-gordo-y-triste-66630.jpg",
27
- "https://www.thehealthy.com/wp-content/uploads/2020/10/xp1iwnvph2q51.jpg?fit=700,700",
28
- "https://i.pinimg.com/736x/26/40/87/2640871a50c7c0332fabffb040f409f7.jpg",
29
- "https://www.digitalmomblog.com/wp-content/uploads/2023/02/crying-behind-mask-meme.jpg",
30
-
31
- ],
32
- "images": [
33
- "https://getwallpapers.com/wallpaper/full/e/a/f/1186903-beautiful-cutest-wallpapers-in-the-world-1920x1200-phone.jpg",
34
- "https://i.pinimg.com/originals/c7/b9/62/c7b962b8330ec841278c07718532983b.jpg",
35
- "https://3.bp.blogspot.com/-nFQxBSDULZQ/WPFBNB-HAQI/AAAAAAAAAac/9AVttSP7mNwRA_oYA-SQydRt-4EXxsUvwCLcB/s1200/Excelentes-Frases-Para-Animar-A-Un-Amigo-Consejos-gratis.jpg",
36
- "https://4.bp.blogspot.com/-DhogjKFhjSA/VGJDQS7NgiI/AAAAAAAASaU/Gq7BwZjlpT4/s1600/postales-de-cachorros.jpg",
37
- "https://4.bp.blogspot.com/-iHbIEnMI5iQ/T5jgKqqwOJI/AAAAAAAAPPQ/52xa0v15EJ8/s1600/1+gatos+y+gatitos+hermosos,+tiernos+(10).jpg",
38
-
39
- ],
40
- "quotes":[
41
- "There is no greater sorrow than to recall happiness in times of misery.Dante Alighieri",
42
- "Life is made of so many partings welded together. Charles Dickens",
43
- "There are moments when I wish I could roll back the clock and take all the sadness away, but I have the feeling that if I did, the joy would be gone as well. –Nicholas Sparks",
44
- "Some stories don’t have happy endings. Even love stories. Maybe especially love stories. - Kristin Hannah, The Nightingale",
45
- "There is no greater sorrow than to recall, in misery, the time when we were happy. –Dante AligherI",
46
- "We must understand that sadness is an ocean, and sometimes we drown, while other days we are forced to swim. -R.M. Drake",
47
- "Heavy hearts, like heavy clouds in the sky, are best relieved by the letting of a little water. –Christopher Morley"
48
- ],
49
- "self_care": [
50
- "Take time to pause. Go outside and watch the clouds",
51
- "Reflect on a positive memory from the past week. Positivity boosts serotonin, a neurotransmitter associated with happiness",
52
- "Try coloring books or doodling. Artistic activities activate the brain’s relaxation pathways",
53
- "Drink some water.",
54
- "Go for a walk, even if it’s just around the room.",
55
- "Dance like no one is watching you"
56
-
57
- ],
58
- "affirmations": [
59
- "This sadness will pass, and brighter moments are ahead.",
60
- "You are taking things one breath at a time.",
61
- "You are strong enough to feel this, and you are resilient.",
62
- "You are surrounded by quiet support, even if you can't see it right now.",
63
- "Healing is happening, gently and slowly.",
64
- "You are allowed to rest and be kind to myself."
65
- ]
66
- },
67
- "angry":{
68
- "playlists":[
69
- "https://open.spotify.com/playlist/609gQW5ztNwAkKnoZplkao?si=fa8033175c4e410e",
70
- "https://open.spotify.com/playlist/37i9dQZF1EIhuCNl2WSFYd?si=115efc71faf94048",
71
- "https://open.spotify.com/playlist/5VP7RwPQ0xzCn0Y6588GTw?si=1fe3193a37a04090",
72
- "https://open.spotify.com/playlist/0Y0haVAr5i8ZBnc67G6oCl?si=36b33db7df654384"
73
-
74
- ],
75
- "memes":[
76
- "https://www.happierhuman.com/wp-content/uploads/2022/06/anger-meme-sayingimages-real-friends-ftm.jpg",
77
- "https://www.happierhuman.com/wp-content/uploads/2022/06/anger-meme-collegetimes-ill-stay-angry-instead.png",
78
- "https://i.imgflip.com/7diog0.jpg",
79
- "https://sayingimages.com/wp-content/uploads/angry-management-memes.jpg",
80
- "https://sayingimages.com/wp-content/uploads/angry-happiness-challenged-memes.jpg",
81
- "https://sayingimages.com/wp-content/uploads/angry-meme.jpg",
82
- "https://memecentral.org/wp-content/uploads/2019/08/angry-man-meme.jpg",
83
- "https://memecentral.org/wp-content/uploads/2019/08/angry-cat-noises-meme.jpg"
84
-
85
- ],
86
- "images":[
87
- "https://wallpapercave.com/wp/6GcHLY2.jpg",
88
- "https://burst.shopifycdn.com/photos/green-eyed-kitten.jpg?width=746&format=pjpg&exif=0&iptc=0",
89
- "https://wallpapercave.com/wp/QGsncry.jpg",
90
- "https://wallpaperaccess.com/full/276172.jpg",
91
- "https://cdn.wallpapersafari.com/1/56/MRJ3uA.jpg"
92
-
93
- ],
94
- "quotes":[
95
- "Anger makes you smaller, while forgiveness forces you to grow beyond what you were — Cherie Carter-Scott",
96
- "Anger is never without a reason, but seldom a good one. — Benjamin Franklin",
97
- "A fool gives full vent to his anger, but a wise man keeps himself under control — Proverbs 29:11",
98
- "When angry count to ten before you speak. If very angry, count to one hundred. - Thomas Jefferson",
99
- "The truth will set you free, but first it will piss you off.",
100
- "“Most misunderstandings in the world could be avoided if people would simply take the time to ask, What else could this mean?",
101
- "Speak when you are angry – and you will make the best speech you’ll ever regret. — Laurence J. Peter"
102
-
103
- ],
104
- "self_care":[
105
- "Take breaks from social commitments when overwhelmed",
106
- "Use mindfulness or meditation to center yourself",
107
- "Take a hot shower or bath with some music and candles",
108
- "Walk way and cold down",
109
- "Grab a paper and write about what's bugging you",
110
- "Count to 20 (or 50 or 34587 or more)"
111
-
112
- ],
113
- "affirmations":[
114
- "Your anger is a signal. Listen to what it’s trying to protect.",
115
- "It’s okay to feel this. Let it move through you, not control you.",
116
- "You don’t owe anyone your silence when something hurts.",
117
- "You’re not ‘too much’—they’re just not used to boundaries.",
118
- "Burning bridges? Babe, sometimes it’s called clearing dead weight.",
119
- "Pop off if you must—but make it poetic and powerful.",
120
- "Alright, you're feeling a bit blue, huh? Snap out of it... gently, of course."
121
- ]
122
- },
123
- "anxious":{
124
- "playlists":[
125
- "https://open.spotify.com/playlist/1r4hnyOWexSvylLokn2hUa?si=581df210bc144a17",
126
- "https://open.spotify.com/playlist/7JabddFr3Q6JPsND4v9Swf?si=ec9ea7bbab86403b",
127
- "https://open.spotify.com/playlist/18L9Oembkvoo7ciwrUDGAi?si=ca0bd53022bb4ab3",
128
- "https://open.spotify.com/playlist/5z5prxfyNclz9U3bE1YIZo?si=41d9c06a714c4707"
129
- ],
130
- "memes":[
131
- "https://www.happierhuman.com/wp-content/uploads/2022/03/memes-anxiety-instagram-what-if-it-does.jpg",
132
- "https://www.happierhuman.com/wp-content/uploads/2022/03/memes-anxiety-realvitamins-where-do-i-begin.jpg",
133
- "https://www.happierhuman.com/wp-content/uploads/2022/03/memes-anxiety-realvitamins-panic-attacks-activated.jpg",
134
- "https://www.happierhuman.com/wp-content/uploads/2022/03/memes-anxiety-realvitamins-mom-do-you-even-know-me.jpg",
135
- "https://ruinmyweek.com/wp-content/uploads/2020/01/anxiety-memes-2.png",
136
- "https://starecat.com/content/wp-content/uploads/when-someone-says-dont-be-anxious-and-your-anxiety-is-cured.jpg",
137
- "https://i.pinimg.com/originals/89/69/b2/8969b2f3ec5fdd0ccaf331262f8287e3.jpg"
138
-
139
- ],
140
- "images":[
141
- "https://www.pixelstalk.net/wp-content/uploads/2016/07/Relaxing-Photos-HD.jpg",
142
- "https://getwallpapers.com/wallpaper/full/8/8/9/1498083-mind-relaxing-wallpapers-1920x1080-tablet.jpg",
143
- "https://wallpaperaccess.com/full/3815908.jpg",
144
- "https://i.pinimg.com/originals/d9/af/a3/d9afa330a7b89865db34e645c86a36ce.jpg",
145
- "https://blog.uptodown.com/wp-content/uploads/relax-app-android-featured.jpg.webp",
146
- "https://db5vrvzqvdahe.cloudfront.net/wp-content/uploads/shutterstock_435387934.jpg",
147
- "https://st2.depositphotos.com/1146092/11636/i/950/depositphotos_116368986-stock-photo-relax-spa-wellness-dog.jpg"
148
-
149
- ],
150
- "quotes":[
151
- "“No need to hurry. No need to sparkle. No need to be anybody but oneself.” — Virginia Woolf",
152
- " “Anxiety happens when you think you have to figure everything out all at once. Breathe. You’re strong. You got this.” — Karen Salmansohn",
153
- " “If you want to test your memory, try to recall what you were worrying about one year ago today.” — E. Joseph Cossman",
154
- " “Feel the fear and do it anyway.” — Susan Jeffers",
155
- "“Sometimes letting go is the best way to find peace.” — Donna Goddard",
156
- "It’s okay to not be okay. Just don’t stay that way.",
157
- "“Breathe. Let go. And remind yourself that this very moment is the only one you know you have for sure.” — Oprah Winfrey",
158
- "“You don’t have to have it all figured out to move forward.” — Roy T. Bennett"
159
-
160
- ],
161
- "self_care":[
162
- "Dance to your favorite songes",
163
- "Do something active: go for a walk, go to the gym",
164
- "Call or text a loved one",
165
- "Cozy up in your favorite spot",
166
- "Watch a movie or a tv show",
167
- "Clean up your bedroom",
168
-
169
-
170
- ],
171
- "affirmations":[
172
- "You are safe in this moment. Breathe through it.",
173
- "This fear will pass. You’ve survived every wave so far.",
174
- "You don’t need to fix everything right now. Just be here.",
175
- "It's okay for your mind to race right now. You are safe.",
176
- "This feeling of anxiety is temporary, and it will pass.",
177
- "Worries are just thoughts in fancy, annoying costumes. See 'em, then ignore 'em.",
178
- "Yeah, your body's on high alert. Tell it to take a coffee break, you've got this.",
179
- "You've survived worse, trust me. This is just a plot twist, not the grand finale.",
180
- "So what if you're a mess? Even masterpieces start with a bit of chaos, right?"
181
-
182
- ]
183
- },
184
- "joy":{
185
- "playlists":[
186
- "https://open.spotify.com/playlist/37i9dQZF1DXdPec7aLTmlC?si=c1e32eeb15734773",
187
- "https://open.spotify.com/playlist/37i9dQZF1EIgG2NEOhqsD7?si=6e44ed2babe24541",
188
- "https://open.spotify.com/playlist/0faAJkECam6JhkR9TLolIQ?si=aacb24457354433b",
189
- "https://open.spotify.com/playlist/6hXwzaSaiiWUazPjpQn0Yl?si=d4da8cb30cf84d49"
190
-
191
- ],
192
- "memes":[
193
- "https://i.pinimg.com/originals/97/79/88/977988c0c50650833040e74b03b3d148.jpg",
194
- "https://i.pinimg.com/originals/ba/fb/5d/bafb5de2a3e9b7e7f246e89385b30a6f.jpg",
195
- "https://img.izismile.com/img/img15/20231218/640/joyful_animal_humor_memes_and_pics_spreading_smiles_640_high_18.jpg",
196
- "https://www.musicraiser.net/wp-content/uploads/2020/01/31-Joyful-Memes-to-Make-You-Smile-Whole-Day-18-545x495.jpg",
197
- "https://sayingimages.com/wp-content/uploads/dont-worry-you-got-this-motivational-memes.jpg",
198
- "https://sayingimages.com/wp-content/uploads/motivational-today-is-the-day-memes.jpg"
199
-
200
- ],
201
- "images":[
202
- "https://www.success.com/wp-content/uploads/legacy/sites/default/files/2_29.jpg",
203
- "https://3.bp.blogspot.com/-lf1l7-_tVr8/WcDydIUsnUI/AAAAAAAAbZ0/k81Qn_guYlwhrcwDH8aZ7CJ1yvXPnJ0pwCLcBGAs/s1600/You%2Bcome%2Bso%2Bfar2.png",
204
- "https://sayingimages.com/wp-content/uploads/be-the-best-you-can-be-motivational-memes.jpg",
205
- "https://sayingimages.com/wp-content/uploads/whos-awesome-youre-awesome-motivational-memes.jpg",
206
- "https://sayingimages.com/wp-content/uploads/motivational-youre-awesome-memes.jpg.webp"
207
-
208
-
209
- ],
210
- "quotes":[
211
- "“They say a person needs just three things to be truly happy in this world: someone to love, something to do, and something to hope for.”― Tom Bodett",
212
- "Focus on the journey, not the destination. Joy is found not in finishing an activity but in doing it. - Greg Anderson",
213
- "If the sight of the blue skies fills you with joy, if a blade of grass springing up in the fields has power to move you, if the simple things of nature have a message that you understand, rejoice, for your soul is alive. - Eleonora Duse",
214
- "The sun does not shine for a few trees and flowers, but for the wide world's joy. Henry Ward Beecher",
215
- "Let your joy be in your journey - not in some distant goal. - Tim Cook",
216
- "“When we are centered in joy, we attain our wisdom.” —Marianne Williamson"
217
-
218
- ],
219
- "self_care":[
220
- "Go watch the sunset",
221
- "Treat yourself to an amazing dessert",
222
- "Treat yourself & a friend to coffe at a cute cae",
223
- "Take yourself out for lunch",
224
- "Look at the stars",
225
- "Dance & sing to your favorite song"
226
-
227
- ],
228
- "affirmations":[
229
- "Yeah, you're basically a **joy magnet**. Don't act surprised, you earned it.",
230
- "Turns out, **happiness looks great on you**. Keep it up, buttercup.",
231
- "Laughter's your new superpower, and you're wielding it like a **pro**.",
232
- "**Unapologetically gleeful**, that's you. And honestly? It's a look.",
233
- "Go on, spread that **contagious cheer**. The world could use a dose of your fabulousness.",
234
- "You find delight in the simple pleasures and beauty all around you.",
235
- "You are worthy of abundant joy, and it is your natural state.",
236
- "Laughter comes easily to you, brightening your day and those around you.",
237
- "You are alive, vibrant, and bursting with positive energy.",
238
- "Joy multiplies within you as you share your light with the world."
239
-
240
-
241
- ]
242
- },
243
- "tired":{
244
- "playlists":[
245
- "https://open.spotify.com/playlist/37i9dQZF1EIcUQK8Nwn2jv?si=5e7ae3e1dcb745a8",
246
- "https://open.spotify.com/playlist/4l1BhoNigXILxeQQeBDbvg?si=e1ab5c466bf14eca",
247
- "https://open.spotify.com/playlist/6rjP6aBpLGgr5odndfARlq?si=d8a4e7ff9d374497",
248
- "https://open.spotify.com/playlist/7MUhmEs5iduvuWid91mnw6?si=553213fcd7b94638"
249
-
250
- ],
251
- "memes":[
252
- "https://www.digitalmomblog.com/wp-content/uploads/2023/09/funny-tired-meme.jpg.webp",
253
- "https://www.digitalmomblog.com/wp-content/uploads/2023/09/tired-meme-funny.jpeg.webp",
254
- "https://inspirationfeed.com/wp-content/uploads/2020/07/Tired-Meme19.jpg",
255
- "https://inspirationfeed.com/wp-content/uploads/2020/07/Tired-Meme33.jpg",
256
- "https://piximus.net/media2/55735/tired-memes-10.jpg",
257
- "https://i.pinimg.com/originals/83/f4/01/83f4016f7e3671275f78b5d7562e19f3.jpg"
258
-
259
- ],
260
- "images":[
261
- "https://quotefancy.com/media/wallpaper/3840x2160/7390377-Carlos-Wallace-Quote-When-you-are-tired-you-rest-You-don-t-give-up.jpg",
262
- "https://cdn3.careeraddict.com/uploads/article/60864/tips-to-wake-up-infographic.png",
263
- "https://www.verywellhealth.com/thmb/ZncipGImtDmdZ4xECfzo1dd9y10=/1500x0/filters:no_upscale():max_bytes(150000):strip_icc()/reasons-for-poor-sleep-quality-45881701-52c54387761c4baa9f702e8a5f86b9a7.gif",
264
- "https://my.clevelandclinic.org/-/scassets/images/org/health/articles/12119-insomnia",
265
- "https://www.awesomeinventions.com/wp-content/uploads/2016/02/Tired-Just-Tired.jpg"
266
-
267
-
268
- ],
269
- "quotes":[
270
- "You can do anything but not everything - David Allen",
271
- "Silence doesn't always mean yes. Sometimes, it means, I am tired of explaining to people who don't even care to understand",
272
- "“Tired minds don’t plan well. Sleep first, plan later.” – Walter Reisch",
273
- "“Even the darkest night will end and the sun will rise.” – Victor Hugo",
274
- "“Even heroes need a break.” – Stan Lee",
275
- "Sometimes I wish I could just press pause and catch my breath."
276
-
277
- ],
278
- "self_care":[
279
- "Take a nap with no alarm",
280
- "Take something off of your to-do list",
281
- "Say no to something",
282
- "Watch your favorite TV show",
283
- "Use a weighted blanket",
284
- "Put your phone on Do Not Disturb"
285
-
286
- ],
287
- "affirmations":[
288
- "You're not lazy, you're in **energy-saving mode**. Smart, really.",
289
- "Operation Recharge is a go! Prepare for maximum horizontal time.",
290
- "Conquering the world can wait. Your couch, however, cannot.",
291
- "You're done. D-O-N-E. Now go get that beauty sleep, you earned it.",
292
- "Rest isn’t lazy—it’s necessary.",
293
- "You don’t have to do it all. You just have to breathe.",
294
- "Your body and soul are asking for care. Listen.",
295
- "It's okay to feel tired. You've done enough for today.",
296
- "Your body is asking for rest, and you are listening.",
297
-
298
- ]
299
-
300
- },
301
- "numb":{
302
- "playlists":[
303
- "https://open.spotify.com/playlist/7DtC8X9lVC5VulFqTZARQA?si=9f533b357b5f4696",
304
- "https://open.spotify.com/playlist/6kR2MtMOkP0CRZYRbbjLCB?si=dabbb4e18ef94831",
305
- "https://open.spotify.com/playlist/04hyzNf9DUjOPkI7v7nDoC?si=01fb238ef4a943ef",
306
- "https://open.spotify.com/playlist/1wU8Bso3aX6ophkPYvETs9?si=28f126326bf94bf0"
307
-
308
- ],
309
- "memes":[
310
- "https://i.imgflip.com/77ft0w.jpg",
311
- "https://themighty.com/wp-content/uploads/2019/11/via-QuickMeme.jpg",
312
- "https://themighty.com/wp-content/uploads/2019/11/Quickmemee.jpg",
313
- "https://i.pinimg.com/originals/82/cb/00/82cb002d89fabe4e2c49fcaf25434eb7.png",
314
- "https://www.reddit.com/media?url=https%3A%2F%2Fi.redd.it%2F7mjxeq54mzb31.jpg",
315
- "https://i.pinimg.com/originals/fa/95/94/fa9594debda1e02ca8bb8b84e9f3ec0a.png"
316
-
317
- ],
318
- "images":[
319
- "https://www.maestronews.com/wallpapers/landscape/sunrise/sunrise_10.jpg",
320
- "https://www.pixelstalk.net/wp-content/uploads/2016/08/Night-Sky-Milky-Way-Galaxy-Wallpaper.jpg",
321
- "https://www.pixelstalk.net/wp-content/uploads/2016/03/Cute-Animal-Wallpaper-HD-desktop.jpg",
322
- "https://cdn.pixabay.com/photo/2017/05/18/13/46/rainbow-2323708_1280.jpg",
323
- "https://www.factinate.com/wp-content/uploads/2018/07/baby-animals.jpg"
324
-
325
- ],
326
- "quotes":[
327
- "“I just let the pain take over, allowing it to numb the pain of being left behind.” ― Jessica Sorensen, The Coincidence of Callie & Kayden",
328
- "“I’ve perfected the art of the fake smile. It’s not so difficult when you are completely numb.” ― Bethany Griffin, Masque of the Red Death",
329
- "“I should have been angry, but I was struggling to feel much of anything.” ― Karie Fugett, Alive Day: A Memoir",
330
- "“Better to feel nothing, to be numb, than to lose control. It's the only way I know to deal with it.” ― Julie Kagawa, The Forever Song",
331
- "“Some scars don’t hurt. Some scars are numb. Some scars rid you of the capacity to feel anything ever again.” ― Joyce Rachelle",
332
- "“I thought I’m healing but the truth is, I just stopped feeling.” – C. C. Aurel"
333
-
334
- ],
335
- "self_care":[
336
- "Try 5 minutes of journaling, doesn't need to be perfect, just pour those thoughts somewhere",
337
- "Give yourself permission to feel exactly how you are feeling",
338
- "Connect with others at your own pace: have a small conversation with a friend",
339
- "Rest and don't feel guilty about it",
340
- "Go for a walk and listen to the sounds around you",
341
- "Do breathing exercises:Try inhaling for four counts, holding for four, and exhaling for four (the 4-4-4 method) "
342
-
343
- ],
344
- "affirmations":[
345
- "If your heart’s on airplane mode, fine—but don’t crash.",
346
- "You’re still a whole damn person, even when you feel nothing.",
347
- "Frozen doesn’t mean gone. You’ll thaw. Slowly. And dramatically.",
348
- "Okay, emotions took a vacation, huh? Fine, you do you.",
349
- "Healing is happening, even when it feels like nothing is happening.",
350
- "You are supported, even if you can't feel it right now.",
351
- "Be kind to yourself in this space of emotional quiet.",
352
- "You are whole, even in this moment of numbness."
353
-
354
- ]
355
- },
356
- "confident":{
357
- "playlists":[
358
- "https://open.spotify.com/playlist/37i9dQZF1EIhAa4OzjmrFk?si=6a513706c2634f18",
359
- "https://open.spotify.com/playlist/5QK5DcACsK2r9VzNwSgHl4?si=2a6efce45370425e",
360
- "https://open.spotify.com/playlist/37i9dQZF1DX4fpCWaHOned?si=ec97e651466c4311",
361
- "https://open.spotify.com/playlist/2f67AbWKCd2Ry2jkzDejs7?si=5fe719ef827b4d39"
362
-
363
- ],
364
- "memes":[
365
- "https://i.imgflip.com/1ks1mm.jpg",
366
- "https://imgix.bustle.com/2017/1/17/7ed6d773-dfd1-4fd6-87eb-713114b0102c.jpg?w=414&h=600&fit=crop&crop=faces&auto=format%2Ccompress&q=50&dpr=2",
367
- "https://i.imgflip.com/1e4msy.jpg",
368
- "https://i.imgflip.com/1ntulb.jpg",
369
- "https://i.pinimg.com/originals/bc/2e/65/bc2e653597ba3cdab4dd7dbc40b90b21.jpg",
370
- "https://sayingimages.com/wp-content/uploads/hold-my-beer-i-got-this-meme.jpeg"
371
-
372
- ],
373
- "images":[
374
- "https://sayingimages.com/wp-content/uploads/motivational-arise-go-forth-and-conquer-memes.jpg",
375
- "https://cdn.pixabay.com/photo/2015/09/24/06/09/positive-954797_1280.jpg",
376
- "https://images.huffingtonpost.com/2015-12-04-1449210149-2724155-SelfConfidence.png",
377
- "https://bethlehemdenver.com/wp-content/uploads/2020/07/FINISH-LINE.jpg",
378
- "https://cdn.pixabay.com/photo/2024/05/24/12/58/ai-generated-8785023_1280.png"
379
-
380
- ],
381
- "quotes":[
382
- "“Be who you are and say what you feel, because those who mind don't matter, and those who matter don't mind.” ― Bernard M. Baruch",
383
- "“You probably wouldn’t worry about what people think of you if you could know how seldom they do.” ― Olin Miller",
384
- "“Do not fear to be eccentric in opinion, for every opinion now accepted was once eccentric.” ― Bertrand Russell",
385
- "“Believe in your infinite potential. Your only limitations are those you set upon yourself.” ― Roy T. Bennett, The Light in the Heart",
386
- "“Accept who you are; and revel in it.” ― Mitch Albom, Tuesdays with Morrie: An Old Man, a Young Man, and Life's Greatest Lesson",
387
- "No matter how old you are now. You are never too young or too old for success or going after what you want."
388
-
389
- ],
390
- "self_care":[
391
- "Surround yourself with positive people",
392
- "Take care of your body: diet, exercise, meditation",
393
- "Always be kind to yourself",
394
- "Practive positive self-talk",
395
- "Do things you are good at"
396
-
397
-
398
- ],
399
- "affirmations":[
400
- "You’re the whole damn meal. Stop acting like a side dish.",
401
- "Confidence looks good on you—don’t take it off for anyone.",
402
- "They should be grateful they even get to witness your glow.",
403
- "Oh, you thought you couldn't? Cute. Watch you **absolutely crush it**.",
404
- "You embrace your authentic self, knowing you are enough.",
405
- "You move through the world with quiet assurance and grace.",
406
- "Your presence is a gentle power that inspires those around you.",
407
- "You believe in yourself, and that belief softly guides your way.",
408
- "You are secure in who you are, finding peace in your own unique journey."
409
-
410
-
411
- ]
412
- },
413
- "hopeful":{
414
- "playlists":[
415
- "https://open.spotify.com/playlist/37i9dQZF1EIemCZWVgQTXB?si=a0546c750dff4601",
416
- "https://open.spotify.com/playlist/77qvKHsd1c9YGbGcnZVNzE?si=09f097151e444c26",
417
- "https://open.spotify.com/playlist/4ofywy1Z3LbiSTlmSLPR0s?si=585d1d45ce84454b",
418
- "https://open.spotify.com/playlist/754LgMDMRwGna2RvnfTePc?si=7186e2ecbda546bd"
419
-
420
- ],
421
- "memes":[
422
- "https://sayingimages.com/wp-content/uploads/theres-still-hope-meme-300x300.jpg",
423
- "https://sayingimages.com/wp-content/uploads/sometimes-you-have-to-tell-yourself-i-am-a-share-and-attack-the-day-hope-meme.jpg",
424
- "https://sayingimages.com/wp-content/uploads/you-always-have-hope-even-if-theres-not-a-chance-in-hell-meme.jpg",
425
- "https://i.pinimg.com/originals/46/d9/30/46d9309e7a040b9151531f2a8e87550b.jpg",
426
- "https://sheideas.com/wp-content/uploads/2018/10/funny-positive-meme-18-585x403.jpg",
427
- "https://www.kerryjheckman.com/uploads/7/2/8/1/72815985/published/when-someone-understands.jpg?1523282931"
428
-
429
- ],
430
- "images":[
431
- "https://library.neura.edu.au/wp-content/uploads/sites/3/2017/01/Hope.jpg",
432
- "https://centralofsuccess.com/wp-content/uploads/2018/03/Inspirational-Hope-Quotes.jpg",
433
- "https://www.thewowstyle.com/wp-content/uploads/2015/01/whe-the-world-says-give-up-hope-whispers-try-it-one-more-time.jpg",
434
- "https://www.wishesmsg.com/wp-content/uploads/Hope-messages-and-sayings.jpg",
435
- "https://i.pinimg.com/736x/db/a6/a6/dba6a688a2f2e3053b3b373b75ec3b7a.jpg"
436
-
437
- ],
438
- "quotes":[
439
- "“You may say I'm a dreamer, but I'm not the only one. I hope someday you'll join us. And the world will live as one.”― John Lennon",
440
- "“I like the night. Without the dark, we'd never see the stars.” ― Stephenie Meyer, Twilight",
441
- "“If you're reading this... Congratulations, you're alive. If that's not something to smile about, then I don't know what is.” ― Chad Sugg, Monsters Under Your Head",
442
- "“If pain must come, may it come quickly. Because I have a life to live, and I need to live it in the best way possible. If he has to make a choice, may he make it now. Then I will either wait for him or forget him.” ― Paulo Coelho, By the River Piedra I Sat Down and Wept",
443
- "“Never lose hope. Storms make people stronger and never last forever.” ― Roy T. Bennett, The Light in the Heart",
444
- "“It's amazing how a little tomorrow can make up for a whole lot of yesterday.” ― John Guare, Landscape of the Body"
445
-
446
- ],
447
- "self_care":[
448
- "Give yourself compliments",
449
- "Keep a goal journal",
450
- "Let loved ones lift you up",
451
- "Take time out to journal - writing your thoughts and feelings down in one place can be really empowering. It can also help to ‘declutter’ your busy mind",
452
- "Binge watch your favourite TV show or movies - set time aside to chill and do something you enjoy, whether that’s alone or with someone you love.",
453
- "Spend time outdoors - choose to re-connect with nature"
454
-
455
- ],
456
- "affirmations":[
457
- "Hope is your quiet rebellion. Keep it alive.",
458
- "Trust the seeds you’ve planted. Bloom is coming.",
459
- "You don’t have to know how—it’s okay to just believe.",
460
- "Even in the quiet, you feel a gentle stirring of possibility.",
461
- "Still got that fire in your belly? Good. It's leading you somewhere epic.",
462
- "Don't just hope for it, expect it. You're manifesting greatness, darling.",
463
- "Your future's looking so bright, you might need shades. Just sayin'.",
464
- "Time to turn up the optimism. Your vibe is attracting your tribe... and cool opportunities.",
465
- "Plot twist: everything's about to work out. You saw it here first.",
466
-
467
- ]
468
- }
469
-
470
-
471
-
472
- }
473
-
474
- classifier = pipeline(task = "text-classification",
475
- model = model_path,
476
- device = "cuda" if torch.cuda.is_available() else "cpu",
477
- top_k = 2,
478
- batch_size = 32)
479
-
480
- # Define our function to use with our model
481
- def mood_text_classifier(text:str):
482
-
483
- # Outputs from the pipeline
484
- outputs = classifier(text)[0]
485
- result = outputs[0]
486
-
487
- label = result["label"].lower()
488
- score = result["score"]
489
-
490
- #Vibe map
491
- vibe = vibe_map.get(label, {})
492
- playlist = random.choice(vibe.get("playlists", ["No playlist found"]))
493
- meme = random.choice(vibe.get("memes", ["No meme found"]))
494
- image = random.choice(vibe.get("images", ["No image found"]))
495
- quote = random.choice(vibe.get("quotes", ["No quote found"]))
496
- self_care = random.choice(vibe.get("self_care", ["No tip found"]))
497
- affirmation = random.choice(vibe.get("affirmations", ["No affirmation found"]))
498
-
499
- return{
500
- "emotion": label,
501
- "confidence":round(score, 3),
502
- "playlist": playlist,
503
- "meme": meme,
504
- "image": image,
505
- "quote": quote,
506
- "self_care": self_care,
507
- "affirmation": affirmation
508
-
509
- }
510
-
511
-
512
- # Create the gradio ChatInterface
513
- def chatbot_friend(message, history):
514
- # Handle the very first interaction (when history is empty)
515
- if not history:
516
- return "Hey my friend! How are you really feeling today? Just tell me everything. Judgement-Free zone."
517
-
518
- # Safely find the last assistant message in history
519
- last_bot_message_content = ""
520
- for item in reversed(history): # Iterate backwards to find the most recent assistant message
521
- if item.get("role") == "assistant":
522
- last_bot_message_content = item.get("content", "").lower()
523
- break # Found the last assistant message, exit loop
524
-
525
- # If the last bot message asked what the user wants (e.g., "Do you want a playlist...")
526
- if "do you want" in last_bot_message_content:
527
-
528
- # Find the user's message right before the bot asked "do you want"
529
- # We look for the most recent 'user' message in history that isn't the current one.
530
- mood_input_message = None
531
- for i in range(len(history) - 1, -1, -1): # Iterate backwards from second to last item
532
- if history[i].get("role") == "user":
533
- mood_input_message = history[i].get("content")
534
- break
535
-
536
- # Fallback if for some reason we can't find it (shouldn't happen often)
537
- if mood_input_message is None:
538
- mood_input_message = message # Use current message as fallback
539
-
540
- mood_info = mood_text_classifier(mood_input_message)
541
- user_choice = message.lower()
542
-
543
- # Prepare additional bot responses based on user's choice
544
- new_bot_messages_content = []
545
-
546
- if "playlist" in user_choice:
547
- new_bot_messages_content.append(f'Here is your playlist for today, enjoy it!: <a href="{mood_info["playlist"]}" target="_blank">Listen 🎵</a>')
548
-
549
- if "meme" in user_choice:
550
- new_bot_messages_content.append(f'Enjoy this hilarious meme: <a href="{mood_info["meme"]}" target="_blank">View Meme</a>')
551
-
552
- if "quote" in user_choice:
553
- new_bot_messages_content.append(f"A nice inspirational quote for your day: {mood_info['quote']}")
554
-
555
- if "self_care" in user_choice:
556
- new_bot_messages_content.append(f"Here is your self-care tip for the day: {mood_info['self_care']}")
557
-
558
- if "affirmation" in user_choice:
559
- new_bot_messages_content.append(f"Here is your affirmation phrase: {mood_info['affirmation']}")
560
-
561
- if "image" in user_choice:
562
- new_bot_messages_content.append(f'Here is your inspirational image: <a href="{mood_info["image"]}" target="_blank">View Image</a>')
563
-
564
- # If no specific request was matched, provide a default meme
565
- if not new_bot_messages_content:
566
- new_bot_messages_content.append(f"I am not sure what you wanted, but take a meme for the soul: <a href=\"{mood_info['meme']}\" target=\"_blank\">View Meme</a>")
567
-
568
- # Append each new bot message to the history in the correct dictionary format
569
- # Each new message should be a dictionary: {"role": "assistant", "content": "text_content"}
570
- for content_str in new_bot_messages_content:
571
- history.append({"role": "assistant", "content": content_str})
572
-
573
- return history # Return the updated history list
574
-
575
- # Otherwise (it's a new initial message asking for mood, not a follow-up)
576
- else:
577
- # Classify the mood and ask what they want
578
- mood_info = mood_text_classifier(message)
579
- mood = mood_info['emotion']
580
-
581
- # Return the bot's response string. Gradio will automatically add it to history.
582
- return (
583
- f"Feeling {mood}? I got you. Do you want a playlist, meme, inspirational quote, "
584
- f"self-care tip, affirmation phrases, or just a cute image? Type what you need!"
585
- )
586
-
587
- # IMPORTANT: Create the ChatInterface with type="messages"
588
- demo = gr.ChatInterface(
589
- fn=chatbot_friend,
590
- title="Your best friend Mood Chatbot",
591
- description="Vibe check + emotional support with actual conversation",
592
- # Crucially, tell Gradio to use the new messages format
593
- # This means `history` in `chatbot_friend` will be a list of {"role": ..., "content": ...} dicts.
594
- type="messages"
595
- )
596
-
597
- if __name__ == "__main__":
598
- demo.launch()
599
- # Launch the interface
600
- if __name__ == "__main__":
601
  demo.launch()
 
1
+
2
+ # Import require files
3
+ import torch
4
+ import gradio as gr
5
+ import random
6
+
7
+ from typing import Dict
8
+ from transformers import pipeline
9
+
10
+ # Define model path
11
+ model_path = "Sairii/mood_classifier_distilbert"
12
+
13
+ # Define vibe map
14
+ vibe_map = {
15
+ "sad": {
16
+ "playlists": [
17
+ "https://open.spotify.com/playlist/5DVUEqRL1EV8I9n65eBaAw?si=73e861e180b34945",
18
+ "https://open.spotify.com/playlist/6yYA6aUGp8qUTgQWWYkPkP?si=4f18ea62db574b89",
19
+ "https://open.spotify.com/playlist/2ZnAWYy4AOs8tpRUCGF6Py?si=fdc856b767e84fd1",
20
+ "https://open.spotify.com/playlist/5tXGgf59I0CYYLSKoXyj55?si=0aaf98afaee544f9"
21
+ ],
22
+ "memes":[
23
+ "https://images3.memedroid.com/images/UPLOADED24/6422c709a474e.webp",
24
+ "https://cdn.verbub.com/images/cuando-estas-triste-y-escuchas-musica-triste-para-estar-mas-triste-219947.jpg",
25
+ "https://cdn.memegenerator.es/imagenes/memes/full/29/24/29241765.jpg",
26
+ "https://cdn.verbub.com/images/cuando-comes-porque-estas-triste-pero-ahora-estas-gordo-y-triste-66630.jpg",
27
+ "https://www.thehealthy.com/wp-content/uploads/2020/10/xp1iwnvph2q51.jpg?fit=700,700",
28
+ "https://i.pinimg.com/736x/26/40/87/2640871a50c7c0332fabffb040f409f7.jpg",
29
+ "https://www.digitalmomblog.com/wp-content/uploads/2023/02/crying-behind-mask-meme.jpg",
30
+
31
+ ],
32
+ "images": [
33
+ "https://getwallpapers.com/wallpaper/full/e/a/f/1186903-beautiful-cutest-wallpapers-in-the-world-1920x1200-phone.jpg",
34
+ "https://i.pinimg.com/originals/c7/b9/62/c7b962b8330ec841278c07718532983b.jpg",
35
+ "https://3.bp.blogspot.com/-nFQxBSDULZQ/WPFBNB-HAQI/AAAAAAAAAac/9AVttSP7mNwRA_oYA-SQydRt-4EXxsUvwCLcB/s1200/Excelentes-Frases-Para-Animar-A-Un-Amigo-Consejos-gratis.jpg",
36
+ "https://4.bp.blogspot.com/-DhogjKFhjSA/VGJDQS7NgiI/AAAAAAAASaU/Gq7BwZjlpT4/s1600/postales-de-cachorros.jpg",
37
+ "https://4.bp.blogspot.com/-iHbIEnMI5iQ/T5jgKqqwOJI/AAAAAAAAPPQ/52xa0v15EJ8/s1600/1+gatos+y+gatitos+hermosos,+tiernos+(10).jpg",
38
+
39
+ ],
40
+ "quotes":[
41
+ "There is no greater sorrow than to recall happiness in times of misery.Dante Alighieri",
42
+ "Life is made of so many partings welded together. Charles Dickens",
43
+ "There are moments when I wish I could roll back the clock and take all the sadness away, but I have the feeling that if I did, the joy would be gone as well. –Nicholas Sparks",
44
+ "Some stories don’t have happy endings. Even love stories. Maybe especially love stories. - Kristin Hannah, The Nightingale",
45
+ "There is no greater sorrow than to recall, in misery, the time when we were happy. –Dante AligherI",
46
+ "We must understand that sadness is an ocean, and sometimes we drown, while other days we are forced to swim. -R.M. Drake",
47
+ "Heavy hearts, like heavy clouds in the sky, are best relieved by the letting of a little water. –Christopher Morley"
48
+ ],
49
+ "self_care": [
50
+ "Take time to pause. Go outside and watch the clouds",
51
+ "Reflect on a positive memory from the past week. Positivity boosts serotonin, a neurotransmitter associated with happiness",
52
+ "Try coloring books or doodling. Artistic activities activate the brain’s relaxation pathways",
53
+ "Drink some water.",
54
+ "Go for a walk, even if it’s just around the room.",
55
+ "Dance like no one is watching you"
56
+
57
+ ],
58
+ "affirmations": [
59
+ "This sadness will pass, and brighter moments are ahead.",
60
+ "You are taking things one breath at a time.",
61
+ "You are strong enough to feel this, and you are resilient.",
62
+ "You are surrounded by quiet support, even if you can't see it right now.",
63
+ "Healing is happening, gently and slowly.",
64
+ "You are allowed to rest and be kind to myself."
65
+ ]
66
+ },
67
+ "angry":{
68
+ "playlists":[
69
+ "https://open.spotify.com/playlist/609gQW5ztNwAkKnoZplkao?si=fa8033175c4e410e",
70
+ "https://open.spotify.com/playlist/37i9dQZF1EIhuCNl2WSFYd?si=115efc71faf94048",
71
+ "https://open.spotify.com/playlist/5VP7RwPQ0xzCn0Y6588GTw?si=1fe3193a37a04090",
72
+ "https://open.spotify.com/playlist/0Y0haVAr5i8ZBnc67G6oCl?si=36b33db7df654384"
73
+
74
+ ],
75
+ "memes":[
76
+ "https://www.happierhuman.com/wp-content/uploads/2022/06/anger-meme-sayingimages-real-friends-ftm.jpg",
77
+ "https://www.happierhuman.com/wp-content/uploads/2022/06/anger-meme-collegetimes-ill-stay-angry-instead.png",
78
+ "https://i.imgflip.com/7diog0.jpg",
79
+ "https://sayingimages.com/wp-content/uploads/angry-management-memes.jpg",
80
+ "https://sayingimages.com/wp-content/uploads/angry-happiness-challenged-memes.jpg",
81
+ "https://sayingimages.com/wp-content/uploads/angry-meme.jpg",
82
+ "https://memecentral.org/wp-content/uploads/2019/08/angry-man-meme.jpg",
83
+ "https://memecentral.org/wp-content/uploads/2019/08/angry-cat-noises-meme.jpg"
84
+
85
+ ],
86
+ "images":[
87
+ "https://wallpapercave.com/wp/6GcHLY2.jpg",
88
+ "https://burst.shopifycdn.com/photos/green-eyed-kitten.jpg?width=746&format=pjpg&exif=0&iptc=0",
89
+ "https://wallpapercave.com/wp/QGsncry.jpg",
90
+ "https://wallpaperaccess.com/full/276172.jpg",
91
+ "https://cdn.wallpapersafari.com/1/56/MRJ3uA.jpg"
92
+
93
+ ],
94
+ "quotes":[
95
+ "Anger makes you smaller, while forgiveness forces you to grow beyond what you were — Cherie Carter-Scott",
96
+ "Anger is never without a reason, but seldom a good one. — Benjamin Franklin",
97
+ "A fool gives full vent to his anger, but a wise man keeps himself under control — Proverbs 29:11",
98
+ "When angry count to ten before you speak. If very angry, count to one hundred. - Thomas Jefferson",
99
+ "The truth will set you free, but first it will piss you off.",
100
+ "“Most misunderstandings in the world could be avoided if people would simply take the time to ask, What else could this mean?",
101
+ "Speak when you are angry – and you will make the best speech you’ll ever regret. — Laurence J. Peter"
102
+
103
+ ],
104
+ "self_care":[
105
+ "Take breaks from social commitments when overwhelmed",
106
+ "Use mindfulness or meditation to center yourself",
107
+ "Take a hot shower or bath with some music and candles",
108
+ "Walk way and cold down",
109
+ "Grab a paper and write about what's bugging you",
110
+ "Count to 20 (or 50 or 34587 or more)"
111
+
112
+ ],
113
+ "affirmations":[
114
+ "Your anger is a signal. Listen to what it’s trying to protect.",
115
+ "It’s okay to feel this. Let it move through you, not control you.",
116
+ "You don’t owe anyone your silence when something hurts.",
117
+ "You’re not ‘too much’—they’re just not used to boundaries.",
118
+ "Burning bridges? Babe, sometimes it’s called clearing dead weight.",
119
+ "Pop off if you must—but make it poetic and powerful.",
120
+ "Alright, you're feeling a bit blue, huh? Snap out of it... gently, of course."
121
+ ]
122
+ },
123
+ "anxious":{
124
+ "playlists":[
125
+ "https://open.spotify.com/playlist/1r4hnyOWexSvylLokn2hUa?si=581df210bc144a17",
126
+ "https://open.spotify.com/playlist/7JabddFr3Q6JPsND4v9Swf?si=ec9ea7bbab86403b",
127
+ "https://open.spotify.com/playlist/18L9Oembkvoo7ciwrUDGAi?si=ca0bd53022bb4ab3",
128
+ "https://open.spotify.com/playlist/5z5prxfyNclz9U3bE1YIZo?si=41d9c06a714c4707"
129
+ ],
130
+ "memes":[
131
+ "https://www.happierhuman.com/wp-content/uploads/2022/03/memes-anxiety-instagram-what-if-it-does.jpg",
132
+ "https://www.happierhuman.com/wp-content/uploads/2022/03/memes-anxiety-realvitamins-where-do-i-begin.jpg",
133
+ "https://www.happierhuman.com/wp-content/uploads/2022/03/memes-anxiety-realvitamins-panic-attacks-activated.jpg",
134
+ "https://www.happierhuman.com/wp-content/uploads/2022/03/memes-anxiety-realvitamins-mom-do-you-even-know-me.jpg",
135
+ "https://ruinmyweek.com/wp-content/uploads/2020/01/anxiety-memes-2.png",
136
+ "https://starecat.com/content/wp-content/uploads/when-someone-says-dont-be-anxious-and-your-anxiety-is-cured.jpg",
137
+ "https://i.pinimg.com/originals/89/69/b2/8969b2f3ec5fdd0ccaf331262f8287e3.jpg"
138
+
139
+ ],
140
+ "images":[
141
+ "https://www.pixelstalk.net/wp-content/uploads/2016/07/Relaxing-Photos-HD.jpg",
142
+ "https://getwallpapers.com/wallpaper/full/8/8/9/1498083-mind-relaxing-wallpapers-1920x1080-tablet.jpg",
143
+ "https://wallpaperaccess.com/full/3815908.jpg",
144
+ "https://i.pinimg.com/originals/d9/af/a3/d9afa330a7b89865db34e645c86a36ce.jpg",
145
+ "https://blog.uptodown.com/wp-content/uploads/relax-app-android-featured.jpg.webp",
146
+ "https://db5vrvzqvdahe.cloudfront.net/wp-content/uploads/shutterstock_435387934.jpg",
147
+ "https://st2.depositphotos.com/1146092/11636/i/950/depositphotos_116368986-stock-photo-relax-spa-wellness-dog.jpg"
148
+
149
+ ],
150
+ "quotes":[
151
+ "“No need to hurry. No need to sparkle. No need to be anybody but oneself.” — Virginia Woolf",
152
+ " “Anxiety happens when you think you have to figure everything out all at once. Breathe. You’re strong. You got this.” — Karen Salmansohn",
153
+ " “If you want to test your memory, try to recall what you were worrying about one year ago today.” — E. Joseph Cossman",
154
+ " “Feel the fear and do it anyway.” — Susan Jeffers",
155
+ "“Sometimes letting go is the best way to find peace.” — Donna Goddard",
156
+ "It’s okay to not be okay. Just don’t stay that way.",
157
+ "“Breathe. Let go. And remind yourself that this very moment is the only one you know you have for sure.” — Oprah Winfrey",
158
+ "“You don’t have to have it all figured out to move forward.” — Roy T. Bennett"
159
+
160
+ ],
161
+ "self_care":[
162
+ "Dance to your favorite songes",
163
+ "Do something active: go for a walk, go to the gym",
164
+ "Call or text a loved one",
165
+ "Cozy up in your favorite spot",
166
+ "Watch a movie or a tv show",
167
+ "Clean up your bedroom",
168
+
169
+
170
+ ],
171
+ "affirmations":[
172
+ "You are safe in this moment. Breathe through it.",
173
+ "This fear will pass. You’ve survived every wave so far.",
174
+ "You don’t need to fix everything right now. Just be here.",
175
+ "It's okay for your mind to race right now. You are safe.",
176
+ "This feeling of anxiety is temporary, and it will pass.",
177
+ "Worries are just thoughts in fancy, annoying costumes. See 'em, then ignore 'em.",
178
+ "Yeah, your body's on high alert. Tell it to take a coffee break, you've got this.",
179
+ "You've survived worse, trust me. This is just a plot twist, not the grand finale.",
180
+ "So what if you're a mess? Even masterpieces start with a bit of chaos, right?"
181
+
182
+ ]
183
+ },
184
+ "joy":{
185
+ "playlists":[
186
+ "https://open.spotify.com/playlist/37i9dQZF1DXdPec7aLTmlC?si=c1e32eeb15734773",
187
+ "https://open.spotify.com/playlist/37i9dQZF1EIgG2NEOhqsD7?si=6e44ed2babe24541",
188
+ "https://open.spotify.com/playlist/0faAJkECam6JhkR9TLolIQ?si=aacb24457354433b",
189
+ "https://open.spotify.com/playlist/6hXwzaSaiiWUazPjpQn0Yl?si=d4da8cb30cf84d49"
190
+
191
+ ],
192
+ "memes":[
193
+ "https://i.pinimg.com/originals/97/79/88/977988c0c50650833040e74b03b3d148.jpg",
194
+ "https://i.pinimg.com/originals/ba/fb/5d/bafb5de2a3e9b7e7f246e89385b30a6f.jpg",
195
+ "https://img.izismile.com/img/img15/20231218/640/joyful_animal_humor_memes_and_pics_spreading_smiles_640_high_18.jpg",
196
+ "https://www.musicraiser.net/wp-content/uploads/2020/01/31-Joyful-Memes-to-Make-You-Smile-Whole-Day-18-545x495.jpg",
197
+ "https://sayingimages.com/wp-content/uploads/dont-worry-you-got-this-motivational-memes.jpg",
198
+ "https://sayingimages.com/wp-content/uploads/motivational-today-is-the-day-memes.jpg"
199
+
200
+ ],
201
+ "images":[
202
+ "https://www.success.com/wp-content/uploads/legacy/sites/default/files/2_29.jpg",
203
+ "https://3.bp.blogspot.com/-lf1l7-_tVr8/WcDydIUsnUI/AAAAAAAAbZ0/k81Qn_guYlwhrcwDH8aZ7CJ1yvXPnJ0pwCLcBGAs/s1600/You%2Bcome%2Bso%2Bfar2.png",
204
+ "https://sayingimages.com/wp-content/uploads/be-the-best-you-can-be-motivational-memes.jpg",
205
+ "https://sayingimages.com/wp-content/uploads/whos-awesome-youre-awesome-motivational-memes.jpg",
206
+ "https://sayingimages.com/wp-content/uploads/motivational-youre-awesome-memes.jpg.webp"
207
+
208
+
209
+ ],
210
+ "quotes":[
211
+ "“They say a person needs just three things to be truly happy in this world: someone to love, something to do, and something to hope for.”― Tom Bodett",
212
+ "Focus on the journey, not the destination. Joy is found not in finishing an activity but in doing it. - Greg Anderson",
213
+ "If the sight of the blue skies fills you with joy, if a blade of grass springing up in the fields has power to move you, if the simple things of nature have a message that you understand, rejoice, for your soul is alive. - Eleonora Duse",
214
+ "The sun does not shine for a few trees and flowers, but for the wide world's joy. Henry Ward Beecher",
215
+ "Let your joy be in your journey - not in some distant goal. - Tim Cook",
216
+ "“When we are centered in joy, we attain our wisdom.” —Marianne Williamson"
217
+
218
+ ],
219
+ "self_care":[
220
+ "Go watch the sunset",
221
+ "Treat yourself to an amazing dessert",
222
+ "Treat yourself & a friend to coffe at a cute cae",
223
+ "Take yourself out for lunch",
224
+ "Look at the stars",
225
+ "Dance & sing to your favorite song"
226
+
227
+ ],
228
+ "affirmations":[
229
+ "Yeah, you're basically a **joy magnet**. Don't act surprised, you earned it.",
230
+ "Turns out, **happiness looks great on you**. Keep it up, buttercup.",
231
+ "Laughter's your new superpower, and you're wielding it like a **pro**.",
232
+ "**Unapologetically gleeful**, that's you. And honestly? It's a look.",
233
+ "Go on, spread that **contagious cheer**. The world could use a dose of your fabulousness.",
234
+ "You find delight in the simple pleasures and beauty all around you.",
235
+ "You are worthy of abundant joy, and it is your natural state.",
236
+ "Laughter comes easily to you, brightening your day and those around you.",
237
+ "You are alive, vibrant, and bursting with positive energy.",
238
+ "Joy multiplies within you as you share your light with the world."
239
+
240
+
241
+ ]
242
+ },
243
+ "tired":{
244
+ "playlists":[
245
+ "https://open.spotify.com/playlist/37i9dQZF1EIcUQK8Nwn2jv?si=5e7ae3e1dcb745a8",
246
+ "https://open.spotify.com/playlist/4l1BhoNigXILxeQQeBDbvg?si=e1ab5c466bf14eca",
247
+ "https://open.spotify.com/playlist/6rjP6aBpLGgr5odndfARlq?si=d8a4e7ff9d374497",
248
+ "https://open.spotify.com/playlist/7MUhmEs5iduvuWid91mnw6?si=553213fcd7b94638"
249
+
250
+ ],
251
+ "memes":[
252
+ "https://www.digitalmomblog.com/wp-content/uploads/2023/09/funny-tired-meme.jpg.webp",
253
+ "https://www.digitalmomblog.com/wp-content/uploads/2023/09/tired-meme-funny.jpeg.webp",
254
+ "https://inspirationfeed.com/wp-content/uploads/2020/07/Tired-Meme19.jpg",
255
+ "https://inspirationfeed.com/wp-content/uploads/2020/07/Tired-Meme33.jpg",
256
+ "https://piximus.net/media2/55735/tired-memes-10.jpg",
257
+ "https://i.pinimg.com/originals/83/f4/01/83f4016f7e3671275f78b5d7562e19f3.jpg"
258
+
259
+ ],
260
+ "images":[
261
+ "https://quotefancy.com/media/wallpaper/3840x2160/7390377-Carlos-Wallace-Quote-When-you-are-tired-you-rest-You-don-t-give-up.jpg",
262
+ "https://cdn3.careeraddict.com/uploads/article/60864/tips-to-wake-up-infographic.png",
263
+ "https://www.verywellhealth.com/thmb/ZncipGImtDmdZ4xECfzo1dd9y10=/1500x0/filters:no_upscale():max_bytes(150000):strip_icc()/reasons-for-poor-sleep-quality-45881701-52c54387761c4baa9f702e8a5f86b9a7.gif",
264
+ "https://my.clevelandclinic.org/-/scassets/images/org/health/articles/12119-insomnia",
265
+ "https://www.awesomeinventions.com/wp-content/uploads/2016/02/Tired-Just-Tired.jpg"
266
+
267
+
268
+ ],
269
+ "quotes":[
270
+ "You can do anything but not everything - David Allen",
271
+ "Silence doesn't always mean yes. Sometimes, it means, I am tired of explaining to people who don't even care to understand",
272
+ "“Tired minds don’t plan well. Sleep first, plan later.” – Walter Reisch",
273
+ "“Even the darkest night will end and the sun will rise.” – Victor Hugo",
274
+ "“Even heroes need a break.” – Stan Lee",
275
+ "Sometimes I wish I could just press pause and catch my breath."
276
+
277
+ ],
278
+ "self_care":[
279
+ "Take a nap with no alarm",
280
+ "Take something off of your to-do list",
281
+ "Say no to something",
282
+ "Watch your favorite TV show",
283
+ "Use a weighted blanket",
284
+ "Put your phone on Do Not Disturb"
285
+
286
+ ],
287
+ "affirmations":[
288
+ "You're not lazy, you're in **energy-saving mode**. Smart, really.",
289
+ "Operation Recharge is a go! Prepare for maximum horizontal time.",
290
+ "Conquering the world can wait. Your couch, however, cannot.",
291
+ "You're done. D-O-N-E. Now go get that beauty sleep, you earned it.",
292
+ "Rest isn’t lazy—it’s necessary.",
293
+ "You don’t have to do it all. You just have to breathe.",
294
+ "Your body and soul are asking for care. Listen.",
295
+ "It's okay to feel tired. You've done enough for today.",
296
+ "Your body is asking for rest, and you are listening.",
297
+
298
+ ]
299
+
300
+ },
301
+ "numb":{
302
+ "playlists":[
303
+ "https://open.spotify.com/playlist/7DtC8X9lVC5VulFqTZARQA?si=9f533b357b5f4696",
304
+ "https://open.spotify.com/playlist/6kR2MtMOkP0CRZYRbbjLCB?si=dabbb4e18ef94831",
305
+ "https://open.spotify.com/playlist/04hyzNf9DUjOPkI7v7nDoC?si=01fb238ef4a943ef",
306
+ "https://open.spotify.com/playlist/1wU8Bso3aX6ophkPYvETs9?si=28f126326bf94bf0"
307
+
308
+ ],
309
+ "memes":[
310
+ "https://i.imgflip.com/77ft0w.jpg",
311
+ "https://themighty.com/wp-content/uploads/2019/11/via-QuickMeme.jpg",
312
+ "https://themighty.com/wp-content/uploads/2019/11/Quickmemee.jpg",
313
+ "https://i.pinimg.com/originals/82/cb/00/82cb002d89fabe4e2c49fcaf25434eb7.png",
314
+ "https://www.reddit.com/media?url=https%3A%2F%2Fi.redd.it%2F7mjxeq54mzb31.jpg",
315
+ "https://i.pinimg.com/originals/fa/95/94/fa9594debda1e02ca8bb8b84e9f3ec0a.png"
316
+
317
+ ],
318
+ "images":[
319
+ "https://www.maestronews.com/wallpapers/landscape/sunrise/sunrise_10.jpg",
320
+ "https://www.pixelstalk.net/wp-content/uploads/2016/08/Night-Sky-Milky-Way-Galaxy-Wallpaper.jpg",
321
+ "https://www.pixelstalk.net/wp-content/uploads/2016/03/Cute-Animal-Wallpaper-HD-desktop.jpg",
322
+ "https://cdn.pixabay.com/photo/2017/05/18/13/46/rainbow-2323708_1280.jpg",
323
+ "https://www.factinate.com/wp-content/uploads/2018/07/baby-animals.jpg"
324
+
325
+ ],
326
+ "quotes":[
327
+ "“I just let the pain take over, allowing it to numb the pain of being left behind.” ― Jessica Sorensen, The Coincidence of Callie & Kayden",
328
+ "“I’ve perfected the art of the fake smile. It’s not so difficult when you are completely numb.” ― Bethany Griffin, Masque of the Red Death",
329
+ "“I should have been angry, but I was struggling to feel much of anything.” ― Karie Fugett, Alive Day: A Memoir",
330
+ "“Better to feel nothing, to be numb, than to lose control. It's the only way I know to deal with it.” ― Julie Kagawa, The Forever Song",
331
+ "“Some scars don’t hurt. Some scars are numb. Some scars rid you of the capacity to feel anything ever again.” ― Joyce Rachelle",
332
+ "“I thought I’m healing but the truth is, I just stopped feeling.” – C. C. Aurel"
333
+
334
+ ],
335
+ "self_care":[
336
+ "Try 5 minutes of journaling, doesn't need to be perfect, just pour those thoughts somewhere",
337
+ "Give yourself permission to feel exactly how you are feeling",
338
+ "Connect with others at your own pace: have a small conversation with a friend",
339
+ "Rest and don't feel guilty about it",
340
+ "Go for a walk and listen to the sounds around you",
341
+ "Do breathing exercises:Try inhaling for four counts, holding for four, and exhaling for four (the 4-4-4 method) "
342
+
343
+ ],
344
+ "affirmations":[
345
+ "If your heart’s on airplane mode, fine—but don’t crash.",
346
+ "You’re still a whole damn person, even when you feel nothing.",
347
+ "Frozen doesn’t mean gone. You’ll thaw. Slowly. And dramatically.",
348
+ "Okay, emotions took a vacation, huh? Fine, you do you.",
349
+ "Healing is happening, even when it feels like nothing is happening.",
350
+ "You are supported, even if you can't feel it right now.",
351
+ "Be kind to yourself in this space of emotional quiet.",
352
+ "You are whole, even in this moment of numbness."
353
+
354
+ ]
355
+ },
356
+ "confident":{
357
+ "playlists":[
358
+ "https://open.spotify.com/playlist/37i9dQZF1EIhAa4OzjmrFk?si=6a513706c2634f18",
359
+ "https://open.spotify.com/playlist/5QK5DcACsK2r9VzNwSgHl4?si=2a6efce45370425e",
360
+ "https://open.spotify.com/playlist/37i9dQZF1DX4fpCWaHOned?si=ec97e651466c4311",
361
+ "https://open.spotify.com/playlist/2f67AbWKCd2Ry2jkzDejs7?si=5fe719ef827b4d39"
362
+
363
+ ],
364
+ "memes":[
365
+ "https://i.imgflip.com/1ks1mm.jpg",
366
+ "https://imgix.bustle.com/2017/1/17/7ed6d773-dfd1-4fd6-87eb-713114b0102c.jpg?w=414&h=600&fit=crop&crop=faces&auto=format%2Ccompress&q=50&dpr=2",
367
+ "https://i.imgflip.com/1e4msy.jpg",
368
+ "https://i.imgflip.com/1ntulb.jpg",
369
+ "https://i.pinimg.com/originals/bc/2e/65/bc2e653597ba3cdab4dd7dbc40b90b21.jpg",
370
+ "https://sayingimages.com/wp-content/uploads/hold-my-beer-i-got-this-meme.jpeg"
371
+
372
+ ],
373
+ "images":[
374
+ "https://sayingimages.com/wp-content/uploads/motivational-arise-go-forth-and-conquer-memes.jpg",
375
+ "https://cdn.pixabay.com/photo/2015/09/24/06/09/positive-954797_1280.jpg",
376
+ "https://images.huffingtonpost.com/2015-12-04-1449210149-2724155-SelfConfidence.png",
377
+ "https://bethlehemdenver.com/wp-content/uploads/2020/07/FINISH-LINE.jpg",
378
+ "https://cdn.pixabay.com/photo/2024/05/24/12/58/ai-generated-8785023_1280.png"
379
+
380
+ ],
381
+ "quotes":[
382
+ "“Be who you are and say what you feel, because those who mind don't matter, and those who matter don't mind.” ― Bernard M. Baruch",
383
+ "“You probably wouldn’t worry about what people think of you if you could know how seldom they do.” ― Olin Miller",
384
+ "“Do not fear to be eccentric in opinion, for every opinion now accepted was once eccentric.” ― Bertrand Russell",
385
+ "“Believe in your infinite potential. Your only limitations are those you set upon yourself.” ― Roy T. Bennett, The Light in the Heart",
386
+ "“Accept who you are; and revel in it.” ― Mitch Albom, Tuesdays with Morrie: An Old Man, a Young Man, and Life's Greatest Lesson",
387
+ "No matter how old you are now. You are never too young or too old for success or going after what you want."
388
+
389
+ ],
390
+ "self_care":[
391
+ "Surround yourself with positive people",
392
+ "Take care of your body: diet, exercise, meditation",
393
+ "Always be kind to yourself",
394
+ "Practive positive self-talk",
395
+ "Do things you are good at"
396
+
397
+
398
+ ],
399
+ "affirmations":[
400
+ "You’re the whole damn meal. Stop acting like a side dish.",
401
+ "Confidence looks good on you—don’t take it off for anyone.",
402
+ "They should be grateful they even get to witness your glow.",
403
+ "Oh, you thought you couldn't? Cute. Watch you **absolutely crush it**.",
404
+ "You embrace your authentic self, knowing you are enough.",
405
+ "You move through the world with quiet assurance and grace.",
406
+ "Your presence is a gentle power that inspires those around you.",
407
+ "You believe in yourself, and that belief softly guides your way.",
408
+ "You are secure in who you are, finding peace in your own unique journey."
409
+
410
+
411
+ ]
412
+ },
413
+ "hopeful":{
414
+ "playlists":[
415
+ "https://open.spotify.com/playlist/37i9dQZF1EIemCZWVgQTXB?si=a0546c750dff4601",
416
+ "https://open.spotify.com/playlist/77qvKHsd1c9YGbGcnZVNzE?si=09f097151e444c26",
417
+ "https://open.spotify.com/playlist/4ofywy1Z3LbiSTlmSLPR0s?si=585d1d45ce84454b",
418
+ "https://open.spotify.com/playlist/754LgMDMRwGna2RvnfTePc?si=7186e2ecbda546bd"
419
+
420
+ ],
421
+ "memes":[
422
+ "https://sayingimages.com/wp-content/uploads/theres-still-hope-meme-300x300.jpg",
423
+ "https://sayingimages.com/wp-content/uploads/sometimes-you-have-to-tell-yourself-i-am-a-share-and-attack-the-day-hope-meme.jpg",
424
+ "https://sayingimages.com/wp-content/uploads/you-always-have-hope-even-if-theres-not-a-chance-in-hell-meme.jpg",
425
+ "https://i.pinimg.com/originals/46/d9/30/46d9309e7a040b9151531f2a8e87550b.jpg",
426
+ "https://sheideas.com/wp-content/uploads/2018/10/funny-positive-meme-18-585x403.jpg",
427
+ "https://www.kerryjheckman.com/uploads/7/2/8/1/72815985/published/when-someone-understands.jpg?1523282931"
428
+
429
+ ],
430
+ "images":[
431
+ "https://library.neura.edu.au/wp-content/uploads/sites/3/2017/01/Hope.jpg",
432
+ "https://centralofsuccess.com/wp-content/uploads/2018/03/Inspirational-Hope-Quotes.jpg",
433
+ "https://www.thewowstyle.com/wp-content/uploads/2015/01/whe-the-world-says-give-up-hope-whispers-try-it-one-more-time.jpg",
434
+ "https://www.wishesmsg.com/wp-content/uploads/Hope-messages-and-sayings.jpg",
435
+ "https://i.pinimg.com/736x/db/a6/a6/dba6a688a2f2e3053b3b373b75ec3b7a.jpg"
436
+
437
+ ],
438
+ "quotes":[
439
+ "“You may say I'm a dreamer, but I'm not the only one. I hope someday you'll join us. And the world will live as one.”― John Lennon",
440
+ "“I like the night. Without the dark, we'd never see the stars.” ― Stephenie Meyer, Twilight",
441
+ "“If you're reading this... Congratulations, you're alive. If that's not something to smile about, then I don't know what is.” ― Chad Sugg, Monsters Under Your Head",
442
+ "“If pain must come, may it come quickly. Because I have a life to live, and I need to live it in the best way possible. If he has to make a choice, may he make it now. Then I will either wait for him or forget him.” ― Paulo Coelho, By the River Piedra I Sat Down and Wept",
443
+ "“Never lose hope. Storms make people stronger and never last forever.” ― Roy T. Bennett, The Light in the Heart",
444
+ "“It's amazing how a little tomorrow can make up for a whole lot of yesterday.” ― John Guare, Landscape of the Body"
445
+
446
+ ],
447
+ "self_care":[
448
+ "Give yourself compliments",
449
+ "Keep a goal journal",
450
+ "Let loved ones lift you up",
451
+ "Take time out to journal - writing your thoughts and feelings down in one place can be really empowering. It can also help to ‘declutter’ your busy mind",
452
+ "Binge watch your favourite TV show or movies - set time aside to chill and do something you enjoy, whether that’s alone or with someone you love.",
453
+ "Spend time outdoors - choose to re-connect with nature"
454
+
455
+ ],
456
+ "affirmations":[
457
+ "Hope is your quiet rebellion. Keep it alive.",
458
+ "Trust the seeds you’ve planted. Bloom is coming.",
459
+ "You don’t have to know how—it’s okay to just believe.",
460
+ "Even in the quiet, you feel a gentle stirring of possibility.",
461
+ "Still got that fire in your belly? Good. It's leading you somewhere epic.",
462
+ "Don't just hope for it, expect it. You're manifesting greatness, darling.",
463
+ "Your future's looking so bright, you might need shades. Just sayin'.",
464
+ "Time to turn up the optimism. Your vibe is attracting your tribe... and cool opportunities.",
465
+ "Plot twist: everything's about to work out. You saw it here first.",
466
+
467
+ ]
468
+ }
469
+
470
+
471
+
472
+ }
473
+
474
+ classifier = pipeline(task = "text-classification",
475
+ model = model_path,
476
+ device = "cuda" if torch.cuda.is_available() else "cpu",
477
+ top_k = 2,
478
+ batch_size = 32)
479
+
480
+ # Define our function to use with our model
481
+ def mood_text_classifier(text:str):
482
+
483
+ # Outputs from the pipeline
484
+ outputs = classifier(text)[0]
485
+ result = outputs[0]
486
+
487
+ label = result["label"].lower()
488
+ score = result["score"]
489
+
490
+ #Vibe map
491
+ vibe = vibe_map.get(label, {})
492
+ playlist = random.choice(vibe.get("playlists", ["No playlist found"]))
493
+ meme = random.choice(vibe.get("memes", ["No meme found"]))
494
+ image = random.choice(vibe.get("images", ["No image found"]))
495
+ quote = random.choice(vibe.get("quotes", ["No quote found"]))
496
+ self_care = random.choice(vibe.get("self_care", ["No tip found"]))
497
+ affirmation = random.choice(vibe.get("affirmations", ["No affirmation found"]))
498
+
499
+ return{
500
+ "emotion": label,
501
+ "confidence":round(score, 3),
502
+ "playlist": playlist,
503
+ "meme": meme,
504
+ "image": image,
505
+ "quote": quote,
506
+ "self_care": self_care,
507
+ "affirmation": affirmation
508
+
509
+ }
510
+
511
+
512
+ # Create the gradio ChatInterface
513
+ def chatbot_friend(message, history):
514
+ # Find the last assistant prompt that asked "what do you want"
515
+ last_bot_message_content = ""
516
+ for item in reversed(history):
517
+ if item.get("role") == "assistant":
518
+ last_bot_message_content = item.get("content", "").lower()
519
+ break
520
+
521
+ if "do you want" in last_bot_message_content:
522
+ # Find the last user message before the bot's ask
523
+ mood_input_message = None
524
+ for item in reversed(history):
525
+ if item.get("role") == "user":
526
+ mood_input_message = item.get("content")
527
+ break
528
+ if mood_input_message is None:
529
+ mood_input_message = message
530
+
531
+ mood_info = mood_text_classifier(mood_input_message)
532
+ user_choice = message.lower()
533
+ response_lines = []
534
+
535
+ if "playlist" in user_choice:
536
+ response_lines.append(f'Playlist: {mood_info["playlist"]}')
537
+ if "meme" in user_choice:
538
+ response_lines.append(f'Meme: {mood_info["meme"]}')
539
+ if "quote" in user_choice:
540
+ response_lines.append(f'Quote: {mood_info["quote"]}')
541
+ if "self_care" in user_choice:
542
+ response_lines.append(f'Self-care: {mood_info["self_care"]}')
543
+ if "affirmation" in user_choice:
544
+ response_lines.append(f'Affirmation: {mood_info["affirmation"]}')
545
+ if "image" in user_choice:
546
+ response_lines.append(f'Inspirational image: {mood_info["image"]}')
547
+
548
+ if not response_lines:
549
+ response_lines.append(f"Not sure what you wanted, but here's a meme: {mood_info['meme']}")
550
+
551
+ return [{"role": "assistant", "content": "\n".join(response_lines)}]
552
+
553
+ # Restart conversation if user says hi again
554
+ if message.strip().lower() in ["hi", "hello", "hey", "start over"]:
555
+ return [{"role": "assistant", "content": "Hey! How are you *really* feeling today? Tell me everything."}]
556
+
557
+ mood_info = mood_text_classifier(message)
558
+ mood = mood_info['emotion']
559
+ return [{
560
+ "role": "assistant",
561
+ "content": f"Feeling {mood}? I got you. Do you want a playlist, meme, inspirational quote, self-care tip, affirmation, or just a cute image? Type what you need!"
562
+ }]
563
+
564
+
565
+ demo = gr.ChatInterface(
566
+ fn=chatbot_friend,
567
+ title="Your best friend Mood Chatbot",
568
+ description="Vibe check + emotional support with actual conversation",
569
+
570
+ type="messages"
571
+ )
572
+
573
+ # Launch the interface
574
+ if __name__ == "__main__":
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
575
  demo.launch()