safwansajad's picture
Update app.py
e9a015f verified
raw
history blame
837 Bytes
import gradio as gr
from transformers import pipeline
# Load model from Hugging Face Hub
model_name = "thrishala/mental_health_chatbot"
nlp = pipeline("text-generation", model=model_name)
# Function to process user input and return chatbot's response
def chatbot_response(user_input):
# Get response using the model pipeline
response = nlp(user_input, max_length=150, num_return_sequences=1)
return response[0]['generated_text']
# Gradio interface
iface = gr.Interface(fn=chatbot_response,
inputs="text",
outputs="text",
title="Mental Health Chatbot",
description="This chatbot provides empathetic responses to mental health-related queries. It aims to support users in a safe and compassionate manner.")
# Launch the app
iface.launch()