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