Spaces:
Sleeping
Sleeping
Upload src/persistentpoker_bench/web_ui.py with huggingface_hub
Browse files
src/persistentpoker_bench/web_ui.py
CHANGED
|
@@ -215,6 +215,7 @@ def build_web_app():
|
|
| 215 |
with gr.Column(scale=1):
|
| 216 |
file_input = gr.File(label="Drag & Drop results.jsonl here", file_types=[".jsonl", ".json"])
|
| 217 |
load_btn = gr.Button("🚀 Load Match", variant="primary")
|
|
|
|
| 218 |
hand_selector = gr.Dropdown(label="Select Hand", choices=[])
|
| 219 |
|
| 220 |
with gr.Column(scale=3):
|
|
@@ -264,6 +265,31 @@ def build_web_app():
|
|
| 264 |
|
| 265 |
return render_visual_table(viz_data), markdown_summary
|
| 266 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 267 |
load_btn.click(on_load_file, inputs=[file_input], outputs=[match_state, hand_selector, hand_summary])
|
| 268 |
hand_selector.change(on_hand_change, inputs=[hand_selector, match_state], outputs=[table_display, hand_summary])
|
| 269 |
|
|
|
|
| 215 |
with gr.Column(scale=1):
|
| 216 |
file_input = gr.File(label="Drag & Drop results.jsonl here", file_types=[".jsonl", ".json"])
|
| 217 |
load_btn = gr.Button("🚀 Load Match", variant="primary")
|
| 218 |
+
demo_btn = gr.Button("🎲 Generate Dummy Demo", variant="secondary")
|
| 219 |
hand_selector = gr.Dropdown(label="Select Hand", choices=[])
|
| 220 |
|
| 221 |
with gr.Column(scale=3):
|
|
|
|
| 265 |
|
| 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])
|
| 294 |
hand_selector.change(on_hand_change, inputs=[hand_selector, match_state], outputs=[table_display, hand_summary])
|
| 295 |
|