cvdnn commited on
Commit
c5e246a
1 Parent(s): 2c21c4d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -55
app.py CHANGED
@@ -1,57 +1,25 @@
1
  import gradio as gr
 
 
2
 
3
- with gr.Blocks(title="Styling Examples") as demo:
4
- with gr.Column(variant="box"):
5
- txt = gr.Textbox(label="Small Textbox", lines=1)
6
- num = gr.Number(label="Number", show_label=False)
7
- slider = gr.Slider(label="Slider", show_label=False)
8
- check = gr.Checkbox(label="Checkbox", show_label=False)
9
- check_g = gr.CheckboxGroup(
10
- label="Checkbox Group",
11
- choices=["One", "Two", "Three"],
12
- show_label=False,
13
- )
14
- radio = gr.Radio(
15
- label="Radio", choices=["One", "Two", "Three"], show_label=False
16
- ).style(
17
- item_container=False,
18
- )
19
- drop = gr.Dropdown(
20
- label="Dropdown", choices=["One", "Two", "Three"], show_label=False
21
- )
22
- image = gr.Image(show_label=False)
23
- video = gr.Video(show_label=False)
24
- audio = gr.Audio(show_label=False)
25
- file = gr.File(show_label=False)
26
- df = gr.Dataframe(show_label=False)
27
- ts = gr.Timeseries(show_label=False)
28
- label = gr.Label().style(
29
- container=False,
30
- )
31
- highlight = gr.HighlightedText(
32
- "+ hello. - goodbye",
33
- show_label=False,
34
- ).style(color_map={"+": "green", "-": "red"}, container=False)
35
- json = gr.JSON().style(container=False)
36
- html = gr.HTML(show_label=False)
37
- gallery = gr.Gallery().style(
38
- grid=(3, 3, 1),
39
- height="auto",
40
- container=False,
41
- )
42
- chat = gr.Chatbot([("hi", "good bye")]).style(color_map=("pink", "blue"))
43
-
44
- model = gr.Model3D()
45
-
46
- md = gr.Markdown(show_label=False)
47
-
48
- highlight = gr.HighlightedText()
49
-
50
- btn = gr.Button("Run").style(
51
- full_width=True,
52
- )
53
-
54
- gr.Dataset(components=[txt, num])
55
-
56
- if __name__ == "__main__":
57
- demo.launch()
 
1
  import gradio as gr
2
+ import random
3
+ import time
4
 
5
+ with gr.Blocks() as demo:
6
+ chatbot = gr.Chatbot()
7
+ msg = gr.Textbox()
8
+ clear = gr.Button("Clear")
9
+
10
+
11
+ def user(user_message, history):
12
+ return "", history + [[user_message, None]]
13
+
14
+
15
+ def bot(history):
16
+ bot_message = random.choice(["Yes", "No"])
17
+ history[-1][1] = bot_message
18
+ time.sleep(1)
19
+ return history
20
+
21
+
22
+ msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(bot, chatbot, chatbot)
23
+ clear.click(lambda: None, None, chatbot, queue=False)
24
+
25
+ demo.launch()