Remove debug pane
This commit is contained in:
@@ -30,7 +30,6 @@ def call_llm(
|
||||
timeout: int | None = None,
|
||||
max_tokens: int | None = None,
|
||||
label: str = "",
|
||||
on_debug: callable = None,
|
||||
) -> str | None:
|
||||
"""Make a single LLM call. Loads config automatically. Returns content text or None on error."""
|
||||
from .config import load_config
|
||||
@@ -45,8 +44,6 @@ def call_llm(
|
||||
try:
|
||||
import litellm
|
||||
except ImportError:
|
||||
if on_debug:
|
||||
on_debug("llm_error", {"label": label, "error": "litellm not installed"})
|
||||
return None
|
||||
try:
|
||||
response = litellm.completion(
|
||||
@@ -67,6 +64,4 @@ def call_llm(
|
||||
except Exception as e:
|
||||
err_msg = f"{type(e).__name__}: {e}"
|
||||
append_llm_log(f"\n--- LLM ERROR ({label}) ---\n{err_msg}")
|
||||
if on_debug:
|
||||
on_debug("llm_error", {"label": label, "error": err_msg})
|
||||
return None
|
||||
|
||||
@@ -18,13 +18,11 @@ def log_turn_details(
|
||||
log_entry: str,
|
||||
ambience: Optional[str],
|
||||
tool_calls: list,
|
||||
on_debug=None,
|
||||
) -> None:
|
||||
"""Write structured turn summary to llm.log and fire TUI debug event."""
|
||||
ts = datetime.now().isoformat()
|
||||
output_chars = len(book_log)
|
||||
output_words = len(book_log.split()) if book_log else 0
|
||||
applied = len([tc for tc in tool_calls if tc.get("tool") not in ("finalize_turn", "narrative")])
|
||||
|
||||
state.append_llm_log("")
|
||||
state.append_llm_log(f"┌─ Turn Details — {ts}")
|
||||
@@ -41,20 +39,3 @@ def log_turn_details(
|
||||
state.append_llm_log(
|
||||
"└─────────────────────────────────────────────────────────────────────────────────────────┘"
|
||||
)
|
||||
|
||||
if on_debug:
|
||||
on_debug("turn_details", {
|
||||
"timestamp": ts,
|
||||
"model": model,
|
||||
"temperature": temperature,
|
||||
"max_tokens": max_tokens,
|
||||
"strategy_name": strategy_name,
|
||||
"die_roll": die_roll,
|
||||
"player_action": player_action,
|
||||
"book_log_chars": output_chars,
|
||||
"book_log_words": output_words,
|
||||
"ambience": ambience,
|
||||
"tool_calls_count": len(tool_calls),
|
||||
"applied_changes_count": applied,
|
||||
"tool_call_results": tool_calls,
|
||||
})
|
||||
|
||||
@@ -230,7 +230,7 @@ def describe_change(tool_name: str, args: dict) -> str:
|
||||
return ""
|
||||
|
||||
|
||||
def extract_tool_calls(text: str, on_debug: callable = None) -> list[dict]:
|
||||
def extract_tool_calls(text: str) -> list[dict]:
|
||||
"""Extract tool calls from ```tool blocks in LLM response."""
|
||||
calls = []
|
||||
seen = set()
|
||||
|
||||
@@ -51,7 +51,6 @@ def validate_action(
|
||||
*,
|
||||
story: str = "",
|
||||
log: str = "",
|
||||
on_debug: callable = None,
|
||||
) -> tuple[bool, str]:
|
||||
"""Ask the LLM whether a player action is valid given the game state. Returns (valid, reason)."""
|
||||
if not player_action:
|
||||
@@ -72,7 +71,6 @@ def validate_action(
|
||||
max_tokens=1024,
|
||||
temperature=0.2,
|
||||
label="Action validation",
|
||||
on_debug=on_debug,
|
||||
)
|
||||
|
||||
if not text:
|
||||
@@ -86,12 +84,8 @@ def validate_action(
|
||||
data = json.loads(cleaned)
|
||||
valid = data.get("valid", True)
|
||||
reason = data.get("reason", "")
|
||||
if on_debug:
|
||||
on_debug("action_validation", {"valid": valid, "reason": reason, "action": player_action})
|
||||
return valid, reason
|
||||
except (json.JSONDecodeError, ValueError):
|
||||
if on_debug:
|
||||
on_debug("action_validation", {"valid": True, "reason": "parse_failed", "raw": text[:200]})
|
||||
if attempt == 0:
|
||||
messages.append({
|
||||
"role": "system",
|
||||
@@ -198,7 +192,6 @@ def validate_turn(
|
||||
changes: list[dict] | None = None,
|
||||
story: str = "",
|
||||
log: str = "",
|
||||
on_debug: callable = None,
|
||||
) -> tuple[bool, str, str]:
|
||||
"""Validate a complete generated turn.
|
||||
|
||||
@@ -229,7 +222,6 @@ def validate_turn(
|
||||
max_tokens=1024,
|
||||
temperature=0.2,
|
||||
label="Turn validation",
|
||||
on_debug=on_debug,
|
||||
)
|
||||
|
||||
if not text:
|
||||
@@ -250,12 +242,8 @@ def validate_turn(
|
||||
action = args.get("action", "ok")
|
||||
if action not in ("ok", "reject", "regenerate"):
|
||||
action = "ok" if valid else "reject"
|
||||
if on_debug:
|
||||
on_debug("turn_validation", {"valid": valid, "reason": reason, "action": action})
|
||||
return valid, reason, action
|
||||
except (json.JSONDecodeError, ValueError):
|
||||
if on_debug:
|
||||
on_debug("turn_validation", {"valid": True, "reason": "parse_failed", "raw": text[:200]})
|
||||
if attempt == 0:
|
||||
messages.append({
|
||||
"role": "system",
|
||||
|
||||
Reference in New Issue
Block a user