awacke1 commited on
Commit
310c485
·
1 Parent(s): b97a3ee

Create app.py

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