Spaces:
Runtime error
Runtime error
armandstrickernlp
commited on
Commit
·
2a943a9
1
Parent(s):
34bfd19
create chatbot
Browse files
app.py
CHANGED
|
@@ -34,12 +34,25 @@ def chat(message, history):
|
|
| 34 |
|
| 35 |
return history, history
|
| 36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
import gradio as gr
|
| 39 |
|
| 40 |
chatbot = gr.Chatbot(color_map=("gray", "blue"))
|
| 41 |
|
| 42 |
-
iface = gr.Interface(
|
| 43 |
["text", "state"],
|
| 44 |
[chatbot, "state"],
|
| 45 |
allow_screenshot=False,
|
|
|
|
| 34 |
|
| 35 |
return history, history
|
| 36 |
|
| 37 |
+
import random
|
| 38 |
+
def chat_test(message, history):
|
| 39 |
+
history = history or []
|
| 40 |
+
if message.startswith("How many"):
|
| 41 |
+
response = random.randint(1, 10)
|
| 42 |
+
elif message.startswith("How"):
|
| 43 |
+
response = random.choice(["Great", "Good", "Okay", "Bad"])
|
| 44 |
+
elif message.startswith("Where"):
|
| 45 |
+
response = random.choice(["Here", "There", "Somewhere"])
|
| 46 |
+
else:
|
| 47 |
+
response = "I don't know"
|
| 48 |
+
history.append((message, response))
|
| 49 |
+
return history, history
|
| 50 |
|
| 51 |
import gradio as gr
|
| 52 |
|
| 53 |
chatbot = gr.Chatbot(color_map=("gray", "blue"))
|
| 54 |
|
| 55 |
+
iface = gr.Interface(chat_test,
|
| 56 |
["text", "state"],
|
| 57 |
[chatbot, "state"],
|
| 58 |
allow_screenshot=False,
|