Spaces:
Sleeping
Sleeping
Upload src/persistentpoker_bench/web_ui.py with huggingface_hub
Browse files
src/persistentpoker_bench/web_ui.py
CHANGED
|
@@ -266,28 +266,18 @@ def build_web_app():
|
|
| 266 |
return render_visual_table(viz_data), markdown_summary
|
| 267 |
|
| 268 |
def on_generate_demo():
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
config = MatchRunnerConfig(hand_runner_config=HandRunnerConfig(seed=42), hand_count=3)
|
| 282 |
-
result = run_seeded_match(player_names=["Alice", "Bob", "Charlie", "Dave"], decision_agents=agents, config=config)
|
| 283 |
-
|
| 284 |
-
from persistentpoker_bench.tournament import MatchRecord, serialize_match_record
|
| 285 |
-
from persistentpoker_bench.model_registry import LeaderboardTrack
|
| 286 |
-
record = MatchRecord(lineup_id="demo", track=LeaderboardTrack.FRONTIER, seed=42, entrants=(), match_result=result, metrics=None)
|
| 287 |
-
data = serialize_match_record(record)
|
| 288 |
-
|
| 289 |
-
hand_names = [f"Hand {i+1}" for i in range(len(data.get("hand_results", [])))]
|
| 290 |
-
return data, gr.update(choices=hand_names, value=hand_names[0] if hand_names else None), f"Demo Match loaded: {len(hand_names)} hands."
|
| 291 |
|
| 292 |
demo_btn.click(on_generate_demo, inputs=[], outputs=[match_state, hand_selector, hand_summary])
|
| 293 |
load_btn.click(on_load_file, inputs=[file_input], outputs=[match_state, hand_selector, hand_summary])
|
|
|
|
| 266 |
return render_visual_table(viz_data), markdown_summary
|
| 267 |
|
| 268 |
def on_generate_demo():
|
| 269 |
+
demo_path = Path("marathon_demo.jsonl")
|
| 270 |
+
if not demo_path.exists():
|
| 271 |
+
return None, gr.update(choices=[]), "Demo file 'marathon_demo.jsonl' not found on the server."
|
| 272 |
+
try:
|
| 273 |
+
with open(demo_path, "r") as f:
|
| 274 |
+
first_line = f.readline()
|
| 275 |
+
data = json.loads(first_line)
|
| 276 |
+
|
| 277 |
+
hand_names = [f"Hand {i+1}" for i in range(len(data.get("hand_results", [])))]
|
| 278 |
+
return data, gr.update(choices=hand_names, value=hand_names[0] if hand_names else None), f"Demo Marathon loaded: {len(hand_names)} hands."
|
| 279 |
+
except Exception as e:
|
| 280 |
+
return None, gr.update(choices=[]), f"Error loading demo file: {e}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 281 |
|
| 282 |
demo_btn.click(on_generate_demo, inputs=[], outputs=[match_state, hand_selector, hand_summary])
|
| 283 |
load_btn.click(on_load_file, inputs=[file_input], outputs=[match_state, hand_selector, hand_summary])
|