Action rejection capability
This commit is contained in:
parent
6b277d725d
commit
e97db7f5b7
@ -57,9 +57,9 @@ class GameEngine:
|
|||||||
else:
|
else:
|
||||||
state.append_llm_log(f"\n[VALIDATION REJECTED] {reason}")
|
state.append_llm_log(f"\n[VALIDATION REJECTED] {reason}")
|
||||||
return TurnResult(
|
return TurnResult(
|
||||||
book_log=f"",
|
book_log="",
|
||||||
log_entry=f"You can't do that — {reason}.",
|
log_entry=f"You can't do that — {reason}.",
|
||||||
user_prompt=auto_prompt(""),
|
user_prompt=f"*Your action \"{player_action}\" was rejected: {reason}*",
|
||||||
)
|
)
|
||||||
|
|
||||||
system = build_system_prompt()
|
system = build_system_prompt()
|
||||||
|
|||||||
20
tools/run.py
20
tools/run.py
@ -204,6 +204,7 @@ class ChaosTUI(App):
|
|||||||
self._settings_loaded = True
|
self._settings_loaded = True
|
||||||
|
|
||||||
def _begin_game(self):
|
def _begin_game(self):
|
||||||
|
self._last_narrative: str = ""
|
||||||
if LAST_PROMPT_PATH.exists():
|
if LAST_PROMPT_PATH.exists():
|
||||||
saved = LAST_PROMPT_PATH.read_text().strip()
|
saved = LAST_PROMPT_PATH.read_text().strip()
|
||||||
if saved:
|
if saved:
|
||||||
@ -446,11 +447,19 @@ class ChaosTUI(App):
|
|||||||
if result.book_log:
|
if result.book_log:
|
||||||
state.archive_turn(result.book_log)
|
state.archive_turn(result.book_log)
|
||||||
state.apply_state(result)
|
state.apply_state(result)
|
||||||
self._display_scene(result)
|
if result.book_log or not result.user_prompt:
|
||||||
if result.user_prompt:
|
self._display_scene(result)
|
||||||
LAST_PROMPT_PATH.write_text(result.user_prompt.strip())
|
else:
|
||||||
self._last_prompt = result.user_prompt
|
if self._last_narrative:
|
||||||
self._last_result = result
|
self._set_narrative(f"{self._last_narrative}\n\n---\n\n{result.user_prompt}")
|
||||||
|
self._enable_input()
|
||||||
|
else:
|
||||||
|
self._display_scene(result)
|
||||||
|
if result.book_log:
|
||||||
|
self._last_result = result
|
||||||
|
if result.user_prompt:
|
||||||
|
LAST_PROMPT_PATH.write_text(result.user_prompt.strip())
|
||||||
|
self._last_prompt = result.user_prompt
|
||||||
self._append_debug("✔ turn complete")
|
self._append_debug("✔ turn complete")
|
||||||
|
|
||||||
def _on_generation_error(self, error: Exception, traceback_str: str) -> None:
|
def _on_generation_error(self, error: Exception, traceback_str: str) -> None:
|
||||||
@ -481,6 +490,7 @@ class ChaosTUI(App):
|
|||||||
inp.focus()
|
inp.focus()
|
||||||
|
|
||||||
def _set_narrative(self, text: str) -> None:
|
def _set_narrative(self, text: str) -> None:
|
||||||
|
self._last_narrative = text
|
||||||
self.query_one("#play-narrative", Static).update(RichMarkdown(text))
|
self.query_one("#play-narrative", Static).update(RichMarkdown(text))
|
||||||
self.query_one("#play-scroll", VerticalScroll).scroll_home(animate=False)
|
self.query_one("#play-scroll", VerticalScroll).scroll_home(animate=False)
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user