Spaces:
Runtime error
Runtime error
AdityaBolt commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,13 +1,35 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
-
def
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
+
def write_letter(name, occasion, tone, emoji_count):
|
| 4 |
+
greetings = {
|
| 5 |
+
"friendly": "Hey there",
|
| 6 |
+
"formal": "Dear",
|
| 7 |
+
"funny": "What's up"
|
| 8 |
+
}
|
| 9 |
+
body_text = f"{greetings[tone]} {name},\n\n" \
|
| 10 |
+
"I just wanted to drop you a note because I heard it's your " \
|
| 11 |
+
f"{occasion}. Wow, what a day to celebrate! ๐ " \
|
| 12 |
+
"I hope your day is filled with laughter, joy, and cake! Lots of cake! ๐\n\n"
|
| 13 |
+
|
| 14 |
+
if tone == "friendly":
|
| 15 |
+
closing = "Catch you later,\n- Your buddy"
|
| 16 |
+
elif tone == "formal":
|
| 17 |
+
closing = "Sincerely,\n- [Your Name Here]"
|
| 18 |
+
else: # funny
|
| 19 |
+
closing = "Stay awesome (I know you will),\n- Your coolest friend"
|
| 20 |
+
|
| 21 |
+
emojis = "๐" * emoji_count
|
| 22 |
+
return body_text + closing + "\n" + emojis
|
| 23 |
+
|
| 24 |
+
inputs = [
|
| 25 |
+
gr.inputs.Textbox(lines=2, label="Name"),
|
| 26 |
+
gr.inputs.Textbox(lines=2, label="Occasion"),
|
| 27 |
+
gr.inputs.Dropdown(choices=["friendly", "formal", "funny"], label="Tone"),
|
| 28 |
+
gr.inputs.Slider(minimum=1, maximum=10, default=3, label="Number of Emojis")
|
| 29 |
+
]
|
| 30 |
+
|
| 31 |
+
output = gr.outputs.Textbox(label="Your Personalized Letter")
|
| 32 |
+
|
| 33 |
+
iface = gr.Interface(fn=write_letter, inputs=inputs, outputs=output, title="Create Your Personalized Letter", description="Fill in the details below to generate your personalized letter. Have fun!")
|
| 34 |
+
|
| 35 |
+
iface.launch()
|