From fec907ec8f854f2c7ee8fcd20bea31507d9ce999 Mon Sep 17 00:00:00 2001 From: Sean Sube Date: Sun, 2 Jun 2024 15:07:57 -0500 Subject: [PATCH] fix action prompt and prompt event actions --- taleweave/models/event.py | 2 +- taleweave/player.py | 2 +- taleweave/simulate.py | 26 +++++++++++++------------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/taleweave/models/event.py b/taleweave/models/event.py index 30bc592..79a7e4e 100644 --- a/taleweave/models/event.py +++ b/taleweave/models/event.py @@ -60,7 +60,7 @@ class PromptEvent(BaseModel): A prompt for a character to take an action. """ - actions: Dict[str, Any] + actions: List[Dict[str, Any]] prompt: str room: Room character: Character diff --git a/taleweave/player.py b/taleweave/player.py index 2e6e14b..6f36023 100644 --- a/taleweave/player.py +++ b/taleweave/player.py @@ -197,7 +197,7 @@ def __call__(self, prompt: str, toolbox: Toolbox | None = None, **kwargs) -> str Ask the player for input. """ - actions = {} + actions = [] formatted_prompt = prompt.format(**kwargs) if toolbox: actions = toolbox.list_definitions() diff --git a/taleweave/simulate.py b/taleweave/simulate.py index 216741a..fbdcccc 100644 --- a/taleweave/simulate.py +++ b/taleweave/simulate.py @@ -132,19 +132,19 @@ def result_parser(value, **kwargs): logger.info("starting turn for character: %s", character.name) result = loop_retry( agent, - get_prompt("world_simulate_character_action"), - context={ - "actions": action_names, - "character_items": character_items, - "attributes": character_attributes, - "directions": room_directions, - "room_name": room.name, - "room_description": describe_entity(room), - "visible_characters": room_characters, - "visible_items": room_items, - "notes_prompt": notes_prompt, - "events_prompt": events_prompt, - }, + format_prompt( + "world_simulate_character_action", + actions=action_names, + character_items=character_items, + attributes=character_attributes, + directions=room_directions, + room_name=room.name, + room_description=describe_entity(room), + visible_characters=room_characters, + visible_items=room_items, + notes_prompt=notes_prompt, + events_prompt=events_prompt, + ), result_parser=result_parser, toolbox=action_toolbox, )