Antoine245 commited on
Commit
833323a
·
1 Parent(s): d6cd65d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -22,7 +22,7 @@ examples = [
22
  ]
23
  ]
24
 
25
- user_input = []
26
 
27
 
28
  with gr.Blocks() as demo:
@@ -30,8 +30,9 @@ with gr.Blocks() as demo:
30
  msg = gr.Textbox()
31
  clear = gr.ClearButton([msg, chatbot])
32
 
33
- def respond(message,chat_history):
34
- user_input.append([chat_history[0]])
 
35
  bot_message = palm.chat(
36
  **defaults,
37
  context=context,
@@ -39,8 +40,8 @@ with gr.Blocks() as demo:
39
  messages=user_input
40
  )
41
  time.sleep(2)
42
- return "", chat_history
43
 
44
- msg.submit(respond,[msg,chatbot],[msg,chatbot])
45
 
46
  demo.launch()
 
22
  ]
23
  ]
24
 
25
+ user_input = ['']
26
 
27
 
28
  with gr.Blocks() as demo:
 
30
  msg = gr.Textbox()
31
  clear = gr.ClearButton([msg, chatbot])
32
 
33
+ def respond(messages):
34
+ global user_input
35
+ user_input.append(messages[0]) # Wrap user input in a list
36
  bot_message = palm.chat(
37
  **defaults,
38
  context=context,
 
40
  messages=user_input
41
  )
42
  time.sleep(2)
43
+ return bot_message['message']
44
 
45
+ msg.submit(respond, [msg, chatbot],[msg, chatbot])
46
 
47
  demo.launch()