Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -275,14 +275,26 @@ def generate_leaderboard(collection):
|
|
275 |
for row in rows:
|
276 |
bot_name = row['bot_name']
|
277 |
original_model = next(entry['original_model'] for entry in chatbots_data if entry['adapter'] == bot_name)
|
|
|
|
|
|
|
|
|
|
|
278 |
total_elo = sum(category['elo_rating'] for category in row['categories'].values())
|
279 |
total_games = sum(category['games_played'] for category in row['categories'].values())
|
280 |
avg_elo = total_elo / len(row['categories']) if len(row['categories']) > 0 else 0
|
281 |
-
|
|
|
282 |
|
283 |
-
|
|
|
|
|
|
|
284 |
leaderboard_data['Avg ELO Score'] = leaderboard_data['Avg ELO Score'].round().astype(int)
|
|
|
|
|
285 |
leaderboard_data = leaderboard_data.sort_values('Avg ELO Score', ascending=False)
|
|
|
286 |
return leaderboard_data
|
287 |
def refresh_leaderboard():
|
288 |
collection = init_database()
|
|
|
275 |
for row in rows:
|
276 |
bot_name = row['bot_name']
|
277 |
original_model = next(entry['original_model'] for entry in chatbots_data if entry['adapter'] == bot_name)
|
278 |
+
|
279 |
+
category_data = []
|
280 |
+
for category, data in row['categories'].items():
|
281 |
+
category_data.append(f"{category}: {data['elo_rating']}")
|
282 |
+
|
283 |
total_elo = sum(category['elo_rating'] for category in row['categories'].values())
|
284 |
total_games = sum(category['games_played'] for category in row['categories'].values())
|
285 |
avg_elo = total_elo / len(row['categories']) if len(row['categories']) > 0 else 0
|
286 |
+
|
287 |
+
leaderboard_data.append([original_model, avg_elo, total_games] + category_data)
|
288 |
|
289 |
+
categories = list(row['categories'].keys())
|
290 |
+
columns = ['Chatbot', 'Avg ELO Score', 'Total Games Played'] + categories
|
291 |
+
|
292 |
+
leaderboard_data = pd.DataFrame(leaderboard_data, columns=columns)
|
293 |
leaderboard_data['Avg ELO Score'] = leaderboard_data['Avg ELO Score'].round().astype(int)
|
294 |
+
|
295 |
+
# Sort by average ELO score in descending order
|
296 |
leaderboard_data = leaderboard_data.sort_values('Avg ELO Score', ascending=False)
|
297 |
+
|
298 |
return leaderboard_data
|
299 |
def refresh_leaderboard():
|
300 |
collection = init_database()
|