Spaces:
Sleeping
Sleeping
Commit
·
feea4c1
1
Parent(s):
923b2fa
Update app.py
Browse files
app.py
CHANGED
@@ -7,22 +7,15 @@ with gr.Blocks() as demo:
|
|
7 |
msg = gr.Textbox()
|
8 |
clear = gr.Button("Clear")
|
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(api_open=False)
|
27 |
if __name__ == "__main__":
|
28 |
demo.launch()
|
|
|
7 |
msg = gr.Textbox()
|
8 |
clear = gr.Button("Clear")
|
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(1)
|
14 |
+
return "", chat_history
|
|
|
|
|
15 |
|
16 |
+
msg.submit(respond, [msg, chatbot], [msg, chatbot])
|
|
|
|
|
17 |
clear.click(lambda: None, None, chatbot, queue=False)
|
18 |
+
|
19 |
demo.queue(api_open=False)
|
20 |
if __name__ == "__main__":
|
21 |
demo.launch()
|