Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -27,10 +27,12 @@ import requests
|
|
27 |
import os
|
28 |
|
29 |
def get_user_elo_ratings():
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
|
|
|
|
34 |
def update_elo_rating(new_rating,winner,loser):
|
35 |
# Fetch the current dataset
|
36 |
elo_ratings = get_user_elo_ratings()
|
@@ -153,10 +155,12 @@ import pandas as pd
|
|
153 |
# Function to generate leaderboard data
|
154 |
|
155 |
def generate_leaderboard():
|
156 |
-
|
|
|
|
|
157 |
|
158 |
# Convert the Hugging Face dataset to a pandas DataFrame
|
159 |
-
leaderboard_data = pd.DataFrame(
|
160 |
|
161 |
# Rename columns to 'Chatbot' and 'ELO Score'
|
162 |
leaderboard_data.columns = ['Chatbot', 'ELO Score']
|
@@ -169,7 +173,6 @@ def generate_leaderboard():
|
|
169 |
|
170 |
return leaderboard_data
|
171 |
|
172 |
-
|
173 |
def refresh_leaderboard():
|
174 |
return generate_leaderboard()
|
175 |
# Gradio interface setup
|
|
|
27 |
import os
|
28 |
|
29 |
def get_user_elo_ratings():
|
30 |
+
global global_elo_ratings
|
31 |
+
if global_elo_ratings is None:
|
32 |
+
dataset = load_dataset("rwitz/mistral-elo-ratings", download_mode="force_redownload")
|
33 |
+
global_elo_ratings = dataset['train'] # or the relevant split
|
34 |
+
return global_elo_ratings
|
35 |
+
|
36 |
def update_elo_rating(new_rating,winner,loser):
|
37 |
# Fetch the current dataset
|
38 |
elo_ratings = get_user_elo_ratings()
|
|
|
155 |
# Function to generate leaderboard data
|
156 |
|
157 |
def generate_leaderboard():
|
158 |
+
global global_elo_ratings
|
159 |
+
if global_elo_ratings is None:
|
160 |
+
global_elo_ratings = get_user_elo_ratings()
|
161 |
|
162 |
# Convert the Hugging Face dataset to a pandas DataFrame
|
163 |
+
leaderboard_data = pd.DataFrame(global_elo_ratings)
|
164 |
|
165 |
# Rename columns to 'Chatbot' and 'ELO Score'
|
166 |
leaderboard_data.columns = ['Chatbot', 'ELO Score']
|
|
|
173 |
|
174 |
return leaderboard_data
|
175 |
|
|
|
176 |
def refresh_leaderboard():
|
177 |
return generate_leaderboard()
|
178 |
# Gradio interface setup
|