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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -4
app.py CHANGED
@@ -31,9 +31,8 @@ with gr.Blocks() as demo:
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,
@@ -42,7 +41,7 @@ with gr.Blocks() as demo:
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
 
 
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,
 
41
  bot_message = bot_message[-1] # Get the last response
42
  chat_history.append(bot_message) # Append the bot's message to the chat history
43
  time.sleep(2)
44
+ return bot_message, chat_history
45
 
46
  msg.submit(respond,[msg,chatbot],[msg, chatbot])
47