testSpace2 / app.py
SupermanRX's picture
new app
2104ce1 verified
raw
history blame
827 Bytes
import gradio as gr
from transformers import AutoModelForCausalLM, AutoTokenizer
# Load your fine-tuned model
model_name = "SupermanRX/moderateTherapistModel" # Replace with your Hugging Face model path
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name)
def chatbot(input_text):
# Process user input and generate response
inputs = tokenizer(input_text, return_tensors="pt")
outputs = model.generate(inputs["input_ids"], max_length=200, pad_token_id=tokenizer.eos_token_id)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
return response
# Create a Gradio interface
interface = gr.Interface(
fn=chatbot,
inputs="text",
outputs="text",
title="Chat with Your Model"
)
# Launch the Gradio app
interface.launch()