Spaces:
Running
Running
import gradio as gr | |
from transformers import AutoModelForCausalLM, AutoTokenizer | |
# Load your model and tokenizer | |
model_name = "WICKED4950/Irisbetterprecise" # Replace with your model | |
tokenizer = AutoTokenizer.from_pretrained(model_name) | |
model = AutoModelForCausalLM.from_pretrained(model_name,from_tf=True) | |
# Define the chatbot function | |
def chatbot_response(input_text): | |
inputs = tokenizer.encode(input_text, return_tensors="pt") | |
outputs = model.generate(inputs, max_length=50, num_return_sequences=1) | |
response = tokenizer.decode(outputs[0], skip_special_tokens=True) | |
return response | |
# Create Gradio interface | |
interface = gr.Interface( | |
fn=chatbot_response, | |
inputs=gr.Textbox(label="Ask me anything!"), | |
outputs=gr.Textbox(label="Response"), | |
title="My Chatbot", | |
description="A simple chatbot deployed using Hugging Face Spaces and Gradio!" | |
) | |
# Launch the app | |
if __name__ == "__main__": | |
interface.launch() | |