Antoine245 commited on
Commit
3294241
·
1 Parent(s): e80e7b5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -22,8 +22,8 @@ examples = [
22
  ]
23
  ]
24
 
25
- # user_message = ['']
26
- # history = ['']
27
 
28
 
29
  with gr.Blocks() as demo:
@@ -32,7 +32,9 @@ with gr.Blocks() as demo:
32
  clear = gr.ClearButton([msg, chatbot])
33
 
34
  def user(user_message, history):
35
- return gr.update(value="", interactive=False), history + [[user_message,None]]
 
 
36
  def bot(history):
37
  # chat_history.append(message) # Initialize chat history
38
  bot_message = palm.chat(
@@ -45,6 +47,7 @@ with gr.Blocks() as demo:
45
  history[-1][1] += character
46
  time.sleep(0.05)
47
  yield history
 
48
  response = msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(
49
  bot, chatbot, chatbot
50
  )
 
22
  ]
23
  ]
24
 
25
+ user_message = []
26
+ history = []
27
 
28
 
29
  with gr.Blocks() as demo:
 
32
  clear = gr.ClearButton([msg, chatbot])
33
 
34
  def user(user_message, history):
35
+ user_message.append(msg.value)
36
+ return gr.update(value="", interactive=False), history + [[user_message[-1], None]]
37
+
38
  def bot(history):
39
  # chat_history.append(message) # Initialize chat history
40
  bot_message = palm.chat(
 
47
  history[-1][1] += character
48
  time.sleep(0.05)
49
  yield history
50
+
51
  response = msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(
52
  bot, chatbot, chatbot
53
  )