diff --git a/tools/engine.py b/tools/engine.py index b416a4b..6b5230a 100644 --- a/tools/engine.py +++ b/tools/engine.py @@ -92,6 +92,8 @@ class GameEngine: if attempt < MAX_RETRIES: feedback = "Your response was empty. Generate a complete turn with narrative and state changes." state.append_llm_log("\n[RETRY] empty response") + if on_action: + on_action("DM is weaving the tale...") continue return TurnResult(error="LLM returned empty response after retries") @@ -141,6 +143,8 @@ class GameEngine: if attempt < MAX_RETRIES: feedback = "The narrative is nearly identical to the previous turn. Generate something new and different." state.append_llm_log(f"\n[TURN REGENERATE] (duplicate) attempt {attempt + 2}") + if on_action: + on_action("DM is weaving the tale...") continue state.append_llm_log(f"\n[TURN DUPLICATE EXCEEDED] cannot generate unique narrative") return TurnResult( @@ -168,6 +172,8 @@ class GameEngine: if attempt < MAX_RETRIES: feedback = "The validation system could not process the previous turn. Please regenerate." state.append_llm_log(f"\n[TURN REGENERATE] (unrecognized) attempt {attempt + 2}") + if on_action: + on_action("DM is consulting the fates...") continue state.append_llm_log(f"\n[TURN UNRECOGNIZED] cannot validate turn") return TurnResult( @@ -186,6 +192,8 @@ class GameEngine: validator_tool = json.dumps({"tool": "validate", "args": {"valid": False, "reason": reason, "action": "regenerate"}}) feedback = f"The validation tool returned:\n```tool\n{validator_tool}\n```\n\nPlease regenerate the turn addressing the issues above. Keep the same player action but fix the problems described." state.append_llm_log(f"\n[TURN REGENERATE] attempt {attempt + 2}: {reason}") + if on_action: + on_action("DM is searching for inspiration...") continue else: state.append_llm_log(f"\n[TURN REGENERATE EXCEEDED] accepting despite: {reason}") diff --git a/tools/run_widgets.py b/tools/run_widgets.py index aa6e0a6..db35ad7 100644 --- a/tools/run_widgets.py +++ b/tools/run_widgets.py @@ -1,6 +1,7 @@ from __future__ import annotations from textual.widgets import Static +from rich.markdown import Markdown as RichMarkdown from run_utils import ( CHAR_PATH, TODAY, REFRESH_SECS,