Spaces:
Sleeping
Sleeping
magic 8 ball
Browse files
app.py
CHANGED
|
@@ -1,17 +1,14 @@
|
|
| 1 |
-
import gradio as gr, random
|
| 2 |
|
| 3 |
|
| 4 |
def echo(message, history): #function for Gradio to call
|
| 5 |
-
#Gradio passes arguments as parameters: the user's most recent input which is a string
|
| 6 |
#I have to put it in this order because Gradio will always past the current user input first and then the convo history
|
| 7 |
-
# however for now, this chatbot won't use the history parameter
|
| 8 |
-
return random.choice(["Yes", "No"])
|
| 9 |
-
|
| 10 |
-
# “I'm passing the function name 'echo' to ChatInterface, not 'echo()' with parentheses, because I want Gradio to call it later, not right now.”
|
| 11 |
-
|
| 12 |
|
| 13 |
# defining chatbot
|
| 14 |
-
chatbot = gr.ChatInterface(echo, title = "
|
| 15 |
# passing fxn into a fxn, passing echo for gradio to call each time the user sends a message
|
| 16 |
# Adding parentheses would call the function and pass its return value instead, I didn't include () because I want Gradio to call it later, not right now
|
| 17 |
|
|
|
|
| 1 |
+
import gradio as gr, random
|
| 2 |
|
| 3 |
|
| 4 |
def echo(message, history): #function for Gradio to call
|
| 5 |
+
#Gradio passes arguments as parameters: the user's most recent input which is a string ("message"), and "history" which is the list of past messages
|
| 6 |
#I have to put it in this order because Gradio will always past the current user input first and then the convo history
|
| 7 |
+
# however for now, this chatbot won't use the history parameter anyway
|
| 8 |
+
return random.choice(["Yes", "No", "Maybe"])
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
# defining chatbot
|
| 11 |
+
chatbot = gr.ChatInterface(echo, title = "magic 8 ball", description = " user asks a yes or no question to the ball to reveal a random answer") #using gradio to quickly build a chatbot UI (w/ convo history & user input)
|
| 12 |
# passing fxn into a fxn, passing echo for gradio to call each time the user sends a message
|
| 13 |
# Adding parentheses would call the function and pass its return value instead, I didn't include () because I want Gradio to call it later, not right now
|
| 14 |
|