test23 / app.py
khaled123's picture
Update app.py
fddc759 verified
raw
history blame
719 Bytes
import gradio as gr
from transformers import AutoModelForCausalLM, AutoTokenizer
# Load your model
model_name = "khaled123/hf"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name)
def chat(input_text):
inputs = tokenizer(input_text, return_tensors="pt")
outputs = model.generate(inputs["input_ids"], max_length=150, num_return_sequences=1)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
return response
iface = gr.Interface(fn=chat,
inputs="text",
outputs="text",
title="Chatbot",
description="A chatbot using a model")
iface.launch()