import gradio as gr from transformers import pipeline # Load pre-trained models emotion_model = pipeline("text-classification", model="j-hartmann/emotion-english-distilroberta-base") severity_model = pipeline("text-classification", model="bhadresh-savani/bert-base-uncased-emotion") dialog_model = pipeline("text-generation", model="microsoft/DialoGPT-medium") def chatbot(user_input): emotion = emotion_model(user_input)[0]['label'] severity = severity_model(user_input)[0]['label'] reply = dialog_model(user_input, max_length=50, num_return_sequences=1)[0]['generated_text'] return f"Emotion: {emotion}\nSeverity: {severity}\nBot Reply: {reply}" iface = gr.Interface( fn=chatbot, inputs="text", outputs="text", title="Mental Health Bot", description="Detects emotion & severity, then replies with supportive text." ) iface.launch()