Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import random
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
def chat(message, history):
|
5 |
+
history = history or []
|
6 |
+
message = message.lower()
|
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 |
+
chatbot = gr.Chatbot().style(color_map=("green", "pink"))
|
19 |
+
demo = gr.Interface(
|
20 |
+
chat,
|
21 |
+
["text", "state"],
|
22 |
+
[chatbot, "state"],
|
23 |
+
allow_flagging="never",
|
24 |
+
)
|
25 |
+
demo.launch()
|