Skip to content

Commit 32cc477

Browse files
committed
Handling situations where Copilot Arena's Leaderboard is not set / unable to be built
1 parent 36f8591 commit 32cc477

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

fastchat/serve/monitor/copilot_arena.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ def process_copilot_arena_leaderboard(leaderboard):
4141

4242

4343
def build_copilot_arena_tab():
44+
if copilot_arena_leaderboard_url is None:
45+
print("Copilot Arena Leaderboard URL is not set. Skipping this leaderboard.")
46+
return
4447
response = requests.get(copilot_arena_leaderboard_url)
4548
if response.status_code == 200:
4649
leaderboard = pd.DataFrame(response.json()["elo_data"])

fastchat/serve/monitor/monitor.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -388,9 +388,7 @@ def highlight_rank_max(s):
388388
(
389389
"color: green; font-weight: bold"
390390
if v > 0
391-
else "color: red; font-weight: bold"
392-
if v < 0
393-
else ""
391+
else "color: red; font-weight: bold" if v < 0 else ""
394392
)
395393
for v in s
396394
]
@@ -493,9 +491,9 @@ def update_leaderboard_and_plots(category, filters):
493491
arena_values = get_arena_table(
494492
arena_df,
495493
model_table_df,
496-
arena_subset_df=arena_subset_df
497-
if category != "Overall"
498-
else arena_overall_sc_df,
494+
arena_subset_df=(
495+
arena_subset_df if category != "Overall" else arena_overall_sc_df
496+
),
499497
hidden_models=(
500498
None
501499
if len(filters) > 0 and "Show Deprecated" in filters
@@ -1052,10 +1050,15 @@ def build_leaderboard_tab(
10521050
build_full_leaderboard_tab(
10531051
elo_results_text, model_table_df, model_to_score
10541052
)
1055-
with gr.Tab("Copilot Arena Leaderboard", id=5):
1056-
from fastchat.serve.monitor.copilot_arena import build_copilot_arena_tab
1053+
try:
1054+
with gr.Tab("Copilot Arena Leaderboard", id=5):
1055+
from fastchat.serve.monitor.copilot_arena import (
1056+
build_copilot_arena_tab,
1057+
)
10571058

1058-
build_copilot_arena_tab()
1059+
build_copilot_arena_tab()
1060+
except Exception as e:
1061+
print(f"Unable to build Copilot Arena's Leaderboard. Error: {e}")
10591062

10601063
if not show_plot:
10611064
gr.Markdown(

0 commit comments

Comments
 (0)