File size: 837 Bytes
db6eba4
e9a015f
bcee0a0
e9a015f
 
 
bcee0a0
e9a015f
 
 
 
 
bcee0a0
e9a015f
 
 
 
 
 
bcee0a0
e9a015f
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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()