Spaces:
Sleeping
Sleeping
Updating the JSON files
Browse files
app.py
CHANGED
@@ -56,6 +56,13 @@ def calculate_leaderboard(selected_game: str) -> pd.DataFrame:
|
|
56 |
leaderboard_df.rename(columns={"index": "LLM Model"}, inplace=True)
|
57 |
return leaderboard_df
|
58 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
# Gradio Interface
|
60 |
with gr.Blocks() as interface:
|
61 |
with gr.Tab("Game Arena"):
|
@@ -66,11 +73,18 @@ with gr.Blocks() as interface:
|
|
66 |
|
67 |
game_dropdown = gr.Dropdown(choices=games_list, label="Select Game", value=games_list[0])
|
68 |
leaderboard_table = gr.Dataframe(value=calculate_leaderboard(games_list[0]), label="Leaderboard")
|
|
|
|
|
69 |
|
70 |
def update_leaderboard(selected_game):
|
71 |
"""Updates the leaderboard table based on the selected game."""
|
72 |
return calculate_leaderboard(selected_game)
|
73 |
|
|
|
|
|
|
|
|
|
74 |
game_dropdown.change(fn=update_leaderboard, inputs=[game_dropdown], outputs=[leaderboard_table])
|
|
|
75 |
|
76 |
interface.launch()
|
|
|
56 |
leaderboard_df.rename(columns={"index": "LLM Model"}, inplace=True)
|
57 |
return leaderboard_df
|
58 |
|
59 |
+
def generate_stats_file(model_name: str):
|
60 |
+
"""Generate a JSON file with detailed statistics for the selected LLM model."""
|
61 |
+
file_path = f"{model_name}_stats.json"
|
62 |
+
with open(file_path, "w") as f:
|
63 |
+
json.dump(results_tracker.get(model_name, {}), f, indent=4)
|
64 |
+
return file_path
|
65 |
+
|
66 |
# Gradio Interface
|
67 |
with gr.Blocks() as interface:
|
68 |
with gr.Tab("Game Arena"):
|
|
|
73 |
|
74 |
game_dropdown = gr.Dropdown(choices=games_list, label="Select Game", value=games_list[0])
|
75 |
leaderboard_table = gr.Dataframe(value=calculate_leaderboard(games_list[0]), label="Leaderboard")
|
76 |
+
model_dropdown = gr.Dropdown(choices=llm_models, label="Select LLM Model")
|
77 |
+
download_button = gr.File(label="Download Statistics File")
|
78 |
|
79 |
def update_leaderboard(selected_game):
|
80 |
"""Updates the leaderboard table based on the selected game."""
|
81 |
return calculate_leaderboard(selected_game)
|
82 |
|
83 |
+
def provide_download_file(model_name):
|
84 |
+
"""Creates a downloadable JSON file with stats for the selected model."""
|
85 |
+
return generate_stats_file(model_name)
|
86 |
+
|
87 |
game_dropdown.change(fn=update_leaderboard, inputs=[game_dropdown], outputs=[leaderboard_table])
|
88 |
+
model_dropdown.change(fn=provide_download_file, inputs=[model_dropdown], outputs=[download_button])
|
89 |
|
90 |
interface.launch()
|