dawoodkhan82 commited on
Commit
586a4b1
1 Parent(s): 7629c1d

add chatbot demo

Browse files
Files changed (1) hide show
  1. app.py +27 -0
app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import random
2
+
3
+ import gradio as gr
4
+
5
+
6
+ def chat(message, history):
7
+ history = history or []
8
+ if message.startswith("How many"):
9
+ response = random.randint(1, 10)
10
+ elif message.startswith("How"):
11
+ response = random.choice(["Great", "Good", "Okay", "Bad"])
12
+ elif message.startswith("Where"):
13
+ response = random.choice(["Here", "There", "Somewhere"])
14
+ else:
15
+ response = "I don't know"
16
+ history.append((message, response))
17
+ return history, history
18
+
19
+
20
+ iface = gr.Interface(
21
+ chat,
22
+ ["text", "state"],
23
+ ["chatbot", "state"],
24
+ allow_screenshot=False,
25
+ allow_flagging="never",
26
+ )
27
+ iface.launch()