AdityaBolt commited on
Commit
16a6757
ยท
verified ยท
1 Parent(s): f06fbfd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -11
app.py CHANGED
@@ -1,13 +1,35 @@
1
  import gradio as gr
2
 
3
- def greet(name):
4
- letter = f"Dear {name},\n\n" \
5
- "I hope this note finds you well. Your smile brightens everyone's day, " \
6
- "and I just wanted to take a moment to tell you how much you mean to those around you. " \
7
- "Keep being your awesome self!\n\n" \
8
- "With lots of love and a huge hug,\n" \
9
- "- Your Friend"
10
- return letter
11
-
12
- iface = gr.Interface(fn=write_letter, inputs="text", outputs="text")
13
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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()