File size: 1,164 Bytes
e42ab72 65195f4 bc86d65 33851c1 bc86d65 e42ab72 bc86d65 65195f4 bc86d65 65195f4 bc86d65 65195f4 80f83c8 |
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 |
import gradio as gr
# Function - Personalize the greeting
def greet(name, style, excitement_level):
base_greeting = {
"Friendly": "AoA",
"Formal": "Asalam-O-Alaikum",
"Casual": "Salam"
}[style]
return f"{base_greeting} {name}{'!' * excitement_level}"
# π¨ Custom Theme
theme = gr.themes.Soft(primary_hue="teal", secondary_hue="blue")
# Layout with Blocks
with gr.Blocks(theme=theme, title="Greeting Generator") as demo:
gr.Markdown("## π Personalized Greeting App\nFill the form below and get a custom greeting!")
with gr.Row():
name = gr.Textbox(label="Your Name", placeholder="Enter your name here", lines=1)
style = gr.Dropdown(choices=["Friendly", "Formal", "Casual"], value="Friendly", label="Greeting Style")
excitement = gr.Slider(minimum=1, maximum=5, step=1, value=2, label="Excitement Level (Number of !)")
greet_btn = gr.Button("Generate Greeting π")
output = gr.Textbox(label="Your Greeting", interactive=False)
greet_btn.click(fn=greet, inputs=[name, style, excitement], outputs=output)
# π Launch in browser
demo.launch()
#demo.launch(inbrowser=True)
|