rwitz commited on
Commit
4c3c8bf
1 Parent(s): dad0315

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -5
app.py CHANGED
@@ -91,11 +91,17 @@ def update_ratings(state, winner_index):
91
 
92
  elo_ratings = update_elo_ratings(elo_ratings, winner, loser)
93
  write_elo_ratings(elo_ratings)
94
- return f"Updated ELO ratings:\n{winner}: {elo_ratings[winner]}\n{loser}: {elo_ratings[loser]}"
95
 
96
- def vote_up_model(state, chatbot):
97
  update_message = update_ratings(state, 0)
98
- chatbot.append(update_message)
 
 
 
 
 
 
99
  return chatbot, gr.Button.update(interactive=False),gr.Button.update(interactive=False) # Disable voting buttons
100
 
101
  def user_ask(state, chatbot1, chatbot2, textbox):
@@ -159,8 +165,8 @@ with gr.Blocks() as demo:
159
  reset_btn.click(clear_chat, inputs=[state], outputs=[state, chatbot1, chatbot2, upvote_btn_a, upvote_btn_b])
160
  textbox.submit(user_ask, inputs=[state, chatbot1, chatbot2, textbox], outputs=[state, chatbot1, chatbot2, textbox,upvote_btn_a,upvote_btn_b])
161
  submit_btn.click(user_ask, inputs=[state, chatbot1, chatbot2, textbox], outputs=[state, chatbot1, chatbot2, textbox,upvote_btn_a,upvote_btn_b])
162
- upvote_btn_a.click(vote_up_model, inputs=[state, chatbot1], outputs=[chatbot1,upvote_btn_a,upvote_btn_b])
163
- upvote_btn_b.click(vote_down_model, inputs=[state, chatbot2], outputs=[chatbot2,upvote_btn_a,upvote_btn_b])
164
  with gr.Tab("Leaderboard"):
165
  leaderboard = gr.Dataframe()
166
  refresh_btn = gr.Button("Refresh Leaderboard")
 
91
 
92
  elo_ratings = update_elo_ratings(elo_ratings, winner, loser)
93
  write_elo_ratings(elo_ratings)
94
+ return ['Winner: '+state['last_bots'][winner_index],'Loser: '+state['last_bots'][1 - winner_index]]
95
 
96
+ def vote_up_model(state, chatbot,chatbot2):
97
  update_message = update_ratings(state, 0)
98
+ chatbot.append(update_message[0])
99
+ chatbot2.append(update_message[1])
100
+ return chatbot, gr.Button.update(interactive=False),gr.Button.update(interactive=False) # Disable voting buttons
101
+ def vote_down_model(state, chatbot,chatbot2):
102
+ update_message = update_ratings(state, 1)
103
+ chatbot2.append(update_message[0])
104
+ chatbot.append(update_message[1])
105
  return chatbot, gr.Button.update(interactive=False),gr.Button.update(interactive=False) # Disable voting buttons
106
 
107
  def user_ask(state, chatbot1, chatbot2, textbox):
 
165
  reset_btn.click(clear_chat, inputs=[state], outputs=[state, chatbot1, chatbot2, upvote_btn_a, upvote_btn_b])
166
  textbox.submit(user_ask, inputs=[state, chatbot1, chatbot2, textbox], outputs=[state, chatbot1, chatbot2, textbox,upvote_btn_a,upvote_btn_b])
167
  submit_btn.click(user_ask, inputs=[state, chatbot1, chatbot2, textbox], outputs=[state, chatbot1, chatbot2, textbox,upvote_btn_a,upvote_btn_b])
168
+ upvote_btn_a.click(vote_up_model, inputs=[state, chatbot1,chatbot2], outputs=[chatbot1,chatbot2,upvote_btn_a,upvote_btn_b])
169
+ upvote_btn_b.click(vote_down_model, inputs=[state, chatbot1,chatbot2], outputs=[chatbot1,chatbot2,upvote_btn_a,upvote_btn_b])
170
  with gr.Tab("Leaderboard"):
171
  leaderboard = gr.Dataframe()
172
  refresh_btn = gr.Button("Refresh Leaderboard")