from transformers import pipeline import gradio as gr # Load the model model_pipeline = pipeline("text-generation", model="./") # Define the greeting function def greet(): return "Hello, Cameron" # Define the text generation function def generate_text(prompt): return model_pipeline(prompt)[0]['generated_text'] # Create a Gradio interface with two options with gr.Blocks() as interface: gr.Markdown("## Welcome to the Space!") gr.Markdown("### Choose an option below:") # Option 1: Greeting with gr.Row(): greet_button = gr.Button("Say Hello") greet_output = gr.Textbox(label="Greeting") # Option 2: Text Generation with gr.Row(): input_text = gr.Textbox(label="Enter text for the model") generate_button = gr.Button("Generate Text") output_text = gr.Textbox(label="Model Output") # Define button actions greet_button.click(fn=greet, inputs=None, outputs=greet_output) generate_button.click(fn=generate_text, inputs=input_text, outputs=output_text) # Launch the interface interface.launch()