File size: 1,096 Bytes
3a5ba25
b430344
 
3a5ba25
 
 
e8d4e86
b430344
46b3c26
b430344
e8d4e86
3a5ba25
e8d4e86
3a5ba25
e8d4e86
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b430344
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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()