import gradio as gr from transformers import pipeline # Load the model generator = pipeline("text-generation", model="distilgpt2") # Define the function for Gradio def generate_text(prompt): result = generator(prompt, max_length=50, num_return_sequences=1) return result[0]["generated_text"] # Create the Gradio interface demo = gr.Interface(fn=generate_text, inputs="text", outputs="text", title="Simple LLM Chat") # Launch the interface demo.launch()