Liman

NodeActor

Unified NodeActor supporting both sync and async execution

Attributes

attributeidUUID
= actor_id or uuid4()
attributenodeT
= node
attributellm
= llm
attributenode_state
= node.get_new_state()
attributestatus
= NodeActorStatus.IDLE
attributeerrorNodeActorError | None
= None
attributelogger
= logging.LoggerAdapter(logger, {'actor_id': str(self.id)})
attributecomposite_idstr

Functions

func__init____init__(self, /, node, actor_id=None, llm=None)
paramself
paramnodeT
paramactor_idUUID | None
= None
paramllmBaseChatModel | None
= None

Returns

None
func__repr____repr__(self) -> str
paramself

Returns

str
funccan_restorecan_restore(cls, /, node, saved_state) -> bool

Check if NodeActor can be restored based on node type and status

paramcls
paramnodeBaseNode[S, NS]
paramsaved_statedict[str, Any]

Returns

bool
funccreatecreate(cls, /, node, actor_id=None, llm=None) -> Self

Create a NodeActor instance from a node.

Args: node: The node to wrap in this actor actor_id: Optional custom actor ID llm: Optional LLM instance for LLMNodes

Returns: Configured NodeActor instance

paramcls
paramnodeT
paramactor_idUUID | None
= None
paramllmBaseChatModel | None
= None

Returns

Self
funccreate_or_restorecreate_or_restore(cls, /, node, state, llm=None) -> Self

Create a new NodeActor or restore from saved state

Args: node: The node to wrap in this actor state: Saved state to restore llm: Optional LLM instance for LLMNodes

Returns: NodeActor instance (new or restored)

paramcls
paramnodeT
paramstatedict[str, Any] | None
paramllmBaseChatModel | None
= None

Returns

Self
funcexecuteexecute(self, /, input_, execution_id, context=None) -> Result

Execute the wrapped node with the provided inputs (async version).

Args: input_: Input for the node context: Additional execution context execution_id: Execution tracking ID

Returns: Result from node execution

Raises: NodeActorError: If execution fails or actor is in invalid state

paramself
paraminput_Any
paramexecution_idUUID
paramcontextdict[str, Any] | None
= None

Returns

Result
funcserialize_stateserialize_state(self) -> dict[str, Any]

Serialize NodeActor state for persistence

paramself

Returns

dict[str, Any]
func_initialize_initialize(self) -> None

Initialize the actor and prepare for execution (async version)

paramself

Returns

None
func_execute_internal_execute_internal(self, /, input_, context, execution_id) -> Result
paramself
paraminput_Any
paramcontextdict[str, Any]
paramexecution_idUUID

Returns

Result
func_execute_llm_node_execute_llm_node(self, /, input_) -> LangChainMessage
paramself
paraminput_Any

Returns

LangChainMessage
func_execute_tool_node_execute_tool_node(self, /, input_, execution_context) -> ToolMessage
paramself
paraminput_Any
paramexecution_contextExecutionContext[ToolNodeState]

Returns

ToolMessage
func_execute_function_node_execute_function_node(self, /, input_, execution_context) -> Any
paramself
paraminput_Any
paramexecution_contextExecutionContext[NS]

Returns

Any
func_get_next_nodes_get_next_nodes(self, /, output) -> list[NextNode]

Get the next nodes to execute based on the output

paramself
paramoutputLangChainMessage | ToolMessage | dict[str, Any] | None

Returns

list[NextNode]
func_get_node_edges_get_node_edges(self) -> list[tuple[type[Node | LLMNode], EdgeSpec]]
paramself

Returns

list[tuple[type[Node | LLMNode], EdgeSpec]]
func_build_evaluation_context_build_evaluation_context(self, /, output) -> tuple[dict[str, Any], dict[str, Any]]

Build context for edge condition evaluation Variables with $ prefix: $output, $status, $state Variables without $ prefix: taken from $state.context

paramself
paramoutputAny

Returns

tuple[dict[str, Any], dict[str, Any]]
func_should_follow_edge_should_follow_edge(self, /, edge, context, state_context, transformer) -> bool

Determine if an edge should be followed based on its conditions

paramself
paramedgeEdgeSpec
paramcontextdict[str, Any]
paramstate_contextdict[str, Any]
paramtransformerWhenTransformer

Returns

bool
func_prepare_execution_context_prepare_execution_context(self, /, context, execution_id) -> ExecutionContext[Any]

Prepare execution context with actor metadata

paramself
paramcontextdict[str, Any]
paramexecution_idUUID

Returns

ExecutionContext[Any]
func_restore_state_restore_state(self, /, state) -> None

Restore NodeActor state from serialized data

paramself
paramstatedict[str, Any]

Returns

None

Last updated on