Spaces:
Running
Running
zhimin-z
commited on
Commit
·
d83f64e
1
Parent(s):
75d304c
refine
Browse files
app.py
CHANGED
|
@@ -33,7 +33,7 @@ openai_client = OpenAI(api_key=api_key, base_url=base_url)
|
|
| 33 |
LEADERBOARD_REPO = "SWE-Arena/leaderboard_data"
|
| 34 |
VOTE_REPO = "SWE-Arena/vote_data"
|
| 35 |
CONVERSATION_REPO = "SWE-Arena/conversation_data"
|
| 36 |
-
LEADERBOARD_FILE = "model-arena
|
| 37 |
|
| 38 |
# Timeout in seconds for model responses
|
| 39 |
TIMEOUT = 90
|
|
@@ -394,7 +394,7 @@ def get_leaderboard_data(vote_entry=None, use_cache=True):
|
|
| 394 |
try:
|
| 395 |
cached_path = hf_hub_download(
|
| 396 |
repo_id=LEADERBOARD_REPO,
|
| 397 |
-
filename=LEADERBOARD_FILE,
|
| 398 |
repo_type="dataset",
|
| 399 |
)
|
| 400 |
with open(cached_path, "r") as f:
|
|
@@ -412,6 +412,16 @@ def get_leaderboard_data(vote_entry=None, use_cache=True):
|
|
| 412 |
"PageRank Score": 2,
|
| 413 |
}
|
| 414 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 415 |
return leaderboard_data
|
| 416 |
except Exception as e:
|
| 417 |
print(f"No cached leaderboard found, computing from votes...")
|
|
@@ -617,7 +627,7 @@ def get_leaderboard_data(vote_entry=None, use_cache=True):
|
|
| 617 |
|
| 618 |
upload_file(
|
| 619 |
path_or_fileobj=file_like_object,
|
| 620 |
-
path_in_repo=LEADERBOARD_FILE,
|
| 621 |
repo_id=LEADERBOARD_REPO,
|
| 622 |
repo_type="dataset",
|
| 623 |
token=HfApi().token,
|
|
@@ -1431,7 +1441,7 @@ with gr.Blocks(title="SWE-Model-Arena", theme=gr.themes.Soft()) as app:
|
|
| 1431 |
}
|
| 1432 |
|
| 1433 |
# Get the current datetime for file naming
|
| 1434 |
-
file_name = f"
|
| 1435 |
|
| 1436 |
# Save feedback back to the Hugging Face dataset
|
| 1437 |
save_content_to_hf(
|
|
|
|
| 33 |
LEADERBOARD_REPO = "SWE-Arena/leaderboard_data"
|
| 34 |
VOTE_REPO = "SWE-Arena/vote_data"
|
| 35 |
CONVERSATION_REPO = "SWE-Arena/conversation_data"
|
| 36 |
+
LEADERBOARD_FILE = "model-arena"
|
| 37 |
|
| 38 |
# Timeout in seconds for model responses
|
| 39 |
TIMEOUT = 90
|
|
|
|
| 394 |
try:
|
| 395 |
cached_path = hf_hub_download(
|
| 396 |
repo_id=LEADERBOARD_REPO,
|
| 397 |
+
filename=f'{LEADERBOARD_FILE}.json',
|
| 398 |
repo_type="dataset",
|
| 399 |
)
|
| 400 |
with open(cached_path, "r") as f:
|
|
|
|
| 412 |
"PageRank Score": 2,
|
| 413 |
}
|
| 414 |
)
|
| 415 |
+
# Add Website column if it doesn't exist
|
| 416 |
+
if "Website" not in leaderboard_data.columns:
|
| 417 |
+
leaderboard_data["Website"] = leaderboard_data["Model"].map(
|
| 418 |
+
lambda x: model_links.get(x, "")
|
| 419 |
+
)
|
| 420 |
+
# Reorder columns to place Website after Model
|
| 421 |
+
cols = leaderboard_data.columns.tolist()
|
| 422 |
+
model_idx = cols.index("Model")
|
| 423 |
+
cols.insert(model_idx + 1, cols.pop(cols.index("Website")))
|
| 424 |
+
leaderboard_data = leaderboard_data[cols]
|
| 425 |
return leaderboard_data
|
| 426 |
except Exception as e:
|
| 427 |
print(f"No cached leaderboard found, computing from votes...")
|
|
|
|
| 627 |
|
| 628 |
upload_file(
|
| 629 |
path_or_fileobj=file_like_object,
|
| 630 |
+
path_in_repo=f'{LEADERBOARD_FILE}.json',
|
| 631 |
repo_id=LEADERBOARD_REPO,
|
| 632 |
repo_type="dataset",
|
| 633 |
token=HfApi().token,
|
|
|
|
| 1441 |
}
|
| 1442 |
|
| 1443 |
# Get the current datetime for file naming
|
| 1444 |
+
file_name = f"{LEADERBOARD_FILE}/{datetime.now().strftime('%Y%m%d_%H%M%S')}"
|
| 1445 |
|
| 1446 |
# Save feedback back to the Hugging Face dataset
|
| 1447 |
save_content_to_hf(
|