DreamStream-1 commited on
Commit
6c32a43
·
verified ·
1 Parent(s): a2919e9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -29
app.py CHANGED
@@ -103,41 +103,41 @@ def generate_suggestions(emotion):
103
  emotion_key = emotion.lower()
104
  suggestions = {
105
  "joy": [
106
- ["Relaxation Techniques", '<a href="https://www.helpguide.org/mental-health/meditation/mindful-breathing-meditation" target="_blank">Visit</a>'],
107
- ["Dealing with Stress", '<a href="https://www.helpguide.org/mental-health/anxiety/tips-for-dealing-with-anxiety" target="_blank">Visit</a>'],
108
- ["Emotional Wellness Toolkit", '<a href="https://www.nih.gov/health-information/emotional-wellness-toolkit" target="_blank">Visit</a>'],
109
- ["Relaxation Video", '<a href="https://youtu.be/m1vaUGtyo-A" target="_blank">Watch</a>'],
110
  ],
111
  "anger": [
112
- ["Emotional Wellness Toolkit", '<a href="https://www.nih.gov/health-information/emotional-wellness-toolkit" target="_blank">Visit</a>'],
113
- ["Stress Management Tips", '<a href="https://www.health.harvard.edu/health-a-to-z" target="_blank">Visit</a>'],
114
- ["Dealing with Anger", '<a href="https://www.helpguide.org/mental-health/anxiety/tips-for-dealing-with-anxiety" target="_blank">Visit</a>'],
115
- ["Relaxation Video", '<a href="https://youtu.be/MIc299Flibs" target="_blank">Watch</a>'],
116
  ],
117
  "fear": [
118
- ["Mindfulness Practices", '<a href="https://www.helpguide.org/mental-health/meditation/mindful-breathing-meditation" target="_blank">Visit</a>'],
119
- ["Coping with Anxiety", '<a href="https://www.helpguide.org/mental-health/anxiety/tips-for-dealing-with-anxiety" target="_blank">Visit</a>'],
120
- ["Emotional Wellness Toolkit", '<a href="https://www.nih.gov/health-information/emotional-wellness-toolkit" target="_blank">Visit</a>'],
121
- ["Relaxation Video", '<a href="https://youtu.be/yGKKz185M5o" target="_blank">Watch</a>'],
122
  ],
123
  "sadness": [
124
- ["Emotional Wellness Toolkit", '<a href="https://www.nih.gov/health-information/emotional-wellness-toolkit" target="_blank">Visit</a>'],
125
- ["Dealing with Anxiety", '<a href="https://www.helpguide.org/mental-health/anxiety/tips-for-dealing-with-anxiety" target="_blank">Visit</a>'],
126
- ["Relaxation Video", '<a href="https://youtu.be/-e-4Kx5px_I" target="_blank">Watch</a>'],
127
  ],
128
  "surprise": [
129
- ["Managing Stress", '<a href="https://www.health.harvard.edu/health-a-to-z" target="_blank">Visit</a>'],
130
- ["Coping Strategies", '<a href="https://www.helpguide.org/mental-health/anxiety/tips-for-dealing-with-anxiety" target="_blank">Visit</a>'],
131
- ["Relaxation Video", '<a href="https://youtu.be/m1vaUGtyo-A" target="_blank">Watch</a>'],
132
  ],
133
  }
134
- return suggestions.get(emotion_key, [["No specific suggestions available.", ""]])
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 ["Please provide both location and query."], ""
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 [f"An error occurred: {e}"], ""
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"]) # Change to DataFrame for professionals
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(