Spaces:
Sleeping
Sleeping
| """Sample web payload for UI smoke tests without running inference.""" | |
| from __future__ import annotations | |
| from typing import Any | |
| from chess_tutor.puzzles.puzzle_record import load_puzzle_records | |
| from chess_tutor.web.sections import ui_layout_config | |
| from chess_tutor.web.version import version_info | |
| def build_sample_web_payload() -> dict[str, Any]: | |
| """Return a minimal inference-shaped payload with one playable puzzle ladder.""" | |
| record = load_puzzle_records(["00008"]).get("00008") | |
| if record is None: | |
| raise RuntimeError("Puzzle 00008 is unavailable (install local puzzle shards).") | |
| series = { | |
| "title": "Sample tactics", | |
| "principle_category": "tactics", | |
| "themes": ["crushing"], | |
| "rating_min": 1800, | |
| "rating_max": 1900, | |
| "lichess_study_url": None, | |
| "puzzles": [ | |
| { | |
| "index": 1, | |
| "id": record.puzzle_id, | |
| "rating": 1834, | |
| "theme": "crushing", | |
| "fen": record.fen, | |
| "solution_uci": list(record.solution_uci), | |
| "lichess_url": f"https://lichess.org/training/{record.puzzle_id}", | |
| }, | |
| ], | |
| } | |
| return { | |
| "ui_layout": ui_layout_config(), | |
| "header": { | |
| "username": "sample-player", | |
| "site": "lichess", | |
| "player_elo": 1500, | |
| "native_player_elo": None, | |
| "elo_bracket": "1500-1599", | |
| "n_games": 100, | |
| "policy": "teacher", | |
| }, | |
| "rating_outlook": ["Listed (site): 1500 Elo [1500-1599]"], | |
| "narrative_sections": [ | |
| { | |
| "title": "Sample coaching report", | |
| "body": "Long narrative content above the puzzle section.\n" * 20, | |
| } | |
| ], | |
| "narrative_markdown": "Sample coaching report", | |
| "opening_cards": [], | |
| "puzzle_series": [series], | |
| "lichess_study_url": None, | |
| "lichess_study_error": None, | |
| "version": version_info(), | |
| } | |