Antoine245 commited on
Commit
0b3cc08
·
1 Parent(s): e646ab5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
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, chat_history):
35
- chat_history.append(message) # Initialize chat history
 
36
  bot_message = palm.chat(
37
  context=context,
38
  examples=examples,
39
  messages=chat_history
40
  )
41
- bot_message = [bot_message.last]
42
- bot_message = str(bot_message)
43
  time.sleep(2)
44
- return "", bot_message, chat_history
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