Spaces:
Runtime error
Runtime error
change the leaderboard frequency up to 3 months
Browse files
app.py
CHANGED
@@ -286,12 +286,7 @@ def chat_with_models(
|
|
286 |
|
287 |
def save_content_to_hf(feedback_data, repo_name):
|
288 |
"""
|
289 |
-
Save feedback content to Hugging Face repository organized by
|
290 |
-
|
291 |
-
Args:
|
292 |
-
content (dict): Feedback data to be saved.
|
293 |
-
month_year (str): Year and month string in the format "YYYY_MM".
|
294 |
-
repo_name (str): Hugging Face repository name.
|
295 |
"""
|
296 |
# Serialize the content to JSON and encode it as bytes
|
297 |
json_content = json.dumps(feedback_data, indent=4).encode("utf-8")
|
@@ -299,12 +294,14 @@ def save_content_to_hf(feedback_data, repo_name):
|
|
299 |
# Create a binary file-like object
|
300 |
file_like_object = io.BytesIO(json_content)
|
301 |
|
302 |
-
# Get the current year and
|
303 |
-
|
304 |
-
|
|
|
|
|
305 |
|
306 |
# Define the path in the repository
|
307 |
-
filename = f"{
|
308 |
|
309 |
# Ensure the user is authenticated with HF
|
310 |
token = HfFolder.get_token()
|
@@ -323,7 +320,7 @@ def save_content_to_hf(feedback_data, repo_name):
|
|
323 |
|
324 |
def load_content_from_hf(repo_name="SE-Arena/votes"):
|
325 |
"""
|
326 |
-
Read feedback content from a Hugging Face repository based on the current
|
327 |
|
328 |
Args:
|
329 |
repo_name (str): Hugging Face repository name.
|
@@ -331,22 +328,24 @@ def load_content_from_hf(repo_name="SE-Arena/votes"):
|
|
331 |
Returns:
|
332 |
list: Aggregated feedback data read from the repository.
|
333 |
"""
|
334 |
-
|
335 |
-
# Get the current year and month
|
336 |
-
year_month = datetime.now().strftime("%Y_%m")
|
337 |
feedback_data = []
|
338 |
|
|
|
|
|
|
|
|
|
|
|
339 |
try:
|
340 |
api = HfApi()
|
341 |
# List all files in the repository
|
342 |
repo_files = api.list_repo_files(repo_id=repo_name, repo_type="dataset")
|
343 |
|
344 |
# Filter files by current year and month
|
345 |
-
leaderboard_files = [file for file in repo_files if
|
346 |
|
347 |
if not leaderboard_files:
|
348 |
raise FileNotFoundError(
|
349 |
-
f"No feedback files found for {
|
350 |
)
|
351 |
|
352 |
# Download and aggregate data
|
|
|
286 |
|
287 |
def save_content_to_hf(feedback_data, repo_name):
|
288 |
"""
|
289 |
+
Save feedback content to Hugging Face repository organized by quarter.
|
|
|
|
|
|
|
|
|
|
|
290 |
"""
|
291 |
# Serialize the content to JSON and encode it as bytes
|
292 |
json_content = json.dumps(feedback_data, indent=4).encode("utf-8")
|
|
|
294 |
# Create a binary file-like object
|
295 |
file_like_object = io.BytesIO(json_content)
|
296 |
|
297 |
+
# Get the current year and quarter
|
298 |
+
now = datetime.now()
|
299 |
+
quarter = (now.month - 1) // 3 + 1
|
300 |
+
year_quarter = f"{now.year}_Q{quarter}"
|
301 |
+
day_hour_minute_second = now.strftime("%d_%H%M%S")
|
302 |
|
303 |
# Define the path in the repository
|
304 |
+
filename = f"{year_quarter}/{day_hour_minute_second}.json"
|
305 |
|
306 |
# Ensure the user is authenticated with HF
|
307 |
token = HfFolder.get_token()
|
|
|
320 |
|
321 |
def load_content_from_hf(repo_name="SE-Arena/votes"):
|
322 |
"""
|
323 |
+
Read feedback content from a Hugging Face repository based on the current quarter.
|
324 |
|
325 |
Args:
|
326 |
repo_name (str): Hugging Face repository name.
|
|
|
328 |
Returns:
|
329 |
list: Aggregated feedback data read from the repository.
|
330 |
"""
|
|
|
|
|
|
|
331 |
feedback_data = []
|
332 |
|
333 |
+
# Get the current year and quarter
|
334 |
+
now = datetime.now()
|
335 |
+
quarter = (now.month - 1) // 3 + 1
|
336 |
+
year_quarter = f"{now.year}_Q{quarter}"
|
337 |
+
|
338 |
try:
|
339 |
api = HfApi()
|
340 |
# List all files in the repository
|
341 |
repo_files = api.list_repo_files(repo_id=repo_name, repo_type="dataset")
|
342 |
|
343 |
# Filter files by current year and month
|
344 |
+
leaderboard_files = [file for file in repo_files if year_quarter in file]
|
345 |
|
346 |
if not leaderboard_files:
|
347 |
raise FileNotFoundError(
|
348 |
+
f"No feedback files found for {year_quarter} in {repo_name}."
|
349 |
)
|
350 |
|
351 |
# Download and aggregate data
|