Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
import random
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
-
#
|
| 5 |
responses = [
|
| 6 |
"Without a doubt.",
|
| 7 |
"Ask again later.",
|
|
@@ -15,13 +15,13 @@ responses = [
|
|
| 15 |
"Most likely.",
|
| 16 |
]
|
| 17 |
|
| 18 |
-
#
|
| 19 |
def magic_8_ball(question):
|
| 20 |
if question.strip() == "":
|
| 21 |
return "Please ask a yes/no question!"
|
| 22 |
return random.choice(responses)
|
| 23 |
|
| 24 |
-
#
|
| 25 |
chatbot = gr.Interface(
|
| 26 |
fn=magic_8_ball,
|
| 27 |
inputs=gr.Textbox(label="Ask the Magic 8 Ball a Yes/No Question:"),
|
|
@@ -30,5 +30,4 @@ chatbot = gr.Interface(
|
|
| 30 |
description="Ask a yes/no question and reveal your fate!"
|
| 31 |
)
|
| 32 |
|
| 33 |
-
# Launch the app
|
| 34 |
chatbot.launch()
|
|
|
|
| 1 |
import random
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
+
#Magic 8 Ball responses
|
| 5 |
responses = [
|
| 6 |
"Without a doubt.",
|
| 7 |
"Ask again later.",
|
|
|
|
| 15 |
"Most likely.",
|
| 16 |
]
|
| 17 |
|
| 18 |
+
#response function
|
| 19 |
def magic_8_ball(question):
|
| 20 |
if question.strip() == "":
|
| 21 |
return "Please ask a yes/no question!"
|
| 22 |
return random.choice(responses)
|
| 23 |
|
| 24 |
+
#Make the Gradio interface
|
| 25 |
chatbot = gr.Interface(
|
| 26 |
fn=magic_8_ball,
|
| 27 |
inputs=gr.Textbox(label="Ask the Magic 8 Ball a Yes/No Question:"),
|
|
|
|
| 30 |
description="Ask a yes/no question and reveal your fate!"
|
| 31 |
)
|
| 32 |
|
|
|
|
| 33 |
chatbot.launch()
|