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)