Ronak Ramachandran commited on
Commit
c1076fc
1 Parent(s): 1f745c4

sentence builder demo

Browse files
Files changed (1) hide show
  1. app.py +29 -4
app.py CHANGED
@@ -1,7 +1,32 @@
1
  import gradio as gr
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
5
 
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
 
 
 
3
 
4
+ def sentence_builder(quantity, animal, countries, place, activity_list, morning):
5
+ 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"}"""
6
+
7
+
8
+ demo = gr.Interface(
9
+ sentence_builder,
10
+ [
11
+ gr.Slider(2, 20, value=4, label="Count", info="Choose between 2 and 20"),
12
+ gr.Dropdown(
13
+ ["cat", "dog", "bird"], label="Animal", info="Will add more animals later!"
14
+ ),
15
+ gr.CheckboxGroup(["USA", "Japan", "Pakistan"], label="Countries", info="Where are they from?"),
16
+ gr.Radio(["park", "zoo", "road"], label="Location", info="Where did they go?"),
17
+ gr.Dropdown(
18
+ ["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."
19
+ ),
20
+ gr.Checkbox(label="Morning", info="Did they do it in the morning?"),
21
+ ],
22
+ "text",
23
+ examples=[
24
+ [2, "cat", ["Japan", "Pakistan"], "park", ["ate", "swam"], True],
25
+ [4, "dog", ["Japan"], "zoo", ["ate", "swam"], False],
26
+ [10, "bird", ["USA", "Pakistan"], "road", ["ran"], False],
27
+ [8, "cat", ["Pakistan"], "zoo", ["ate"], True],
28
+ ]
29
+ )
30
+
31
+ if __name__ == "__main__":
32
+ demo.launch()