Spaces:
Runtime error
Runtime error
File size: 1,413 Bytes
e523d5a b86906b a77c5f7 b092712 a77c5f7 b092712 10383da a77c5f7 10383da 508f540 b092712 a77c5f7 10383da a77c5f7 b092712 | 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 38 | 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()
|