Spaces:
Runtime error
Runtime error
Commit
·
0b3cc08
1
Parent(s):
e646ab5
Update app.py
Browse files
app.py
CHANGED
@@ -31,17 +31,18 @@ with gr.Blocks() as demo:
|
|
31 |
msg = gr.Textbox()
|
32 |
clear = gr.ClearButton([msg, chatbot])
|
33 |
|
34 |
-
def respond(message
|
35 |
-
chat_history
|
|
|
36 |
bot_message = palm.chat(
|
37 |
context=context,
|
38 |
examples=examples,
|
39 |
messages=chat_history
|
40 |
)
|
41 |
-
bot_message = [
|
42 |
-
bot_message
|
43 |
time.sleep(2)
|
44 |
-
return
|
45 |
|
46 |
msg.submit(respond,[msg,chatbot],[msg, chatbot])
|
47 |
|
|
|
31 |
msg = gr.Textbox()
|
32 |
clear = gr.ClearButton([msg, chatbot])
|
33 |
|
34 |
+
def respond(message):
|
35 |
+
global chat_history
|
36 |
+
chat_history.append([message]) # Wrap the message in a list or tuple
|
37 |
bot_message = palm.chat(
|
38 |
context=context,
|
39 |
examples=examples,
|
40 |
messages=chat_history
|
41 |
)
|
42 |
+
bot_message = bot_message[-1] # Get the last response
|
43 |
+
chat_history.append(bot_message) # Append the bot's message to the chat history
|
44 |
time.sleep(2)
|
45 |
+
return bot_message
|
46 |
|
47 |
msg.submit(respond,[msg,chatbot],[msg, chatbot])
|
48 |
|