Spaces:
Running
Running
use year for update interval
Browse files
app.py
CHANGED
|
@@ -302,7 +302,7 @@ def format_conversation_history(conversation_history):
|
|
| 302 |
|
| 303 |
def save_content_to_hf(vote_data, repo_name, folder_name, file_name):
|
| 304 |
"""
|
| 305 |
-
Save feedback content to Hugging Face repository
|
| 306 |
"""
|
| 307 |
# Serialize the content to JSON and encode it as bytes
|
| 308 |
json_content = json.dumps(vote_data, indent=4).encode("utf-8")
|
|
@@ -330,7 +330,7 @@ def save_content_to_hf(vote_data, repo_name, folder_name, file_name):
|
|
| 330 |
|
| 331 |
def load_content_from_hf(repo_name="SE-Arena/votes"):
|
| 332 |
"""
|
| 333 |
-
Read feedback content from a Hugging Face repository based on the current
|
| 334 |
|
| 335 |
Args:
|
| 336 |
repo_name (str): Hugging Face repository name.
|
|
@@ -339,18 +339,14 @@ def load_content_from_hf(repo_name="SE-Arena/votes"):
|
|
| 339 |
list: Aggregated feedback data read from the repository.
|
| 340 |
"""
|
| 341 |
vote_data = []
|
| 342 |
-
|
| 343 |
-
# Get the current year and quarter
|
| 344 |
-
now = datetime.now()
|
| 345 |
-
quarter = (now.month - 1) // 3 + 1
|
| 346 |
-
year_quarter = f"{now.year}_Q{quarter}"
|
| 347 |
|
| 348 |
try:
|
| 349 |
api = HfApi()
|
| 350 |
# List all files in the repository
|
| 351 |
for file in api.list_repo_files(repo_id=repo_name, repo_type="dataset"):
|
| 352 |
-
# Filter files by current year
|
| 353 |
-
if
|
| 354 |
continue
|
| 355 |
# Download and aggregate data
|
| 356 |
local_path = hf_hub_download(
|
|
@@ -1194,10 +1190,9 @@ with gr.Blocks() as app:
|
|
| 1194 |
"winner": winner_model,
|
| 1195 |
}
|
| 1196 |
|
| 1197 |
-
# Get the current year
|
| 1198 |
now = datetime.now()
|
| 1199 |
-
|
| 1200 |
-
folder_name = f"{now.year}_Q{quarter}"
|
| 1201 |
file_name = now.strftime("%Y%m%d_%H%M%S")
|
| 1202 |
|
| 1203 |
# Save feedback back to the Hugging Face dataset
|
|
|
|
| 302 |
|
| 303 |
def save_content_to_hf(vote_data, repo_name, folder_name, file_name):
|
| 304 |
"""
|
| 305 |
+
Save feedback content to Hugging Face repository.
|
| 306 |
"""
|
| 307 |
# Serialize the content to JSON and encode it as bytes
|
| 308 |
json_content = json.dumps(vote_data, indent=4).encode("utf-8")
|
|
|
|
| 330 |
|
| 331 |
def load_content_from_hf(repo_name="SE-Arena/votes"):
|
| 332 |
"""
|
| 333 |
+
Read feedback content from a Hugging Face repository based on the current year.
|
| 334 |
|
| 335 |
Args:
|
| 336 |
repo_name (str): Hugging Face repository name.
|
|
|
|
| 339 |
list: Aggregated feedback data read from the repository.
|
| 340 |
"""
|
| 341 |
vote_data = []
|
| 342 |
+
year = str(datetime.now().year)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 343 |
|
| 344 |
try:
|
| 345 |
api = HfApi()
|
| 346 |
# List all files in the repository
|
| 347 |
for file in api.list_repo_files(repo_id=repo_name, repo_type="dataset"):
|
| 348 |
+
# Filter files by current year
|
| 349 |
+
if year not in file:
|
| 350 |
continue
|
| 351 |
# Download and aggregate data
|
| 352 |
local_path = hf_hub_download(
|
|
|
|
| 1190 |
"winner": winner_model,
|
| 1191 |
}
|
| 1192 |
|
| 1193 |
+
# Get the current year
|
| 1194 |
now = datetime.now()
|
| 1195 |
+
folder_name = now.year
|
|
|
|
| 1196 |
file_name = now.strftime("%Y%m%d_%H%M%S")
|
| 1197 |
|
| 1198 |
# Save feedback back to the Hugging Face dataset
|