import gradio as gr from transformers import pipeline # Load the model (this is the pretrained Mistral 7B model) model = pipeline("text-generation", model="mistralai/Mistral-7B-v0.1") # Create the interface def generate_text(prompt): return model(prompt, max_length=100)[0]['generated_text'] # Set up Gradio interface iface = gr.Interface(fn=generate_text, inputs="text", outputs="text") # Launch the interface iface.launch()