Add meta language
This commit is contained in:
@@ -14,3 +14,4 @@ class TurnResult:
|
||||
error: Optional[str] = None
|
||||
debug_info: str = ""
|
||||
changes: list[str] = field(default_factory=list)
|
||||
is_meta: bool = False
|
||||
|
||||
@@ -171,6 +171,33 @@ Regenerate (turn had fixable issues like wrong state changes or minor inconsiste
|
||||
```
|
||||
"""
|
||||
|
||||
META_VALIDATION_PROMPT = """You are validating a meta (out-of-character) DM response. The player's action starts with `>` — they are talking to the DM, not to a character.
|
||||
|
||||
## Player Action (Meta)
|
||||
{action}
|
||||
|
||||
## Generated Meta Response
|
||||
{narrative}
|
||||
|
||||
## Instructions
|
||||
1. **Meta Format**: The entire response must start with `>` and use meta language (DM addressing the player directly).
|
||||
2. **State Changes**: There MUST be no state changes. This is a meta conversation, not story progression.
|
||||
3. **Answer Quality**: The response should address the player's meta question and be helpful.
|
||||
4. **No Story Advancement**: The response must not advance the game narrative.
|
||||
|
||||
Reply with ONLY a ```tool block. Examples:
|
||||
|
||||
Valid:
|
||||
```tool
|
||||
{{"tool": "validate", "args": {{"valid": true, "reason": "ok", "action": "ok"}}}}
|
||||
```
|
||||
|
||||
Regenerate (response didn't start with `>` or tried to change state):
|
||||
```tool
|
||||
{{"tool": "validate", "args": {{"valid": false, "reason": "describe the issue", "action": "regenerate"}}}}
|
||||
```
|
||||
"""
|
||||
|
||||
|
||||
def _format_changes(changes: list[dict]) -> str:
|
||||
"""Format tool calls into a readable change list for the validation prompt."""
|
||||
@@ -193,6 +220,7 @@ def validate_turn(
|
||||
changes: list[dict] | None = None,
|
||||
story: str = "",
|
||||
log: str = "",
|
||||
meta: bool = False,
|
||||
) -> tuple[bool, str, str]:
|
||||
"""Validate a complete generated turn.
|
||||
|
||||
@@ -208,12 +236,18 @@ def validate_turn(
|
||||
journal = state.read_file(JOURNAL_PATH) or "*No journal entries.*"
|
||||
change_summary = _format_changes(changes or [])
|
||||
|
||||
prompt = TURN_VALIDATION_PROMPT.format(
|
||||
character=char, world=world, story=recent,
|
||||
log=log_entries, journal=journal, action=player_action,
|
||||
narrative=narrative, log_entry=log_entry or "*No log entry provided.*",
|
||||
changes=change_summary,
|
||||
)
|
||||
if meta:
|
||||
prompt = META_VALIDATION_PROMPT.format(
|
||||
action=player_action,
|
||||
narrative=narrative,
|
||||
)
|
||||
else:
|
||||
prompt = TURN_VALIDATION_PROMPT.format(
|
||||
character=char, world=world, story=recent,
|
||||
log=log_entries, journal=journal, action=player_action,
|
||||
narrative=narrative, log_entry=log_entry or "*No log entry provided.*",
|
||||
changes=change_summary,
|
||||
)
|
||||
|
||||
messages = [{"role": "user", "content": prompt}]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user