Spaces:
Sleeping
Sleeping
all lesson 10 code
Browse files
app.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import random
|
| 3 |
+
|
| 4 |
+
def echo(message, history):
|
| 5 |
+
return echo
|
| 6 |
+
|
| 7 |
+
def respond(message, history):
|
| 8 |
+
return random.choice(["Yes", "No"])
|
| 9 |
+
|
| 10 |
+
def magic_8_ball(message, history):
|
| 11 |
+
responses = [
|
| 12 |
+
"Without a doubt",
|
| 13 |
+
"Outlook not so good",
|
| 14 |
+
"Ask again later",
|
| 15 |
+
"Definitely yes",
|
| 16 |
+
"I wouldn't count on it",
|
| 17 |
+
"Signs point to yes",
|
| 18 |
+
"Very doubtful",
|
| 19 |
+
"It is certain"
|
| 20 |
+
]
|
| 21 |
+
return random.choice(responses)
|
| 22 |
+
|
| 23 |
+
chatbot = gr.ChatInterface(
|
| 24 |
+
fn = magic_8_ball,
|
| 25 |
+
title = "Magic 8 Ball 🎱",
|
| 26 |
+
description = "ask a yes of no question and get a mysterious answer!"
|
| 27 |
+
)
|
| 28 |
+
|
| 29 |
+
chatbot.launch()
|