Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -155,17 +155,20 @@ async def chat_with_bots(user_input, state, character_name, character_descriptio
|
|
155 |
)
|
156 |
return bot1_response.replace("<|im_end|>",""), bot2_response.replace("<|im_end|>","")
|
157 |
def update_ratings(state, winner_index, collection, category):
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
|
|
|
|
|
|
169 |
def vote_up_model(state, chatbot, chatbot2, character_name, character_description, user_name):
|
170 |
user_input = format_prompt(state, 0, character_name, character_description, user_name)
|
171 |
collection = init_database()
|
|
|
155 |
)
|
156 |
return bot1_response.replace("<|im_end|>",""), bot2_response.replace("<|im_end|>","")
|
157 |
def update_ratings(state, winner_index, collection, category):
|
158 |
+
try:
|
159 |
+
elo_ratings = get_user_elo_ratings(collection)
|
160 |
+
winner_adapter = state['last_bots'][winner_index]
|
161 |
+
loser_adapter = state['last_bots'][1 - winner_index]
|
162 |
+
|
163 |
+
winner = next(entry['original_model'] for entry in chatbots_data if entry['adapter'] == winner_adapter)
|
164 |
+
loser = next(entry['original_model'] for entry in chatbots_data if entry['adapter'] == loser_adapter)
|
165 |
+
|
166 |
+
elo_ratings = update_elo_ratings(elo_ratings, winner_adapter, loser_adapter, category)
|
167 |
+
update_elo_rating(collection, elo_ratings, winner_adapter, loser_adapter, category)
|
168 |
+
return [('Winner: ', winner), ('Loser: ', loser)]
|
169 |
+
except Exception as e:
|
170 |
+
print(f"Error updating ratings: {str(e)}")
|
171 |
+
return [('Error', 'Failed to update ratings.'), ('Error', 'Failed to update ratings.')]
|
172 |
def vote_up_model(state, chatbot, chatbot2, character_name, character_description, user_name):
|
173 |
user_input = format_prompt(state, 0, character_name, character_description, user_name)
|
174 |
collection = init_database()
|