Update app.py
Browse files
app.py
CHANGED
@@ -1,57 +1,25 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
2 |
|
3 |
-
with gr.Blocks(
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
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()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|