DreamStream-1 commited on
Commit
cc23a29
·
verified ·
1 Parent(s): b0e9702

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -18
app.py CHANGED
@@ -258,26 +258,9 @@ def predict_disease(symptoms):
258
  return "\n".join(markdown_output)
259
 
260
  # Gradio Application Interface
261
- with gr.Blocks(theme='shivi/calm_seafoam') as app: # Set theme here
262
  gr.HTML("<h1>🌟 Well-Being Companion</h1>")
263
 
264
- # Theme Dropdown
265
- themes = [
266
- "calm_seafoam",
267
- "Ranko_test"
268
- ]
269
-
270
- theme_dropdown = gr.Dropdown(choices=themes, label="Select Theme")
271
-
272
- # Button to toggle dark mode
273
- toggle_dark = gr.Button(value="Toggle Dark", scale=1)
274
-
275
- # Function to switch to dark mode
276
- def toggle_dark_mode(dark_mode):
277
- return "dark" if dark_mode == "light" else "light"
278
-
279
- toggle_dark.click(toggle_dark_mode, inputs=None, outputs=None) # Update this as you wish
280
-
281
  with gr.Tab("Well-Being Chatbot"):
282
  with gr.Row():
283
  user_input = gr.Textbox(label="Please Enter Your Message Here", placeholder="Type your message here...", max_lines=3)
@@ -285,6 +268,7 @@ with gr.Blocks(theme='shivi/calm_seafoam') as app: # Set theme here
285
  query = gr.Textbox(label="Search Health Professionals Nearby", placeholder="E.g., Health Professionals", max_lines=1)
286
 
287
  submit_chatbot = gr.Button(value="Submit Your Message", variant="primary", icon="fa-paper-plane")
 
288
 
289
  chatbot = gr.Chatbot(label="Chat History", show_label=True)
290
  sentiment = gr.Textbox(label="Detected Sentiment", show_label=True)
@@ -294,12 +278,22 @@ with gr.Blocks(theme='shivi/calm_seafoam') as app: # Set theme here
294
  professionals = gr.DataFrame(label="Nearby Health Professionals", headers=["Name", "Address"])
295
  map_html = gr.HTML(label="Interactive Map")
296
 
 
 
 
 
297
  submit_chatbot.click(
298
  app_function_chatbot,
299
  inputs=[user_input, location, query, chatbot],
300
  outputs=[chatbot, sentiment, emotion, suggestions_markdown, professionals, map_html],
301
  )
302
 
 
 
 
 
 
 
303
  with gr.Tab("Disease Prediction"):
304
  symptom1 = gr.Dropdown(choices=[None] + list(X_train.columns), label="Select Symptom 1", value=None)
305
  symptom2 = gr.Dropdown(choices=[None] + list(X_train.columns), label="Select Symptom 2", value=None)
 
258
  return "\n".join(markdown_output)
259
 
260
  # Gradio Application Interface
261
+ with gr.Blocks(theme='shivi/calm_seafoam') as app: # Directly set theme here
262
  gr.HTML("<h1>🌟 Well-Being Companion</h1>")
263
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
264
  with gr.Tab("Well-Being Chatbot"):
265
  with gr.Row():
266
  user_input = gr.Textbox(label="Please Enter Your Message Here", placeholder="Type your message here...", max_lines=3)
 
268
  query = gr.Textbox(label="Search Health Professionals Nearby", placeholder="E.g., Health Professionals", max_lines=1)
269
 
270
  submit_chatbot = gr.Button(value="Submit Your Message", variant="primary", icon="fa-paper-plane")
271
+ clear_chatbot = gr.Button(value="Clear", variant="secondary") # Clear button
272
 
273
  chatbot = gr.Chatbot(label="Chat History", show_label=True)
274
  sentiment = gr.Textbox(label="Detected Sentiment", show_label=True)
 
278
  professionals = gr.DataFrame(label="Nearby Health Professionals", headers=["Name", "Address"])
279
  map_html = gr.HTML(label="Interactive Map")
280
 
281
+ # Functionality to clear the chat input
282
+ def clear_input():
283
+ return "", [] # Clear both the user input and chat history
284
+
285
  submit_chatbot.click(
286
  app_function_chatbot,
287
  inputs=[user_input, location, query, chatbot],
288
  outputs=[chatbot, sentiment, emotion, suggestions_markdown, professionals, map_html],
289
  )
290
 
291
+ clear_chatbot.click(
292
+ clear_input,
293
+ inputs=None,
294
+ outputs=[user_input, chatbot] # Reset user input and chat history
295
+ )
296
+
297
  with gr.Tab("Disease Prediction"):
298
  symptom1 = gr.Dropdown(choices=[None] + list(X_train.columns), label="Select Symptom 1", value=None)
299
  symptom2 = gr.Dropdown(choices=[None] + list(X_train.columns), label="Select Symptom 2", value=None)