Mental_Health / app.py
InsaneJSK's picture
Update app.py
3370535 verified
# Install necessary libraries
# pip install gradio transformers
from transformers import pipeline
import gradio as gr
# Load the text-generation pipeline
pipe = pipeline("text-generation", model="thrishala/mental_health_chatbot")
# Define the chatbot function
def chatbot_response(input_text):
# Generate a response using the model
response = pipe(input_text, max_length=150, num_return_sequences=1, pad_token_id=50256)
return response[0]['generated_text']
# Create a Gradio interface
with gr.Blocks() as demo:
gr.Markdown("# Mental Health Chatbot")
gr.Markdown("This chatbot is designed to provide responses for mental health-related queries.")
with gr.Row():
with gr.Column():
input_text = gr.Textbox(label="Your Question", placeholder="Ask me anything...")
submit_button = gr.Button("Submit")
with gr.Column():
output_text = gr.Textbox(label="Chatbot Response", placeholder="The chatbot will respond here...")
submit_button.click(fn=chatbot_response, inputs=input_text, outputs=output_text)
# Launch the app
demo.launch()