rwitz commited on
Commit
62664c3
1 Parent(s): e265ae5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -142,7 +142,7 @@ def vote_down_model(state, chatbot,chatbot2):
142
  chatbot.append(update_message[1])
143
  return chatbot,chatbot2, gr.Button.update(interactive=False),gr.Button.update(interactive=False),gr.Textbox.update(interactive=False),gr.Button.update(interactive=False) # Disable voting buttons
144
 
145
- def user_ask(state, chatbot1, chatbot2, textbox):
146
  global enable_btn
147
  user_input = textbox
148
  if len(user_input) > 200:
@@ -157,7 +157,7 @@ def user_ask(state, chatbot1, chatbot2, textbox):
157
  state["history"][1].extend([
158
  {"role": "user", "content": user_input}])
159
  # Chat with bots
160
- bot1_response, bot2_response = chat_with_bots(user_input, state)
161
  state["history"][0].extend([
162
  {"role": "bot1", "content": bot1_response},
163
  ])
@@ -207,8 +207,8 @@ with gr.Blocks() as demo:
207
  submit_btn = gr.Button(value="Send")
208
  reset_btn = gr.Button(value="Reset")
209
  reset_btn.click(clear_chat, inputs=[state], outputs=[state, chatbot1, chatbot2, upvote_btn_a, upvote_btn_b,textbox,submit_btn])
210
- textbox.submit(user_ask, inputs=[state, chatbot1, chatbot2, textbox], outputs=[state, chatbot1, chatbot2, textbox,upvote_btn_a,upvote_btn_b])
211
- submit_btn.click(user_ask, inputs=[state, chatbot1, chatbot2, textbox], outputs=[state, chatbot1, chatbot2, textbox,upvote_btn_a,upvote_btn_b])
212
  upvote_btn_a.click(vote_up_model, inputs=[state, chatbot1,chatbot2], outputs=[chatbot1,chatbot2,upvote_btn_a,upvote_btn_b,textbox,submit_btn])
213
  upvote_btn_b.click(vote_down_model, inputs=[state, chatbot1,chatbot2], outputs=[chatbot1,chatbot2,upvote_btn_a,upvote_btn_b,textbox,submit_btn])
214
  with gr.Tab("Leaderboard"):
 
142
  chatbot.append(update_message[1])
143
  return chatbot,chatbot2, gr.Button.update(interactive=False),gr.Button.update(interactive=False),gr.Textbox.update(interactive=False),gr.Button.update(interactive=False) # Disable voting buttons
144
 
145
+ async def user_ask(state, chatbot1, chatbot2, textbox):
146
  global enable_btn
147
  user_input = textbox
148
  if len(user_input) > 200:
 
157
  state["history"][1].extend([
158
  {"role": "user", "content": user_input}])
159
  # Chat with bots
160
+ bot1_response, bot2_response = await chat_with_bots(user_input, state)
161
  state["history"][0].extend([
162
  {"role": "bot1", "content": bot1_response},
163
  ])
 
207
  submit_btn = gr.Button(value="Send")
208
  reset_btn = gr.Button(value="Reset")
209
  reset_btn.click(clear_chat, inputs=[state], outputs=[state, chatbot1, chatbot2, upvote_btn_a, upvote_btn_b,textbox,submit_btn])
210
+ textbox.submit(user_ask, inputs=[state, chatbot1, chatbot2, textbox], outputs=[state, chatbot1, chatbot2, textbox,upvote_btn_a,upvote_btn_b], queue=True)
211
+ submit_btn.click(user_ask, inputs=[state, chatbot1, chatbot2, textbox], outputs=[state, chatbot1, chatbot2, textbox,upvote_btn_a,upvote_btn_b], queue=True)
212
  upvote_btn_a.click(vote_up_model, inputs=[state, chatbot1,chatbot2], outputs=[chatbot1,chatbot2,upvote_btn_a,upvote_btn_b,textbox,submit_btn])
213
  upvote_btn_b.click(vote_down_model, inputs=[state, chatbot1,chatbot2], outputs=[chatbot1,chatbot2,upvote_btn_a,upvote_btn_b,textbox,submit_btn])
214
  with gr.Tab("Leaderboard"):