lcipolina commited on
Commit
261cee6
·
verified ·
1 Parent(s): 1ad7c66

Update app.py

Browse files

Added comments

Files changed (1) hide show
  1. app.py +12 -0
app.py CHANGED
@@ -123,19 +123,31 @@ def extract_leaderboard_stats(game_name: str) -> pd.DataFrame:
123
  return leaderboard_df
124
 
125
  with gr.Blocks() as interface:
 
126
  with gr.Tab("Game Arena"):
127
  gr.Markdown("# Play Against LLMs\nChoose a game and an opponent to play!")
 
128
  game_dropdown = gr.Dropdown(get_available_games(include_aggregated=False), label="Select a Game")
 
129
  opponent_dropdown = gr.Dropdown(["Random Bot", "LLM"], label="Choose Opponent")
 
130
  play_button = gr.Button("Start Game")
 
131
  game_output = gr.Textbox(label="Game Log")
132
 
 
133
  play_button.click(lambda game, opponent: f"Game {game} started against {opponent}", inputs=[game_dropdown, opponent_dropdown], outputs=[game_output])
134
 
 
135
  with gr.Tab("Leaderboard"):
136
  gr.Markdown("# LLM Model Leaderboard\nTrack performance across different games!")
 
137
  leaderboard_game_dropdown = gr.Dropdown(choices=get_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
  leaderboard_game_dropdown.change(fn=extract_leaderboard_stats, inputs=[leaderboard_game_dropdown], outputs=[leaderboard_table])
140
 
 
141
  interface.launch()
 
 
123
  return leaderboard_df
124
 
125
  with gr.Blocks() as interface:
126
+ # Tab for playing games against LLMs
127
  with gr.Tab("Game Arena"):
128
  gr.Markdown("# Play Against LLMs\nChoose a game and an opponent to play!")
129
+ # Dropdown to select a game, excluding 'Aggregated Performance'
130
  game_dropdown = gr.Dropdown(get_available_games(include_aggregated=False), label="Select a Game")
131
+ # Dropdown to choose an opponent (Random Bot or LLM)
132
  opponent_dropdown = gr.Dropdown(["Random Bot", "LLM"], label="Choose Opponent")
133
+ # Button to start the game
134
  play_button = gr.Button("Start Game")
135
+ # Textbox to display the game log
136
  game_output = gr.Textbox(label="Game Log")
137
 
138
+ # Event to start the game when the button is clicked
139
  play_button.click(lambda game, opponent: f"Game {game} started against {opponent}", inputs=[game_dropdown, opponent_dropdown], outputs=[game_output])
140
 
141
+ # Tab for leaderboard and performance tracking
142
  with gr.Tab("Leaderboard"):
143
  gr.Markdown("# LLM Model Leaderboard\nTrack performance across different games!")
144
+ # Dropdown to select a game, including 'Aggregated Performance'
145
  leaderboard_game_dropdown = gr.Dropdown(choices=get_available_games(), label="Select Game", value="Aggregated Performance")
146
+ # Table to display leaderboard statistics
147
  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)
148
+ # Update the leaderboard when a new game is selected
149
  leaderboard_game_dropdown.change(fn=extract_leaderboard_stats, inputs=[leaderboard_game_dropdown], outputs=[leaderboard_table])
150
 
151
+ # Launch the Gradio interface
152
  interface.launch()
153
+