feat: Implement World Architect
This commit is contained in:
@@ -5,6 +5,7 @@ from langchain_core.messages import HumanMessage, SystemMessage
|
||||
from entities import Entity
|
||||
from llm_runtime import _format_prompt, _normalize_llm_output, llm
|
||||
from time_utils import WorldClock, describe_relative_time
|
||||
from world_architect import invoke_architect, apply_state_delta, WorldState
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -15,6 +16,7 @@ def ask_entity(
|
||||
player_query: str,
|
||||
world_clock: WorldClock,
|
||||
location: str,
|
||||
world_state: WorldState | None = None,
|
||||
):
|
||||
facts = entity.memory.retrieve(
|
||||
player_query,
|
||||
@@ -87,3 +89,22 @@ RECENT CHAT: {recent_context}
|
||||
)
|
||||
|
||||
logger.info("[%s]: %s", entity.name.upper(), response)
|
||||
|
||||
# Invoke World Architect to process entity action
|
||||
if world_state:
|
||||
logger.info("Invoking World Architect for action processing...")
|
||||
state_delta = invoke_architect(
|
||||
entity_id=entity.entity_id,
|
||||
action=response,
|
||||
current_state=world_state.to_dict(),
|
||||
entity_name=entity.name,
|
||||
)
|
||||
|
||||
if state_delta:
|
||||
logger.info("Applying state delta to world...")
|
||||
apply_state_delta(world_state, state_delta)
|
||||
logger.info(
|
||||
"World time now: %s", world_state.world_clock.get_time_str()
|
||||
)
|
||||
else:
|
||||
logger.info("No state changes from architect")
|
||||
|
||||
Reference in New Issue
Block a user