DreamStream-1 commited on
Commit
2a2aa69
·
verified ·
1 Parent(s): 51fdaf6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +47 -16
app.py CHANGED
@@ -179,36 +179,67 @@ css = """
179
  background-color: #f7f7f7;
180
  }
181
  .gradio-input, .gradio-output {
182
- font-size: 16px;
 
 
 
183
  }
184
- .gradio-button {
185
- background-color: #FF5733;
186
  color: white;
187
  border-radius: 5px;
188
  }
189
- .gradio-button:hover {
190
- background-color: #C70039;
 
 
 
 
 
 
 
 
 
 
191
  }
192
  """
193
 
194
- # Gradio interface
 
 
 
 
 
 
 
 
 
 
 
 
 
 
195
  iface = gr.Interface(
196
- fn=chatbot,
197
  inputs=[
198
- gr.Textbox(label="Message", placeholder="Type a message...", lines=2),
199
- gr.State()
 
 
200
  ],
201
  outputs=[
202
- gr.Chatbot(label="Chatbot History"),
203
  gr.Textbox(label="Sentiment Analysis"),
204
- gr.Textbox(label="Emotion Detection"),
205
- gr.DataFrame(label="Suggestions Based on Emotion"),
206
- gr.HTML(label="Health Professionals & Map")
 
 
207
  ],
208
- layout="vertical",
209
  live=True,
210
- css=css
 
 
211
  )
212
 
213
- # Launch the Gradio interface
214
  iface.launch(share=True)
 
179
  background-color: #f7f7f7;
180
  }
181
  .gradio-input, .gradio-output {
182
+ padding: 10px;
183
+ border-radius: 5px;
184
+ background-color: #fff;
185
+ border: 1px solid #ccc;
186
  }
187
+ .gradio-container .gradio-button {
188
+ background-color: #4CAF50;
189
  color: white;
190
  border-radius: 5px;
191
  }
192
+ .gradio-container .gradio-button:hover {
193
+ background-color: #45a049;
194
+ }
195
+ .gradio-output {
196
+ font-size: 16px;
197
+ color: #333;
198
+ }
199
+ .gradio-container h3 {
200
+ color: #333;
201
+ }
202
+ .gradio-output .output {
203
+ border-top: 2px solid #ddd;
204
  }
205
  """
206
 
207
+ # Gradio interface components
208
+ def gradio_app(message, current_location, health_professional_query, history):
209
+ # Detect sentiment and emotion
210
+ sentiment = analyze_sentiment(message)
211
+ emotion = detect_emotion(message)
212
+
213
+ # Generate suggestions based on emotion
214
+ suggestions_df = generate_suggestions(emotion)
215
+
216
+ # Get health professionals details and map
217
+ route_info, map_html = get_health_professionals_and_map(current_location, health_professional_query)
218
+
219
+ return sentiment, emotion, suggestions_df, route_info, map_html, history
220
+
221
+ # Gradio interface setup
222
  iface = gr.Interface(
223
+ fn=gradio_app,
224
  inputs=[
225
+ gr.Textbox(lines=2, placeholder="Enter your message..."),
226
+ gr.Textbox(lines=2, placeholder="Enter your current location..."),
227
+ gr.Textbox(lines=2, placeholder="Enter health professional query..."),
228
+ gr.State(value=[])
229
  ],
230
  outputs=[
 
231
  gr.Textbox(label="Sentiment Analysis"),
232
+ gr.Textbox(label="Detected Emotion"),
233
+ gr.Dataframe(label="Suggestions"),
234
+ gr.Textbox(label="Nearby Health Professionals"),
235
+ gr.HTML(label="Map of Health Professionals"),
236
+ gr.State(value=[])
237
  ],
 
238
  live=True,
239
+ allow_flagging="never",
240
+ theme="huggingface",
241
+ css=css # Apply custom CSS styling
242
  )
243
 
244
+ # Launch Gradio interface
245
  iface.launch(share=True)