Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -159,41 +159,41 @@ def generate_suggestions(emotion):
|
|
159 |
emotion_key = emotion.lower()
|
160 |
suggestions = {
|
161 |
"joy": [
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
],
|
167 |
"anger": [
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
],
|
173 |
"fear": [
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
],
|
179 |
"sadness": [
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
],
|
184 |
"surprise": [
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
],
|
189 |
}
|
190 |
|
191 |
-
#
|
192 |
formatted_suggestions = [
|
193 |
-
|
194 |
]
|
195 |
|
196 |
-
return formatted_suggestions
|
197 |
|
198 |
def get_health_professionals_and_map(location, query):
|
199 |
"""Search nearby healthcare professionals using Google Maps API."""
|
@@ -258,16 +258,14 @@ with gr.Blocks() as app:
|
|
258 |
sentiment = gr.Textbox(label="Detected Sentiment")
|
259 |
emotion = gr.Textbox(label="Detected Emotion")
|
260 |
|
261 |
-
gr.Markdown("Suggestions"
|
262 |
-
|
263 |
-
suggestions = gr.DataFrame(headers=["Title", "Link"])
|
264 |
professionals = gr.DataFrame(label="Nearby Health Professionals", headers=["Name", "Address"])
|
265 |
map_html = gr.HTML(label="Interactive Map")
|
266 |
|
267 |
submit_chatbot.click(
|
268 |
app_function_chatbot,
|
269 |
inputs=[user_input, location, query, chatbot],
|
270 |
-
outputs=[chatbot, sentiment, emotion,
|
271 |
)
|
272 |
|
273 |
with gr.Tab("Disease Prediction"):
|
|
|
159 |
emotion_key = emotion.lower()
|
160 |
suggestions = {
|
161 |
"joy": [
|
162 |
+
("Mindfulness Practices", "https://www.helpguide.org/mental-health/meditation/mindful-breathing-meditation"),
|
163 |
+
("Coping with Anxiety", "https://www.helpguide.org/mental-health/anxiety/tips-for-dealing-with-anxiety"),
|
164 |
+
("Emotional Wellness Toolkit", "https://www.nih.gov/health-information/emotional-wellness-toolkit"),
|
165 |
+
("Relaxation Video", "https://youtu.be/yGKKz185M5o"),
|
166 |
],
|
167 |
"anger": [
|
168 |
+
("Emotional Wellness Toolkit", "https://www.nih.gov/health-information/emotional-wellness-toolkit"),
|
169 |
+
("Stress Management Tips", "https://www.health.harvard.edu/health-a-to-z"),
|
170 |
+
("Dealing with Anger", "https://www.helpguide.org/mental-health/anxiety/tips-for-dealing-with-anxiety"),
|
171 |
+
("Relaxation Video", "https://youtu.be/MIc299Flibs"),
|
172 |
],
|
173 |
"fear": [
|
174 |
+
("Mindfulness Practices", "https://www.helpguide.org/mental-health/meditation/mindful-breathing-meditation"),
|
175 |
+
("Coping with Anxiety", "https://www.helpguide.org/mental-health/anxiety/tips-for-dealing-with-anxiety"),
|
176 |
+
("Emotional Wellness Toolkit", "https://www.nih.gov/health-information/emotional-wellness-toolkit"),
|
177 |
+
("Relaxation Video", "https://youtu.be/yGKKz185M5o"),
|
178 |
],
|
179 |
"sadness": [
|
180 |
+
("Emotional Wellness Toolkit", "https://www.nih.gov/health-information/emotional-wellness-toolkit"),
|
181 |
+
("Dealing with Anxiety", "https://www.helpguide.org/mental-health/anxiety/tips-for-dealing-with-anxiety"),
|
182 |
+
("Relaxation Video", "https://youtu.be/-e-4Kx5px_I"),
|
183 |
],
|
184 |
"surprise": [
|
185 |
+
("Managing Stress", "https://www.health.harvard.edu/health-a-to-z"),
|
186 |
+
("Coping Strategies", "https://www.helpguide.org/mental-health/anxiety/tips-for-dealing-with-anxiety"),
|
187 |
+
("Relaxation Video", "https://youtu.be/m1vaUGtyo-A"),
|
188 |
],
|
189 |
}
|
190 |
|
191 |
+
# Create a markdown string for clickable suggestions
|
192 |
formatted_suggestions = [
|
193 |
+
f"- [{title}]({link})" for title, link in suggestions.get(emotion_key, [("No specific suggestions available.", "#")])
|
194 |
]
|
195 |
|
196 |
+
return "\n".join(formatted_suggestions)
|
197 |
|
198 |
def get_health_professionals_and_map(location, query):
|
199 |
"""Search nearby healthcare professionals using Google Maps API."""
|
|
|
258 |
sentiment = gr.Textbox(label="Detected Sentiment")
|
259 |
emotion = gr.Textbox(label="Detected Emotion")
|
260 |
|
261 |
+
suggestions_markdown = gr.Markdown(label="Suggestions") # Use Markdown to display clickable links
|
|
|
|
|
262 |
professionals = gr.DataFrame(label="Nearby Health Professionals", headers=["Name", "Address"])
|
263 |
map_html = gr.HTML(label="Interactive Map")
|
264 |
|
265 |
submit_chatbot.click(
|
266 |
app_function_chatbot,
|
267 |
inputs=[user_input, location, query, chatbot],
|
268 |
+
outputs=[chatbot, sentiment, emotion, suggestions_markdown, professionals, map_html],
|
269 |
)
|
270 |
|
271 |
with gr.Tab("Disease Prediction"):
|