diff --git a/fastchat/serve/monitor/copilot_arena.py b/fastchat/serve/monitor/copilot_arena.py index 80786e341..369115856 100644 --- a/fastchat/serve/monitor/copilot_arena.py +++ b/fastchat/serve/monitor/copilot_arena.py @@ -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"] @@ -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"]) diff --git a/fastchat/serve/monitor/monitor.py b/fastchat/serve/monitor/monitor.py index 9f7e0dd08..f21cf4a58 100644 --- a/fastchat/serve/monitor/monitor.py +++ b/fastchat/serve/monitor/monitor.py @@ -1035,11 +1035,17 @@ def build_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 not copilot_arena_leaderboard_url: + raise ValueError( + "COPILOT_ARENA_LEADERBOARD_URL environment variable is not set. " + "Please configure it to a valid 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}")