NodeActor
Unified NodeActor supporting both sync and async execution
Attributes
attributeidUUID= actor_id or uuid4()attributenodeT= nodeattributellm= llmattributenode_state= node.get_new_state()attributestatus= NodeActorStatus.IDLEattributeerrorNodeActorError | None= Noneattributelogger= logging.LoggerAdapter(logger, {'actor_id': str(self.id)})attributecomposite_idstrFunctions
func__init____init__(self, /, node, actor_id=None, llm=None)paramselfparamnodeTparamactor_idUUID | None= NoneparamllmBaseChatModel | None= NoneReturns
Nonefunc__repr____repr__(self) -> strparamselfReturns
strfunccan_restorecan_restore(cls, /, node, saved_state) -> boolCheck if NodeActor can be restored based on node type and status
paramclsparamnodeBaseNode[S, NS]paramsaved_statedict[str, Any]Returns
boolfunccreatecreate(cls, /, node, actor_id=None, llm=None) -> SelfCreate 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
paramclsparamnodeTparamactor_idUUID | None= NoneparamllmBaseChatModel | None= NoneReturns
Selffunccreate_or_restorecreate_or_restore(cls, /, node, state, llm=None) -> SelfCreate 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)
paramclsparamnodeTparamstatedict[str, Any] | NoneparamllmBaseChatModel | None= NoneReturns
Selffuncexecuteexecute(self, /, input_, execution_id, context=None) -> ResultExecute 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
paramselfparaminput_Anyparamexecution_idUUIDparamcontextdict[str, Any] | None= NoneReturns
Resultfuncserialize_stateserialize_state(self) -> dict[str, Any]Serialize NodeActor state for persistence
paramselfReturns
dict[str, Any]func_initialize_initialize(self) -> NoneInitialize the actor and prepare for execution (async version)
paramselfReturns
Nonefunc_execute_internal_execute_internal(self, /, input_, context, execution_id) -> Resultparamselfparaminput_Anyparamcontextdict[str, Any]paramexecution_idUUIDReturns
Resultfunc_execute_llm_node_execute_llm_node(self, /, input_) -> LangChainMessageparamselfparaminput_AnyReturns
LangChainMessagefunc_execute_tool_node_execute_tool_node(self, /, input_, execution_context) -> ToolMessageparamselfparaminput_Anyparamexecution_contextExecutionContext[ToolNodeState]Returns
ToolMessagefunc_execute_function_node_execute_function_node(self, /, input_, execution_context) -> Anyparamselfparaminput_Anyparamexecution_contextExecutionContext[NS]Returns
Anyfunc_get_next_nodes_get_next_nodes(self, /, output) -> list[NextNode]Get the next nodes to execute based on the output
paramselfparamoutputLangChainMessage | ToolMessage | dict[str, Any] | NoneReturns
list[NextNode]func_get_node_edges_get_node_edges(self) -> list[tuple[type[Node | LLMNode], EdgeSpec]]paramselfReturns
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
paramselfparamoutputAnyReturns
tuple[dict[str, Any], dict[str, Any]]func_should_follow_edge_should_follow_edge(self, /, edge, context, state_context, transformer) -> boolDetermine if an edge should be followed based on its conditions
paramselfparamedgeEdgeSpecparamcontextdict[str, Any]paramstate_contextdict[str, Any]paramtransformerWhenTransformerReturns
boolfunc_prepare_execution_context_prepare_execution_context(self, /, context, execution_id) -> ExecutionContext[Any]Prepare execution context with actor metadata
paramselfparamcontextdict[str, Any]paramexecution_idUUIDReturns
ExecutionContext[Any]func_restore_state_restore_state(self, /, state) -> NoneRestore NodeActor state from serialized data
paramselfparamstatedict[str, Any]Returns
NoneLast updated on