Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -103,41 +103,41 @@ def generate_suggestions(emotion):
|
|
| 103 |
emotion_key = emotion.lower()
|
| 104 |
suggestions = {
|
| 105 |
"joy": [
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
],
|
| 111 |
"anger": [
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
],
|
| 117 |
"fear": [
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
],
|
| 123 |
"sadness": [
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
],
|
| 128 |
"surprise": [
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
],
|
| 133 |
}
|
| 134 |
-
return suggestions.get(emotion_key, [
|
| 135 |
|
| 136 |
def get_health_professionals_and_map(location, query):
|
| 137 |
"""Search nearby healthcare professionals using Google Maps API."""
|
| 138 |
try:
|
| 139 |
if not location or not query:
|
| 140 |
-
return ["
|
| 141 |
|
| 142 |
geo_location = gmaps.geocode(location)
|
| 143 |
if geo_location:
|
|
@@ -158,7 +158,7 @@ def get_health_professionals_and_map(location, query):
|
|
| 158 |
|
| 159 |
return [], "" # Return empty list if no professionals found
|
| 160 |
except Exception as e:
|
| 161 |
-
return [
|
| 162 |
|
| 163 |
# Main Application Logic
|
| 164 |
def app_function(user_input, location, query, history):
|
|
@@ -224,16 +224,16 @@ textarea:hover, input:hover {
|
|
| 224 |
}
|
| 225 |
|
| 226 |
#suggestions-title {
|
| 227 |
-
text-align: center;
|
| 228 |
-
font-weight: bold;
|
| 229 |
-
color: white;
|
| 230 |
-
font-size: 4.2rem;
|
| 231 |
-
margin-bottom: 20px;
|
| 232 |
}
|
| 233 |
|
| 234 |
/* Style for the submit button */
|
| 235 |
.gr-button {
|
| 236 |
-
background-color: #ae1c93;
|
| 237 |
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.06);
|
| 238 |
transition: background-color 0.3s ease;
|
| 239 |
}
|
|
@@ -254,7 +254,7 @@ with gr.Blocks(css=custom_css) as app:
|
|
| 254 |
user_input = gr.Textbox(label="Please Enter Your Message Here")
|
| 255 |
location = gr.Textbox(label="Please Enter Your Current Location Here")
|
| 256 |
query = gr.Textbox(label="Please Enter Which Health Professional You Want To Search Nearby")
|
| 257 |
-
|
| 258 |
submit = gr.Button(value="Submit", variant="primary")
|
| 259 |
|
| 260 |
chatbot = gr.Chatbot(label="Chat History")
|
|
@@ -265,7 +265,7 @@ with gr.Blocks(css=custom_css) as app:
|
|
| 265 |
gr.Markdown("Suggestions", elem_id="suggestions-title")
|
| 266 |
|
| 267 |
suggestions = gr.DataFrame(headers=["Title", "Link"]) # Table for suggestions
|
| 268 |
-
professionals = gr.DataFrame(label="Nearby Health Professionals", headers=["Name", "Address"]) #
|
| 269 |
map_html = gr.HTML(label="Interactive Map")
|
| 270 |
|
| 271 |
submit.click(
|
|
|
|
| 103 |
emotion_key = emotion.lower()
|
| 104 |
suggestions = {
|
| 105 |
"joy": [
|
| 106 |
+
{"Title": "Relaxation Techniques", "Link": "https://www.helpguide.org/mental-health/meditation/mindful-breathing-meditation"},
|
| 107 |
+
{"Title": "Dealing with Stress", "Link": "https://www.helpguide.org/mental-health/anxiety/tips-for-dealing-with-anxiety"},
|
| 108 |
+
{"Title": "Emotional Wellness Toolkit", "Link": "https://www.nih.gov/health-information/emotional-wellness-toolkit"},
|
| 109 |
+
{"Title": "Relaxation Video", "Link": "https://youtu.be/m1vaUGtyo-A"},
|
| 110 |
],
|
| 111 |
"anger": [
|
| 112 |
+
{"Title": "Emotional Wellness Toolkit", "Link": "https://www.nih.gov/health-information/emotional-wellness-toolkit"},
|
| 113 |
+
{"Title": "Stress Management Tips", "Link": "https://www.health.harvard.edu/health-a-to-z"},
|
| 114 |
+
{"Title": "Dealing with Anger", "Link": "https://www.helpguide.org/mental-health/anxiety/tips-for-dealing-with-anxiety"},
|
| 115 |
+
{"Title": "Relaxation Video", "Link": "https://youtu.be/MIc299Flibs"},
|
| 116 |
],
|
| 117 |
"fear": [
|
| 118 |
+
{"Title": "Mindfulness Practices", "Link": "https://www.helpguide.org/mental-health/meditation/mindful-breathing-meditation"},
|
| 119 |
+
{"Title": "Coping with Anxiety", "Link": "https://www.helpguide.org/mental-health/anxiety/tips-for-dealing-with-anxiety"},
|
| 120 |
+
{"Title": "Emotional Wellness Toolkit", "Link": "https://www.nih.gov/health-information/emotional-wellness-toolkit"},
|
| 121 |
+
{"Title": "Relaxation Video", "Link": "https://youtu.be/yGKKz185M5o"},
|
| 122 |
],
|
| 123 |
"sadness": [
|
| 124 |
+
{"Title": "Emotional Wellness Toolkit", "Link": "https://www.nih.gov/health-information/emotional-wellness-toolkit"},
|
| 125 |
+
{"Title": "Dealing with Anxiety", "Link": "https://www.helpguide.org/mental-health/anxiety/tips-for-dealing-with-anxiety"},
|
| 126 |
+
{"Title": "Relaxation Video", "Link": "https://youtu.be/-e-4Kx5px_I"},
|
| 127 |
],
|
| 128 |
"surprise": [
|
| 129 |
+
{"Title": "Managing Stress", "Link": "https://www.health.harvard.edu/health-a-to-z"},
|
| 130 |
+
{"Title": "Coping Strategies", "Link": "https://www.helpguide.org/mental-health/anxiety/tips-for-dealing-with-anxiety"},
|
| 131 |
+
{"Title": "Relaxation Video", "Link": "https://youtu.be/m1vaUGtyo-A"},
|
| 132 |
],
|
| 133 |
}
|
| 134 |
+
return suggestions.get(emotion_key, [{"Title": "No specific suggestions available.", "Link": "#"}])
|
| 135 |
|
| 136 |
def get_health_professionals_and_map(location, query):
|
| 137 |
"""Search nearby healthcare professionals using Google Maps API."""
|
| 138 |
try:
|
| 139 |
if not location or not query:
|
| 140 |
+
return [], "" # Return empty list if inputs are missing
|
| 141 |
|
| 142 |
geo_location = gmaps.geocode(location)
|
| 143 |
if geo_location:
|
|
|
|
| 158 |
|
| 159 |
return [], "" # Return empty list if no professionals found
|
| 160 |
except Exception as e:
|
| 161 |
+
return [], "" # Return empty list on exception
|
| 162 |
|
| 163 |
# Main Application Logic
|
| 164 |
def app_function(user_input, location, query, history):
|
|
|
|
| 224 |
}
|
| 225 |
|
| 226 |
#suggestions-title {
|
| 227 |
+
text-align: center !important; /* Ensure the centering is applied */
|
| 228 |
+
font-weight: bold !important; /* Ensure bold is applied */
|
| 229 |
+
color: white !important; /* Ensure color is applied */
|
| 230 |
+
font-size: 4.2rem !important; /* Ensure font size is applied */
|
| 231 |
+
margin-bottom: 20px !important; /* Ensure margin is applied */
|
| 232 |
}
|
| 233 |
|
| 234 |
/* Style for the submit button */
|
| 235 |
.gr-button {
|
| 236 |
+
background-color: #ae1c93; /* Set the background color to #ae1c93 */
|
| 237 |
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.06);
|
| 238 |
transition: background-color 0.3s ease;
|
| 239 |
}
|
|
|
|
| 254 |
user_input = gr.Textbox(label="Please Enter Your Message Here")
|
| 255 |
location = gr.Textbox(label="Please Enter Your Current Location Here")
|
| 256 |
query = gr.Textbox(label="Please Enter Which Health Professional You Want To Search Nearby")
|
| 257 |
+
|
| 258 |
submit = gr.Button(value="Submit", variant="primary")
|
| 259 |
|
| 260 |
chatbot = gr.Chatbot(label="Chat History")
|
|
|
|
| 265 |
gr.Markdown("Suggestions", elem_id="suggestions-title")
|
| 266 |
|
| 267 |
suggestions = gr.DataFrame(headers=["Title", "Link"]) # Table for suggestions
|
| 268 |
+
professionals = gr.DataFrame(label="Nearby Health Professionals", headers=["Name", "Address"]) # Changed to DataFrame
|
| 269 |
map_html = gr.HTML(label="Interactive Map")
|
| 270 |
|
| 271 |
submit.click(
|