Lin0He commited on
Commit
1b41a86
·
1 Parent(s): 962985b

Upload interface.py

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