import gradio as gr from transformers import pipeline # Load the text-generation pipeline generator = pipeline("text-generation", model="King-8/community-gpt2") # Define the chatbot response function def chat(prompt): response = generator(prompt, max_length=100, do_sample=True, temperature=0.7) return response[0]["generated_text"] # Set up the Gradio interface iface = gr.Interface(fn=chat, inputs="text", outputs="text", title="Community GPT-2 Chatbot", description="Ask me anything!") # Launch the app iface.launch()