Spaces:
Sleeping
Sleeping
Update app.py
Browse filesRe introduced the playing tab
app.py
CHANGED
@@ -121,27 +121,20 @@ def extract_leaderboard_stats(game_name: str) -> pd.DataFrame:
|
|
121 |
|
122 |
return leaderboard_df
|
123 |
|
124 |
-
def generate_leaderboard_json():
|
125 |
-
"""Generate a JSON file containing leaderboard stats."""
|
126 |
-
available_games = get_available_games()
|
127 |
-
leaderboard = extract_leaderboard_stats("Aggregated Performance").to_dict(orient="records")
|
128 |
-
json_file = "results/leaderboard_stats.json"
|
129 |
-
with open(json_file, "w", encoding="utf-8") as f:
|
130 |
-
json.dump({"timestamp": datetime.utcnow().isoformat(), "leaderboard": leaderboard}, f, indent=4)
|
131 |
-
return json_file
|
132 |
-
|
133 |
with gr.Blocks() as interface:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
with gr.Tab("Leaderboard"):
|
135 |
gr.Markdown("# LLM Model Leaderboard\nTrack performance across different games!")
|
136 |
available_games = get_available_games()
|
137 |
leaderboard_game_dropdown = gr.Dropdown(available_games, label="Select Game", value="Aggregated Performance")
|
138 |
-
leaderboard_table = gr.Dataframe(headers=["agent_name", "agent_type", "# games", "total rewards", "avg_generation_time (sec)", "win-rate", "win vs_random (%)"])
|
139 |
-
|
140 |
-
|
141 |
-
download_component = gr.File(label="Download Leaderboard JSON")
|
142 |
-
|
143 |
-
leaderboard_game_dropdown.change(extract_leaderboard_stats, inputs=[leaderboard_game_dropdown], outputs=[leaderboard_table])
|
144 |
-
refresh_button.click(extract_leaderboard_stats, inputs=[leaderboard_game_dropdown], outputs=[leaderboard_table])
|
145 |
-
generate_button.click(generate_leaderboard_json, outputs=[download_component])
|
146 |
-
|
147 |
-
interface.launch()
|
|
|
121 |
|
122 |
return leaderboard_df
|
123 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
with gr.Blocks() as interface:
|
125 |
+
with gr.Tab("Game Arena"):
|
126 |
+
gr.Markdown("# Play Against LLMs\nChoose a game and an opponent to play!")
|
127 |
+
game_dropdown = gr.Dropdown(get_available_games()[1:], label="Select a Game")
|
128 |
+
opponent_dropdown = gr.Dropdown(["Random Bot", "LLM"], label="Choose Opponent")
|
129 |
+
play_button = gr.Button("Start Game")
|
130 |
+
game_output = gr.Textbox(label="Game Log")
|
131 |
+
|
132 |
+
play_button.click(lambda game, opponent: f"Game {game} started against {opponent}", inputs=[game_dropdown, opponent_dropdown], outputs=[game_output])
|
133 |
+
|
134 |
with gr.Tab("Leaderboard"):
|
135 |
gr.Markdown("# LLM Model Leaderboard\nTrack performance across different games!")
|
136 |
available_games = get_available_games()
|
137 |
leaderboard_game_dropdown = gr.Dropdown(available_games, label="Select Game", value="Aggregated Performance")
|
138 |
+
leaderboard_table = gr.Dataframe(value=extract_leaderboard_stats("Aggregated Performance"), headers=["agent_name", "agent_type", "# games", "total rewards", "avg_generation_time (sec)", "win-rate", "win vs_random (%)"], every=5)
|
139 |
+
|
140 |
+
interface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|