Add character detail, markdown rendering, wider layout, and LLM provider switch

- Character sheets gain structured combat_stats, abilities (name +
  plain-language explanation), and equipment fields, populated by the
  upsert_character_sheet tool; the detail page renders them as their
  own sections instead of one prose block, with a player-card-style
  attribute grid (full ability names + modifiers).
- Fix double-escaped unicode occasionally left in tool-call JSON
  arguments (a model quirk) and stop the app's own json.dumps calls
  from re-introducing it (ensure_ascii=False).
- Render chat messages as markdown (react-markdown + Tailwind
  typography) instead of raw text, and widen the games/characters/
  chat layout to use more of the screen on desktop.
- Sharpen the DM system prompt: state the ability + DC for each
  offered action option before the player commits, and narrate rolls
  as DC → result → pass/fail before the story consequence; also stop
  re-asking Session-0 questions already answered in the game's
  name/description.
- Make the DM's LLM provider configurable (xai default, lmstudio for
  a local OpenAI-compatible server via host.docker.internal) instead
  of hardcoded to x.ai.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Thorsten
2026-09-01 15:18:15 +02:00
parent ec53ed3aba
commit 624644619c
26 changed files with 1503 additions and 119 deletions
+39 -3
View File
@@ -11,8 +11,8 @@ TOOL_SCHEMA = {
"name": "upsert_character_sheet",
"description": (
"Create or update a player's character sheet as facts about them are confirmed or change during play "
"(name, race, class, ability stats, abilities, backstory). Call this proactively as soon as details are "
"settled — do not wait until the end of the session."
"(name, race, class, ability stats, combat stats, abilities, equipment, backstory). Call this "
"proactively as soon as details are settled — do not wait until the end of the session."
),
"parameters": {
"type": "object",
@@ -32,9 +32,39 @@ TOOL_SCHEMA = {
"type": "object",
"description": "Ability scores, e.g. {\"STR\": 15, \"DEX\": 12, \"CON\": 14, \"INT\": 10, \"WIS\": 8, \"CHA\": 13}",
},
"combat_stats": {
"type": "object",
"description": (
"Key/value readouts, e.g. {\"HP\": \"13/13\", \"RK\": \"19\", \"Initiative\": \"+1\", "
"\"Tempo\": \"7,5 m\", \"Übungsbonus\": \"+2\"}. Send the full current set each time — "
"this replaces whatever was stored before."
),
},
"abilities": {
"type": "array",
"description": (
"Every notable class feature, racial trait, feat, or spell the character has — one "
"entry per ability. Each 'description' must be a clear, beginner-friendly explanation "
"of what it does and when/how to use it, not just its rules name. Send the full current "
"list each time — this replaces whatever was stored before."
),
"items": {
"type": "object",
"properties": {
"name": {"type": "string"},
"description": {"type": "string"},
},
"required": ["name", "description"],
},
},
"equipment": {
"type": "array",
"description": "Full current equipment/inventory list, one item per string. Replaces whatever was stored before.",
"items": {"type": "string"},
},
"description": {
"type": "string",
"description": "Free-text description: special abilities, oaths, backstory, anything relevant.",
"description": "Backstory/background narrative only — oaths, personality, motivation, current situation. Abilities and equipment go in their own fields, not here.",
},
},
"required": ["player_name"],
@@ -77,6 +107,12 @@ async def upsert(session: AsyncSession, game_id: uuid.UUID, tool_input: dict) ->
setattr(character, field, tool_input[field])
if "stats" in tool_input and tool_input["stats"] is not None:
character.stats = {**(character.stats or {}), **tool_input["stats"]}
if "combat_stats" in tool_input and tool_input["combat_stats"] is not None:
character.combat_stats = {**(character.combat_stats or {}), **tool_input["combat_stats"]}
if "abilities" in tool_input and tool_input["abilities"] is not None:
character.abilities = tool_input["abilities"]
if "equipment" in tool_input and tool_input["equipment"] is not None:
character.equipment = tool_input["equipment"]
await session.flush()