drmurataltun commited on
Commit
9bfa7e0
1 Parent(s): 8550247

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -0
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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(["How are you?", "I love you", "I'm very hungry"])
15
+ time.sleep(2)
16
+ history[-1][1] = bot_message
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.queue()
25
+ demo.launch()