DreamStream-1 commited on
Commit
fc18b37
·
verified ·
1 Parent(s): c784304

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +44 -67
app.py CHANGED
@@ -157,7 +157,7 @@ def get_health_professionals_and_map(location, query):
157
  except Exception as e:
158
  return [f"An error occurred: {e}"], ""
159
 
160
- # Main Application Functionality
161
  def app_function(user_input, location, query, history):
162
  chatbot_history, _ = generate_chatbot_response(user_input, history)
163
  sentiment_result = analyze_sentiment(user_input)
@@ -173,84 +173,61 @@ body {
173
  background: linear-gradient(135deg, #0d0d0d, #ff5722);
174
  color: white;
175
  }
176
-
177
  h1 {
178
- background: #ffffff;
179
- color: #000000;
180
- border-radius: 8px;
181
- padding: 10px;
182
- font-weight: bold;
183
  text-align: center;
184
- font-size: 2.5rem;
185
- }
186
-
187
- textarea, input {
188
- background: transparent;
189
- color: black;
190
- border: 2px solid orange;
191
- padding: 8px;
192
- font-size: 1rem;
193
- caret-color: black;
194
- outline: none;
195
- border-radius: 8px;
196
- }
197
-
198
- textarea:focus, input:focus {
199
- background: transparent;
200
- color: black;
201
- border: 2px solid orange;
202
- outline: none;
203
- }
204
-
205
- textarea:hover, input:hover {
206
- background: transparent;
207
- color: black;
208
- border: 2px solid orange;
209
  }
210
-
211
- .df-container {
212
- background: white;
213
- color: black;
214
- border: 2px solid orange;
215
- border-radius: 10px;
 
 
216
  padding: 10px;
217
- font-size: 14px;
218
- max-height: 400px;
219
- overflow-y: auto;
220
  }
221
-
222
- #suggestions-title {
223
- text-align: center;
224
- font-weight: bold;
225
- color: white; /* Text in white */
226
- font-size: 3rem; /* Bigger size for suggestions */
227
- margin-bottom: 20px;
 
 
 
 
228
  }
229
  """
230
 
231
- # Gradio App
232
  with gr.Blocks(css=custom_css) as app:
233
- gr.HTML("<h1>🌟 Well-Being Companion</h1>")
234
  with gr.Row():
235
- user_input = gr.Textbox(label="Your Message")
236
- location = gr.Textbox(label="Your Location")
237
- query = gr.Textbox(label="Search Query")
238
- chatbot = gr.Chatbot(label="Chat History")
239
- sentiment = gr.Textbox(label="Detected Sentiment")
240
- emotion = gr.Textbox(label="Detected Emotion")
241
 
242
- # Suggestions Title
243
- gr.Markdown("Suggestions", elem_id="suggestions-title")
 
 
244
 
245
- suggestions = gr.DataFrame(headers=["Title", "Link"]) # Table for suggestions
246
- professionals = gr.Textbox(label="Nearby Professionals", lines=6)
247
- map_html = gr.HTML(label="Interactive Map")
248
- submit = gr.Button(value="Submit", variant="primary")
249
-
250
- submit.click(
 
 
 
251
  app_function,
252
- inputs=[user_input, location, query, chatbot],
253
- outputs=[chatbot, sentiment, emotion, suggestions, professionals, map_html],
254
  )
255
 
256
- app.launch()
 
 
157
  except Exception as e:
158
  return [f"An error occurred: {e}"], ""
159
 
160
+ # Main Application Logic
161
  def app_function(user_input, location, query, history):
162
  chatbot_history, _ = generate_chatbot_response(user_input, history)
163
  sentiment_result = analyze_sentiment(user_input)
 
173
  background: linear-gradient(135deg, #0d0d0d, #ff5722);
174
  color: white;
175
  }
 
176
  h1 {
 
 
 
 
 
177
  text-align: center;
178
+ color: white;
179
+ font-size: 36px;
180
+ font-weight: bold;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
181
  }
182
+ textarea {
183
+ width: 100%;
184
+ height: 150px;
185
+ background-color: #333333;
186
+ color: white;
187
+ border: 1px solid #ff5722;
188
+ border-radius: 5px;
189
+ font-size: 16px;
190
  padding: 10px;
 
 
 
191
  }
192
+ button {
193
+ background-color: #ff5722;
194
+ color: white;
195
+ font-size: 16px;
196
+ padding: 10px 20px;
197
+ border-radius: 5px;
198
+ border: none;
199
+ cursor: pointer;
200
+ }
201
+ button:hover {
202
+ background-color: #e64a19;
203
  }
204
  """
205
 
206
+ # Gradio Interface Setup
207
  with gr.Blocks(css=custom_css) as app:
208
+ gr.Markdown("# 🌟 Mental Health Chatbot App")
209
  with gr.Row():
210
+ chatbot_output = gr.Chatbot(label="Chat History", elem_id="chatbox")
211
+ user_input = gr.Textbox(label="Your Message", placeholder="Type something...", interactive=True)
 
 
 
 
212
 
213
+ gr.Markdown("### Sentiment, Emotion, and Suggestions")
214
+ sentiment_output = gr.Textbox(label="Sentiment Analysis")
215
+ emotion_output = gr.Textbox(label="Emotion Detected")
216
+ suggestions_output = gr.DataFrame(headers=["Title", "Link"], label="Suggestions")
217
 
218
+ gr.Markdown("### Locate Health Professionals (Optional)")
219
+ location_input = gr.Textbox(label="Your Location")
220
+ query_input = gr.Textbox(label="Query (e.g., therapist, clinic)", placeholder="Type something...", interactive=True)
221
+
222
+ professionals_output = gr.DataFrame(headers=["Professional", "Address"], label="Nearby Professionals")
223
+ map_output = gr.HTML(label="Map of Professionals")
224
+
225
+ submit_button = gr.Button(value="Submit", elem_id="submit-btn")
226
+ submit_button.click(
227
  app_function,
228
+ inputs=[user_input, location_input, query_input, chatbot_output],
229
+ outputs=[chatbot_output, sentiment_output, emotion_output, suggestions_output, professionals_output, map_output]
230
  )
231
 
232
+ # Run the App
233
+ app.launch(share=True)