|
|
import gradio as gr |
|
|
|
|
|
def mental_health_bot(user_input): |
|
|
|
|
|
if "sad" in user_input.lower(): |
|
|
return "I'm sorry to hear that. I'm here to help." |
|
|
elif "happy" in user_input.lower(): |
|
|
return "That's great to hear! Keep smiling!" |
|
|
return "How can I help you today?" |
|
|
|
|
|
with gr.Blocks() as demo: |
|
|
gr.Markdown("### 🧠 Mental Health Support App") |
|
|
|
|
|
with gr.Row(): |
|
|
user_input = gr.Textbox(label="Enter your question or feelings", placeholder="Type something...", lines=2) |
|
|
|
|
|
with gr.Row(): |
|
|
submit_btn = gr.Button("Submit", elem_id="submit-btn") |
|
|
clear_btn = gr.Button("Clear") |
|
|
|
|
|
with gr.Row(): |
|
|
output = gr.Textbox(label="Response", placeholder="Your response will appear here", lines=2) |
|
|
|
|
|
submit_btn.click(mental_health_bot, inputs=[user_input], outputs=[output]) |
|
|
clear_btn.click(lambda: ("", ""), inputs=[], outputs=[user_input, output]) |
|
|
|
|
|
|
|
|
demo.launch() |
|
|
|