rwitz commited on
Commit
8e50330
1 Parent(s): 628ad2b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -124,13 +124,15 @@ def update_ratings(state, winner_index, collection):
124
  update_elo_rating(collection, elo_ratings, winner, loser)
125
  return [('Winner: ', winner.replace('rwitz/','').replace('-lora','')), ('Loser: ', loser.replace('rwitz/','').replace('-lora',''))]
126
 
127
- def vote_up_model(state, chatbot, chatbot2, collection):
 
128
  update_message = update_ratings(state, 0, collection)
129
  chatbot.append(update_message[0])
130
  chatbot2.append(update_message[1])
131
  return chatbot, chatbot2, gr.Button.update(interactive=False), gr.Button.update(interactive=False), gr.Textbox.update(interactive=False), gr.Button.update(interactive=False)
132
 
133
- def vote_down_model(state, chatbot, chatbot2, collection):
 
134
  update_message = update_ratings(state, 1, collection)
135
  chatbot2.append(update_message[0])
136
  chatbot.append(update_message[1])
@@ -203,9 +205,8 @@ with gr.Blocks() as demo:
203
  submit_btn.click(user_ask, inputs=[state, chatbot1, chatbot2, textbox], outputs=[state, chatbot1, chatbot2, textbox, upvote_btn_a, upvote_btn_b], queue=True)
204
 
205
  collection = init_database()
206
- upvote_btn_a.click(vote_up_model, inputs=[state, chatbot1, chatbot2, collection], outputs=[chatbot1, chatbot2, upvote_btn_a, upvote_btn_b, textbox, submit_btn])
207
- upvote_btn_b.click(vote_down_model, inputs=[state, chatbot1, chatbot2, collection], outputs=[chatbot1, chatbot2, upvote_btn_a, upvote_btn_b, textbox, submit_btn])
208
-
209
  with gr.Tab("Leaderboard"):
210
  try:
211
  leaderboard = gr.Dataframe(refresh_leaderboard(collection))
 
124
  update_elo_rating(collection, elo_ratings, winner, loser)
125
  return [('Winner: ', winner.replace('rwitz/','').replace('-lora','')), ('Loser: ', loser.replace('rwitz/','').replace('-lora',''))]
126
 
127
+ def vote_up_model(state, chatbot, chatbot2):
128
+ collection = init_database()
129
  update_message = update_ratings(state, 0, collection)
130
  chatbot.append(update_message[0])
131
  chatbot2.append(update_message[1])
132
  return chatbot, chatbot2, gr.Button.update(interactive=False), gr.Button.update(interactive=False), gr.Textbox.update(interactive=False), gr.Button.update(interactive=False)
133
 
134
+ def vote_down_model(state, chatbot, chatbot2):
135
+ collection = init_database()
136
  update_message = update_ratings(state, 1, collection)
137
  chatbot2.append(update_message[0])
138
  chatbot.append(update_message[1])
 
205
  submit_btn.click(user_ask, inputs=[state, chatbot1, chatbot2, textbox], outputs=[state, chatbot1, chatbot2, textbox, upvote_btn_a, upvote_btn_b], queue=True)
206
 
207
  collection = init_database()
208
+ upvote_btn_a.click(vote_up_model, inputs=[state, chatbot1, chatbot2], outputs=[chatbot1, chatbot2, upvote_btn_a, upvote_btn_b, textbox, submit_btn])
209
+ upvote_btn_b.click(vote_down_model, inputs=[state, chatbot1, chatbot2], outputs=[chatbot1, chatbot2, upvote_btn_a, upvote_btn_b, textbox, submit_btn])
 
210
  with gr.Tab("Leaderboard"):
211
  try:
212
  leaderboard = gr.Dataframe(refresh_leaderboard(collection))