mirror of
https://github.com/gradio-app/gradio.git
synced 2024-12-27 02:30:17 +08:00
28 lines
1.1 KiB
Python
28 lines
1.1 KiB
Python
import gradio as gr
|
|
from time import sleep
|
|
|
|
def answer_question(quantity, animal, place, activity_list, morning, etc):
|
|
return f"""The {quantity} {animal}s went to the {place} where they {" and ".join(activity_list)} until the {"morning" if morning else "night"}""", "OK"
|
|
|
|
|
|
gr.Interface(answer_question,
|
|
[
|
|
gr.inputs.Slider(2, 20),
|
|
gr.inputs.Dropdown(["cat", "dog", "bird"]),
|
|
gr.inputs.Radio(["park", "zoo", "road"]),
|
|
gr.inputs.CheckboxGroup(["ran", "swam", "ate", "slept"]),
|
|
gr.inputs.Checkbox(label="Is it the morning?"),
|
|
gr.inputs.Textbox(default="What else?"),
|
|
],
|
|
[
|
|
gr.outputs.Textbox(lines=8),
|
|
gr.outputs.Textbox(lines=1),
|
|
],
|
|
examples=[
|
|
[2, "cat", "park", ["ran", "swam"], True],
|
|
[4, "dog", "zoo", ["ate", "swam"], False],
|
|
[10, "bird", "road", ["ran"], False],
|
|
[8, "cat", "zoo", ["ate"], True],
|
|
]
|
|
).launch()
|