Artvv commited on
Commit
94327cd
·
verified ·
1 Parent(s): e002bd8

Upload src/persistentpoker_bench/web_ui.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. src/persistentpoker_bench/web_ui.py +12 -22
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
- from persistentpoker_bench.match_runner import run_seeded_match, MatchRunnerConfig
270
- from persistentpoker_bench.hand_runner import HandRunnerConfig
271
- from persistentpoker_bench.runtime_agents import StaticDecisionAgent
272
- from persistentpoker_bench.game_state import ActionType
273
- from persistentpoker_bench.schemas import LLMDecision, WinnerPoolDecision
274
-
275
- agents = {
276
- 0: StaticDecisionAgent(LLMDecision(action=ActionType.CALL.value, amount=None, believed_pool=[], winner_pool_decision=WinnerPoolDecision.CONTINUE, reasoning="Call everything")),
277
- 1: StaticDecisionAgent(LLMDecision(action=ActionType.CHECK.value, amount=None, believed_pool=[], winner_pool_decision=WinnerPoolDecision.CONTINUE, reasoning="Check it down")),
278
- 2: StaticDecisionAgent(LLMDecision(action=ActionType.FOLD.value, amount=None, believed_pool=[], winner_pool_decision=WinnerPoolDecision.CONTINUE, reasoning="Too scared")),
279
- 3: StaticDecisionAgent(LLMDecision(action=ActionType.CALL.value, amount=None, believed_pool=[], winner_pool_decision=WinnerPoolDecision.CONTINUE, reasoning="I'm a bot")),
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])