Update app.py
Browse files
app.py
CHANGED
@@ -5,25 +5,14 @@ import time
|
|
5 |
with gr.Blocks() as demo:
|
6 |
chatbot = gr.Chatbot()
|
7 |
msg = gr.Textbox()
|
8 |
-
clear = gr.
|
9 |
|
10 |
-
def
|
11 |
-
return "", history + [[user_message, None]]
|
12 |
-
|
13 |
-
def bot(history):
|
14 |
bot_message = random.choice(["How are you?", "I love you", "I'm very hungry"])
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
time.sleep(0.05)
|
19 |
-
yield history
|
20 |
|
21 |
-
msg.submit(
|
22 |
-
bot, chatbot, chatbot
|
23 |
-
)
|
24 |
-
clear.click(lambda: None, None, chatbot, queue=False)
|
25 |
-
|
26 |
-
demo.queue()
|
27 |
-
if __name__ == "__main__":
|
28 |
-
demo.launch()
|
29 |
|
|
|
|
5 |
with gr.Blocks() as demo:
|
6 |
chatbot = gr.Chatbot()
|
7 |
msg = gr.Textbox()
|
8 |
+
clear = gr.ClearButton([msg, chatbot])
|
9 |
|
10 |
+
def respond(message, chat_history):
|
|
|
|
|
|
|
11 |
bot_message = random.choice(["How are you?", "I love you", "I'm very hungry"])
|
12 |
+
chat_history.append((message, bot_message))
|
13 |
+
time.sleep(2)
|
14 |
+
return "", chat_history
|
|
|
|
|
15 |
|
16 |
+
msg.submit(respond, [msg, chatbot], [msg, chatbot])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
+
demo.launch()
|