Spaces:
Runtime error
Runtime error
File size: 844 Bytes
2964452 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
import gradio as gr
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
model_name = "thrishala/mental_health_chatbot"
model = AutoModelForCausalLM.from_pretrained(model_name)
tokenizer = AutoTokenizer.from_pretrained(model_name)
def generate_response(user_input):
inputs = tokenizer.encode(user_input + tokenizer.eos_token, return_tensors="pt")
output = model.generate(inputs, max_length=250, pad_token_id=tokenizer.eos_token_id)
response = tokenizer.decode(output[:, inputs.shape[-1]:][0], skip_special_tokens=True)
return response
interface = gr.Interface(
fn=generate_response,
inputs="text",
outputs="text",
title="Mental Health Chatbot",
description="A chatbot providing empathetic support and resources for mental health."
)
if __name__ == "__main__":
interface.launch()
|