File size: 1,131 Bytes
4478d67
4cc700d
4478d67
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import gradio as gr
from shared_functions import greet, download_text

def greeting_tab():
    gr.Markdown("## Greeting Generator")
    with gr.Row():
        with gr.Column():
            name = gr.Textbox(label="Name", info="Enter your name", placeholder="e.g. Alex")
            intensity = gr.Slider(1, 20, value=3, step=1, label="Intensity", info="How excited should the greeting be?")
            with gr.Accordion("Advanced Options", open=False):
                exclaim = gr.Checkbox(label="Shout (all caps)", info="Make the greeting all uppercase and add exclamations")
            greet_btn = gr.Button("Greet")
        with gr.Column():
            greet_output = gr.Textbox(label="Greeting", lines=2)
            download_greet_btn = gr.DownloadButton(label="Download Greeting", value=download_text, inputs=greet_output)
            gr.Examples(
                [["Jill", 1, False], ["Sam", 3, True], ["Alex", 5, False]],
                inputs=[name, intensity, exclaim],
                outputs=greet_output,
                fn=greet
            )
    greet_btn.click(greet, [name, intensity, exclaim], greet_output)