import gradio as gr def write_letter(name, occasion, tone, emoji_count): greetings = { "friendly": "Hey there", "formal": "Dear", "funny": "What's up" } body_text = f"{greetings[tone]} {name},\n\n" \ f"I just wanted to drop you a note because I heard it's your {occasion}. " \ "What a day to celebrate! 🎉 " \ "I hope your day is filled with laughter, joy, and cake! Lots of cake! 🎂\n\n" closing = "" if tone == "friendly": closing = "Catch you later,\n- Your buddy" elif tone == "formal": closing = "Sincerely,\n- [Your Name Here]" elif tone == "funny": closing = "Stay awesome (I know you will),\n- Your coolest friend" emojis = "😊" * emoji_count return body_text + closing + "\n" + emojis inputs = [ gr.Textbox(lines=2, placeholder="Name", label="Name"), gr.Textbox(lines=2, placeholder="Occasion", label="Occasion"), gr.Dropdown(choices=["friendly", "formal", "funny"], label="Tone"), gr.Slider(minimum=1, maximum=10, value=3, label="Number of Emojis") # Corrected here ] iface = gr.Interface(fn=write_letter, inputs=inputs, outputs="textbox", title="Create Your Personalized Letter", description="Fill in the details below to generate your personalized letter. Have fun!") iface.launch()