raghaziz commited on
Commit
f94b6df
·
verified ·
1 Parent(s): c581532

Create sentence_builder.py

Browse files
Files changed (1) hide show
  1. sentence_builder.py +30 -0
sentence_builder.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ def sentence_builder(quantity, animal, countries, place, activity_list, morning):
4
+ return f"""The {quantity} {animal}s from {" and ".join(countries)} went to the {place} where they {" and ".join(activity_list)} until the {"morning" if morning else "night"}"""
5
+
6
+ demo = gr.Interface(
7
+ sentence_builder,
8
+ [
9
+ gr.Slider(2, 20, value=4, label="Count", info="Choose between 2 and 20"),
10
+ gr.Dropdown(
11
+ ["monkey", "fish", "camel"], label="Animal", info="Will add more animals later!"
12
+ ),
13
+ gr.CheckboxGroup(["USA", "Saudi Arabia", "Pakistan"], label="Countries", info="Where are they from?"),
14
+ gr.Radio(["desert", "zoo", "sea"], label="Location", info="Where did they go?"),
15
+ gr.Dropdown(
16
+ ["ran", "swam", "ate", "slept"], value=["swam", "slept"], multiselect=True, label="Activity", info="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed auctor, nisl eget ultricies aliquam, nunc nisl aliquet nunc, eget aliquam nisl nunc vel nisl."
17
+ ),
18
+ gr.Checkbox(label="Morning", info="Did they do it in the morning?"),
19
+ ],
20
+ "text",
21
+ examples=[
22
+ [2, "monkey", ["USA", "Pakistan"], "zoo", ["ate", "swam"], True],
23
+ [4, "fish", ["Japan"], "sea", ["ate", "swam"], False],
24
+ [10, "camel", ["USA", "Saudi Arabia"], "desert", ["ran"], False],
25
+ [8, "fish", ["USA"], "sea", ["ate"], True],
26
+ ]
27
+ )
28
+
29
+ if __name__ == "__main__":
30
+ demo.launch()