majweldon commited on
Commit
2b1a008
·
1 Parent(s): 71f9fc7

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ def user(user_message, history):
11
+ return "", history + [[user_message, None]]
12
+
13
+ def bot(history):
14
+ bot_message = random.choice(["Yes", "No"])
15
+ history[-1][1] = bot_message
16
+ time.sleep(1)
17
+ return history
18
+
19
+ msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(
20
+ bot, chatbot, chatbot
21
+ )
22
+ clear.click(lambda: None, None, chatbot, queue=False)
23
+
24
+ demo.launch()