Skip to content

Commit

Permalink
Remove loading of Copilot Arena tab when env variable is not set (#3645)
Browse files Browse the repository at this point in the history
  • Loading branch information
adityamittal13 authored Dec 20, 2024
1 parent 7a912c7 commit 8664268
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
9 changes: 0 additions & 9 deletions fastchat/serve/monitor/copilot_arena.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@

copilot_arena_leaderboard_url = os.getenv("COPILOT_ARENA_LEADERBOARD_URL")

if not copilot_arena_leaderboard_url:
raise ValueError(
"COPILOT_ARENA_LEADERBOARD_URL environment variable is not set. "
"Please configure it to a valid URL."
)


def process_copilot_arena_leaderboard(leaderboard):
leaderboard = leaderboard.copy().loc[leaderboard["visibility"] == "public"]
Expand Down Expand Up @@ -41,9 +35,6 @@ def process_copilot_arena_leaderboard(leaderboard):


def build_copilot_arena_tab():
if copilot_arena_leaderboard_url is None:
print("Copilot Arena Leaderboard URL is not set. Skipping this leaderboard.")
return
response = requests.get(copilot_arena_leaderboard_url)
if response.status_code == 200:
leaderboard = pd.DataFrame(response.json()["elo_data"])
Expand Down
20 changes: 13 additions & 7 deletions fastchat/serve/monitor/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1034,15 +1034,21 @@ def build_leaderboard_tab(
build_full_leaderboard_tab(
elo_results_text, model_table_df, model_to_score
)
try:
with gr.Tab("Copilot Arena Leaderboard", id=5):
from fastchat.serve.monitor.copilot_arena import (
build_copilot_arena_tab,
)

from fastchat.serve.monitor.copilot_arena import (
build_copilot_arena_tab,
copilot_arena_leaderboard_url,
)

if copilot_arena_leaderboard_url:
with gr.Tab("Copilot Arena Leaderboard", id=5):
build_copilot_arena_tab()
except Exception as e:
print(f"Unable to build Copilot Arena's Leaderboard. Error: {e}")
else:
print(
"Unable to build Copilot Arena's Leaderboard. "
"COPILOT_ARENA_LEADERBOARD_URL environment variable is not set. "
"Please configure it to a valid URL."
)

if not show_plot:
gr.Markdown(
Expand Down

0 comments on commit 8664268

Please sign in to comment.