Spaces:
Paused
Paused
Update tabs/therapy_chat.py
Browse files- tabs/therapy_chat.py +108 -101
tabs/therapy_chat.py
CHANGED
|
@@ -26,119 +26,126 @@ def clear_chat():
|
|
| 26 |
chat_history = []
|
| 27 |
return "", ""
|
| 28 |
|
|
|
|
| 29 |
# UI function
|
| 30 |
def therapy_chat_tab():
|
| 31 |
gr.Markdown("## 🧠 TherapyBot++", elem_classes="centered-text")
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
<div style="
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
position: relative;
|
| 53 |
-
background: linear-gradient(to right, #1c2f3a 0%, #000000 50%, #1c2f3a 100%);
|
| 54 |
-
border-radius: 12px;
|
| 55 |
-
box-shadow: 0 2px 12px rgba(0,0,0,0.4);
|
| 56 |
-
text-align: center;
|
| 57 |
-
padding: 16px 24px;
|
| 58 |
-
box-sizing: border-box;
|
| 59 |
">
|
| 60 |
-
<
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
<div
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
<div>🦴 More than half your bones are located in your hands and feet.</div>
|
| 102 |
-
<div>🧘 Just 10 minutes of mindful breathing can reset your brain chemistry.</div>
|
| 103 |
-
<div>❓ Most therapy breakthroughs come from better questions — not quick answers.</div>
|
| 104 |
-
<div>😂 Laughter releases feel-good hormones and even helps reduce pain.</div>
|
| 105 |
-
<div>🫀 Your heart weighs around 7 to 15 ounces depending on your body.</div>
|
| 106 |
-
<div>🏃 The heart works harder than a sprinter's leg muscles — nonstop effort.</div>
|
| 107 |
-
<div>🧠 Emotional pain activates the same brain region as physical pain.</div>
|
| 108 |
-
<div>🍌 Bananas can naturally boost your mood by increasing serotonin levels.</div>
|
| 109 |
-
</div>
|
| 110 |
</div>
|
| 111 |
</div>
|
| 112 |
</div>
|
| 113 |
-
|
|
|
|
| 114 |
.chatbot-scroll .chatbot-content {
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
}
|
| 120 |
.scroll-wrapper {
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
}
|
| 125 |
.scroll-inner {
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
}
|
| 133 |
@keyframes chatbot-scroll-vertical {
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
}
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
|
|
|
| 26 |
chat_history = []
|
| 27 |
return "", ""
|
| 28 |
|
| 29 |
+
# UI function
|
| 30 |
# UI function
|
| 31 |
def therapy_chat_tab():
|
| 32 |
gr.Markdown("## 🧠 TherapyBot++", elem_classes="centered-text")
|
| 33 |
+
gr.Markdown(
|
| 34 |
+
"Thoughtfully designed to be your safe and supportive space — here for you when your mind needs it the most.",
|
| 35 |
+
elem_classes="centered-text"
|
| 36 |
+
)
|
| 37 |
+
|
| 38 |
+
with gr.Row():
|
| 39 |
+
with gr.Column():
|
| 40 |
+
user_input = gr.Textbox(placeholder="How are you feeling?", label="🗣 Your Message", lines=8)
|
| 41 |
+
submit_btn = gr.Button("Submit", elem_id="submit-btn")
|
| 42 |
+
clear_btn = gr.Button("Clear")
|
| 43 |
+
with gr.Column():
|
| 44 |
+
with gr.Accordion("📜 Chat History", open=True):
|
| 45 |
+
chat_display = gr.Textbox(label=None, interactive=False, lines=13.8, container=False)
|
| 46 |
+
|
| 47 |
+
submit_btn.click(respond, user_input, outputs=[user_input, chat_display])
|
| 48 |
+
clear_btn.click(clear_chat, outputs=[user_input, chat_display])
|
| 49 |
+
|
| 50 |
+
gr.Markdown(
|
| 51 |
+
"""
|
| 52 |
+
<div style="
|
| 53 |
+
height: auto;
|
| 54 |
+
min-height: 100px;
|
| 55 |
+
width: 100%;
|
| 56 |
+
max-width: 65%;
|
| 57 |
+
margin: 15px auto;
|
| 58 |
+
overflow: hidden;
|
| 59 |
+
position: relative;
|
| 60 |
+
background: linear-gradient(to right, #1c2f3a 0%, #000000 50%, #1c2f3a 100%);
|
| 61 |
+
border-radius: 12px;
|
| 62 |
+
box-shadow: 0 2px 12px rgba(0,0,0,0.4);
|
| 63 |
+
text-align: center;
|
| 64 |
+
padding: 16px 24px;
|
| 65 |
+
box-sizing: border-box;
|
| 66 |
+
">
|
| 67 |
<div style="
|
| 68 |
+
font-size: 15px;
|
| 69 |
+
color: #e0e0e0;
|
| 70 |
+
font-weight: 600;
|
| 71 |
+
margin-bottom: 14px;
|
| 72 |
+
position: relative;
|
| 73 |
+
z-index: 2;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
">
|
| 75 |
+
🧠 <em>Here are some surprising and helpful wellness facts:</em>
|
| 76 |
+
</div>
|
| 77 |
+
<div class="scroll-wrapper chatbot-scroll">
|
| 78 |
+
<div class="scroll-content chatbot-content">
|
| 79 |
+
<div class="scroll-inner">
|
| 80 |
+
<div>-----</div>
|
| 81 |
+
<div>🧠 Talking to someone about your emotions can significantly lower stress levels.</div>
|
| 82 |
+
<div>👃 The average human nose can identify over 50,000 different smells.</div>
|
| 83 |
+
<div>😶🌫️ Suppressing emotions doesn’t erase them — they return stronger later.</div>
|
| 84 |
+
<div>🧠 Your brain remains plastic at any age — emotional healing is always possible.</div>
|
| 85 |
+
<div>🍋 Lemons are among the healthiest fruits, rich in antioxidants and immune support.</div>
|
| 86 |
+
<div>🛏️ Sleep affects nearly every system in the body — it’s your natural mental reset.</div>
|
| 87 |
+
<div>🔁 Replaying negative thoughts rewires your brain for anxiety — called cognitive looping.</div>
|
| 88 |
+
<div>🍵 Drinking a warm beverage may help your body feel cooler and more relaxed.</div>
|
| 89 |
+
<div>👶 Newborns have the fastest heartbeats of any human age group.</div>
|
| 90 |
+
<div>🦶 Your feet can reveal early signs of deeper health issues like diabetes or stress.</div>
|
| 91 |
+
<div>👫 Companionship and bonding are great for both your heart and brain health.</div>
|
| 92 |
+
<div>👂 The brain releases calming chemicals when it feels truly listened to.</div>
|
| 93 |
+
<div>🌞 Optimistic thinking can add years to your life by reducing stress.</div>
|
| 94 |
+
<div>❄️ Cold weather can boost metabolism and strengthen your immune system.</div>
|
| 95 |
+
<div>👁️ You can physically see signs of high cholesterol in your eyes and skin.</div>
|
| 96 |
+
<div>🎨 Creative activities like drawing or music reduce anxiety and boost cognition.</div>
|
| 97 |
+
<div>🧬 Trauma can be inherited — emotions may echo generations before you.</div>
|
| 98 |
+
<div>😢 Humans are the only animals who cry due to emotional reasons.</div>
|
| 99 |
+
<div>📵 Limiting screen time improves focus, clarity, and emotional regulation.</div>
|
| 100 |
+
<div>💓 Your heart beats over 100,000 times a day to keep you alive and well.</div>
|
| 101 |
+
<div>☕ Drinking coffee may reduce symptoms of depression and lift your mood.</div>
|
| 102 |
+
<div>💧 You can lose 3% body weight in fluids before even feeling thirsty.</div>
|
| 103 |
+
<div>📆 Heart attacks are most frequent on Monday mornings due to work stress.</div>
|
| 104 |
+
<div>🐶 A dog’s companionship may lower blood pressure and protect your heart.</div>
|
| 105 |
+
<div>🩸 The heart pumps nearly 2,000 gallons of blood every day.</div>
|
| 106 |
+
<div>😣 Chronic stress increases your risk of type 2 diabetes.</div>
|
| 107 |
+
<div>🩻 Some capillaries are ten times thinner than a strand of hair.</div>
|
| 108 |
+
<div>🦴 More than half your bones are located in your hands and feet.</div>
|
| 109 |
+
<div>🧘 Just 10 minutes of mindful breathing can reset your brain chemistry.</div>
|
| 110 |
+
<div>❓ Most therapy breakthroughs come from better questions — not quick answers.</div>
|
| 111 |
+
<div>😂 Laughter releases feel-good hormones and even helps reduce pain.</div>
|
| 112 |
+
<div>🫀 Your heart weighs around 7 to 15 ounces depending on your body.</div>
|
| 113 |
+
<div>🏃 The heart works harder than a sprinter's leg muscles — nonstop effort.</div>
|
| 114 |
+
<div>🧠 Emotional pain activates the same brain region as physical pain.</div>
|
| 115 |
+
<div>🍌 Bananas can naturally boost your mood by increasing serotonin levels.</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
</div>
|
| 117 |
</div>
|
| 118 |
</div>
|
| 119 |
+
</div>
|
| 120 |
+
<style>
|
| 121 |
.chatbot-scroll .chatbot-content {
|
| 122 |
+
position: absolute;
|
| 123 |
+
width: 100%;
|
| 124 |
+
animation: chatbot-scroll-vertical 130s linear infinite;
|
| 125 |
+
will-change: transform;
|
| 126 |
}
|
| 127 |
.scroll-wrapper {
|
| 128 |
+
height: 50px;
|
| 129 |
+
overflow: hidden;
|
| 130 |
+
position: relative;
|
| 131 |
+
}
|
| 132 |
.scroll-inner {
|
| 133 |
+
display: flex;
|
| 134 |
+
flex-direction: column;
|
| 135 |
+
gap: 20px;
|
| 136 |
+
color: #bbbbbb;
|
| 137 |
+
font-size: 13.8px;
|
| 138 |
+
line-height: 1.5;
|
| 139 |
}
|
| 140 |
@keyframes chatbot-scroll-vertical {
|
| 141 |
+
0% {
|
| 142 |
+
transform: translateY(0);
|
| 143 |
+
}
|
| 144 |
+
100% {
|
| 145 |
+
transform: translateY(-50%);
|
| 146 |
+
}
|
| 147 |
}
|
| 148 |
+
</style>
|
| 149 |
+
""",
|
| 150 |
+
elem_classes="centered-text"
|
| 151 |
+
)
|