Tranformers / app.py
typesdigital's picture
Create app.py
dbc88bc
raw
history blame
582 Bytes
import gradio as gr
from transformers import pipeline
# Create a text generation pipeline using Hugging Face Transformers
generator = pipeline("text-generation", model="EleutherAI/gpt-neo-2.7B")
# Define the chat function
def chat(input_text):
response = generator(input_text, max_length=50, do_sample=True)[0]["generated_text"]
return response
# Create a Gradio interface
iface = gr.Interface(
fn=chat,
inputs=gr.inputs.Textbox(label="Input Text"),
outputs=gr.outputs.Textbox(label="Response"),
live=True,
)
# Launch the Gradio interface
iface.launch()