manan05 commited on
Commit
c2b25e6
1 Parent(s): 5a6bbf6

chatbot demop

Browse files
Files changed (1) hide show
  1. app.py +15 -4
app.py CHANGED
@@ -1,7 +1,18 @@
1
  import gradio as gr
 
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
 
 
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- iface.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.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()