BaseNode
Abstract base class for all nodes in the Liman framework.
BaseNode provides the foundation for LLM, Tool, and custom nodes. It handles language configuration, compilation, and execution lifecycle. All concrete nodes must inherit from this class and implement the abstract methods for their specific functionality.
Attributes
attribute
__slots__= Component.__slots__ + ('default_lang', 'fallback_lang', '_compiled')
attribute
specS
attribute
default_langLanguageCode
= default_lang
attribute
fallback_langLanguageCode
= fallback_lang
attribute
is_llm_nodebool
attribute
is_tool_nodebool
Functions
func
__init____init__(self, /, spec, registry, *, initial_data=None, yaml_path=None, strict=False, default_lang='en', fallback_lang='en') -> None
Initialize base node with specification and configuration.
Args: spec: Node specification defining behavior and properties registry: Component registry for dependency resolution initial_data: Optional initial data for the component yaml_path: Optional path to the YAML file this node was loaded from strict: Whether to enforce strict validation default_lang: Default language code for localization fallback_lang: Fallback language code when default is unavailable
Raises: LimanError: If language codes are invalid
param
selfparam
specS
param
registryRegistry
param
initial_datadict[str, Any] | None
= None
param
yaml_pathstr | None
= None
param
strictbool
= False
param
default_langstr
= 'en'
param
fallback_langstr
= 'en'
Returns
None
func
__repr____repr__(self) -> str
param
selfReturns
str
func
generate_idgenerate_id(self) -> UUID
Generate unique identifier for this node instance.
Returns: Randomly generated UUID for the node
param
selfReturns
UUID
func
compilecompile(self) -> None
Compile the node for execution.
Prepares the node for execution by validating configuration, resolving dependencies, and performing any necessary setup. Must be implemented by concrete node classes.
param
selfReturns
None
func
invokeinvoke(self, *args, **kwargs) -> Any
Execute the node's primary functionality.
Performs the main operation of the node. Implementation varies by node type (LLM calls, tool execution, custom logic).
Args: *args: Positional arguments for node execution **kwargs: Keyword arguments for node execution
Returns: Result of node execution, type varies by implementation
param
selfparam
argsAny
= ()
param
kwargsAny
= {}
Returns
Any
func
get_new_stateget_new_state(self) -> NS
Create new state instance for this node.
Returns: Fresh node state object for execution
param
selfReturns
NS
Last updated on