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