Spaces:
Runtime error
Runtime error
File size: 526 Bytes
13aad12 a68ffde 13aad12 a68ffde 13aad12 a68ffde 13aad12 a68ffde 13aad12 a68ffde | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | import gradio as gr
from transformers import pipeline
# Load a text generation pipeline from Hugging Face
generator = pipeline("text-generation", model="gpt2")
def chat_with_model(prompt):
result = generator(prompt, max_length=100)[0]['generated_text']
return result
# Build Gradio interface
iface = gr.Interface(
fn=chat_with_model,
inputs=gr.Textbox(lines=2, placeholder="Type your message..."),
outputs="text",
title="My AI Chatbot",
description="Chat with a GPT-2 model!"
)
iface.launch() |