Spaces:
Sleeping
Sleeping
Magic 8 Ball Chatbot
Browse files
app.py
CHANGED
|
@@ -1,18 +1,39 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import random
|
| 3 |
|
| 4 |
-
def
|
| 5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
return response
|
| 7 |
|
| 8 |
-
print("Hello, world")
|
| 9 |
-
|
| 10 |
chatbot = gr.ChatInterface(
|
| 11 |
-
|
| 12 |
type="messages",
|
| 13 |
-
title="
|
| 14 |
-
description="
|
| 15 |
)
|
| 16 |
|
| 17 |
chatbot.launch()
|
| 18 |
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import random
|
| 3 |
|
| 4 |
+
def magic_8_ball(message, history):
|
| 5 |
+
responses = [
|
| 6 |
+
"Without a doubt.",
|
| 7 |
+
"Outlook not so good.",
|
| 8 |
+
"Ask again later.",
|
| 9 |
+
"Yes, definitely!",
|
| 10 |
+
"My sources say no.",
|
| 11 |
+
"Signs point to yes.",
|
| 12 |
+
"Don't count on it.",
|
| 13 |
+
"It is certain.",
|
| 14 |
+
"Better not tell you now.",
|
| 15 |
+
"Very doubtful.",
|
| 16 |
+
"Reply hazy, try again.",
|
| 17 |
+
"You may rely on it.",
|
| 18 |
+
"Concentrate and ask again.",
|
| 19 |
+
"My reply is no.",
|
| 20 |
+
"As I see it, yes.",
|
| 21 |
+
"Most likely.",
|
| 22 |
+
"Yes.",
|
| 23 |
+
"No.",
|
| 24 |
+
"Cannot predict now.",
|
| 25 |
+
"It is decidedly so."
|
| 26 |
+
]
|
| 27 |
+
response = random.choice(responses)
|
| 28 |
return response
|
| 29 |
|
|
|
|
|
|
|
| 30 |
chatbot = gr.ChatInterface(
|
| 31 |
+
magic_8_ball,
|
| 32 |
type="messages",
|
| 33 |
+
title="Magic 8 Ball Chatbot",
|
| 34 |
+
description="Ask any yes–no question and let the Magic 8 Ball reveal your fate!"
|
| 35 |
)
|
| 36 |
|
| 37 |
chatbot.launch()
|
| 38 |
|
| 39 |
+
|