Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -164,8 +164,10 @@ def update_ratings(state, winner_index, collection, category):
|
|
| 164 |
winner = next(entry['original_model'] for entry in chatbots_data if entry['adapter'] == winner_adapter)
|
| 165 |
loser = next(entry['original_model'] for entry in chatbots_data if entry['adapter'] == loser_adapter)
|
| 166 |
|
| 167 |
-
|
| 168 |
-
|
|
|
|
|
|
|
| 169 |
return [('Winner: ', winner), ('Loser: ', loser)]
|
| 170 |
except Exception as e:
|
| 171 |
print(f"Error updating ratings: {str(e)}")
|
|
@@ -177,17 +179,17 @@ async def vote_up_model(state, chatbot, chatbot2, character_name, character_desc
|
|
| 177 |
# Disable both upvote buttons immediately
|
| 178 |
yield chatbot, chatbot2, gr.Button.update(interactive=False, value="π Upvoted"), gr.Button.update(interactive=False), gr.Textbox.update(interactive=False), gr.Button.update(interactive=False)
|
| 179 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 180 |
# Process sentiment analysis asynchronously
|
| 181 |
-
|
| 182 |
-
top_category = await sentiment_task
|
| 183 |
|
| 184 |
if top_category:
|
| 185 |
-
|
| 186 |
-
chatbot.append(update_message[0])
|
| 187 |
-
chatbot2.append(update_message[1])
|
| 188 |
-
|
| 189 |
-
yield chatbot, chatbot2, gr.Button.update(interactive=False, value="π Upvoted"), gr.Button.update(interactive=False), gr.Textbox.update(interactive=False), gr.Button.update(interactive=False)
|
| 190 |
-
|
| 191 |
async def vote_down_model(state, chatbot, chatbot2, character_name, character_description, user_name):
|
| 192 |
user_input = format_prompt(state, 1, character_name, character_description, user_name)
|
| 193 |
collection = init_database()
|
|
@@ -195,17 +197,17 @@ async def vote_down_model(state, chatbot, chatbot2, character_name, character_de
|
|
| 195 |
# Disable both upvote buttons immediately
|
| 196 |
yield chatbot, chatbot2, gr.Button.update(interactive=False), gr.Button.update(interactive=False, value="π Upvoted"), gr.Textbox.update(interactive=False), gr.Button.update(interactive=False)
|
| 197 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 198 |
# Process sentiment analysis asynchronously
|
| 199 |
-
|
| 200 |
-
top_category = await sentiment_task
|
| 201 |
|
| 202 |
if top_category:
|
| 203 |
-
|
| 204 |
-
chatbot2.append(update_message[0])
|
| 205 |
-
chatbot.append(update_message[1])
|
| 206 |
-
|
| 207 |
-
yield chatbot, chatbot2, gr.Button.update(interactive=False), gr.Button.update(interactive=False, value="π Upvoted"), gr.Textbox.update(interactive=False), gr.Button.update(interactive=False)
|
| 208 |
-
|
| 209 |
async def user_ask(state, chatbot1, chatbot2, textbox, character_name, character_description, user_name):
|
| 210 |
if character_name and len(character_name) > 20:
|
| 211 |
character_name = character_name[:20] # Limit character name to 20 characters
|
|
|
|
| 164 |
winner = next(entry['original_model'] for entry in chatbots_data if entry['adapter'] == winner_adapter)
|
| 165 |
loser = next(entry['original_model'] for entry in chatbots_data if entry['adapter'] == loser_adapter)
|
| 166 |
|
| 167 |
+
if category != "overall":
|
| 168 |
+
elo_ratings = update_elo_ratings(elo_ratings, winner_adapter, loser_adapter, category)
|
| 169 |
+
update_elo_rating(collection, elo_ratings, winner_adapter, loser_adapter, category)
|
| 170 |
+
|
| 171 |
return [('Winner: ', winner), ('Loser: ', loser)]
|
| 172 |
except Exception as e:
|
| 173 |
print(f"Error updating ratings: {str(e)}")
|
|
|
|
| 179 |
# Disable both upvote buttons immediately
|
| 180 |
yield chatbot, chatbot2, gr.Button.update(interactive=False, value="π Upvoted"), gr.Button.update(interactive=False), gr.Textbox.update(interactive=False), gr.Button.update(interactive=False)
|
| 181 |
|
| 182 |
+
# Update ratings and yield winner/loser immediately
|
| 183 |
+
update_message = update_ratings(state, 0, collection, "overall")
|
| 184 |
+
chatbot.append(update_message[0])
|
| 185 |
+
chatbot2.append(update_message[1])
|
| 186 |
+
yield chatbot, chatbot2, gr.Button.update(interactive=False, value="π Upvoted"), gr.Button.update(interactive=False), gr.Textbox.update(interactive=False), gr.Button.update(interactive=False)
|
| 187 |
+
|
| 188 |
# Process sentiment analysis asynchronously
|
| 189 |
+
top_category = await classify_vote(user_input)
|
|
|
|
| 190 |
|
| 191 |
if top_category:
|
| 192 |
+
update_ratings(state, 0, collection, top_category)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 193 |
async def vote_down_model(state, chatbot, chatbot2, character_name, character_description, user_name):
|
| 194 |
user_input = format_prompt(state, 1, character_name, character_description, user_name)
|
| 195 |
collection = init_database()
|
|
|
|
| 197 |
# Disable both upvote buttons immediately
|
| 198 |
yield chatbot, chatbot2, gr.Button.update(interactive=False), gr.Button.update(interactive=False, value="π Upvoted"), gr.Textbox.update(interactive=False), gr.Button.update(interactive=False)
|
| 199 |
|
| 200 |
+
# Update ratings and yield winner/loser immediately
|
| 201 |
+
update_message = update_ratings(state, 1, collection, "overall")
|
| 202 |
+
chatbot2.append(update_message[0])
|
| 203 |
+
chatbot.append(update_message[1])
|
| 204 |
+
yield chatbot, chatbot2, gr.Button.update(interactive=False), gr.Button.update(interactive=False, value="π Upvoted"), gr.Textbox.update(interactive=False), gr.Button.update(interactive=False)
|
| 205 |
+
|
| 206 |
# Process sentiment analysis asynchronously
|
| 207 |
+
top_category = await classify_vote(user_input)
|
|
|
|
| 208 |
|
| 209 |
if top_category:
|
| 210 |
+
update_ratings(state, 1, collection, top_category)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 211 |
async def user_ask(state, chatbot1, chatbot2, textbox, character_name, character_description, user_name):
|
| 212 |
if character_name and len(character_name) > 20:
|
| 213 |
character_name = character_name[:20] # Limit character name to 20 characters
|