Spaces:
Sleeping
Sleeping
added functionally to chatbot
Browse files
app.py
CHANGED
|
@@ -1,5 +1,15 @@
|
|
| 1 |
-
import gradio as gr #abbreviate gradio
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
# defining chatbot
|
| 4 |
-
chatbot = gr.ChatInterface() #using gradio to quickly build a chatbot UI (w/ convo history & user input)
|
|
|
|
| 5 |
chatbot.launch() #launch chatbot
|
|
|
|
| 1 |
+
import gradio as gr #abbreviate gradio, import lines go first
|
| 2 |
+
|
| 3 |
+
def echo(message, history): #function for Gradio to call
|
| 4 |
+
#Gradio passes arguments as parameters: the user's most recent input which is a string, i'm going to call it "message", and "history" which is the list of past messages
|
| 5 |
+
#I have to put it in this order because Gradio will always past the current user input first and then the convo history
|
| 6 |
+
# however for now, this chatbot won't use the history parameter anyay
|
| 7 |
+
return message #returns what user types in
|
| 8 |
+
|
| 9 |
+
# “I'm passing the function name 'echo' to ChatInterface, not 'echo()' with parentheses, because I want Gradio to call it later, not right now.”
|
| 10 |
+
|
| 11 |
|
| 12 |
# defining chatbot
|
| 13 |
+
chatbot = gr.ChatInterface(echo) #using gradio to quickly build a chatbot UI (w/ convo history & user input)
|
| 14 |
+
# passing echo for gradio to call, not w/ () because I want Gradio to call it later, not right now
|
| 15 |
chatbot.launch() #launch chatbot
|