FunctionNode
Node for executing custom Python functions within workflows.
FunctionNode allows integration of arbitrary Python functions into the Liman execution graph. Functions can be sync or async.
Attributes
attribute
spec_type= FunctionNodeSpec
attribute
state_type= FunctionNodeState
attribute
registry= registry
Functions
func
__init____init__(self, /, spec, registry, *, initial_data=None, yaml_path=None, strict=False, default_lang='en', fallback_lang='en') -> None
Initialize function node with specification and registry.
Args: spec: Function node specification defining the target function 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
param
selfparam
specFunctionNodeSpec
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
compilecompile(self) -> None
Compile the function node for execution.
Prepares the node for execution. Currently performs basic validation and sets the compiled flag.
Raises: LimanError: If the node is already compiled
param
selfReturns
None
func
set_funcset_func(self, /, func) -> None
Manually set the function for this function node.
Args: func: Callable function to execute during invocation
param
selfparam
funcCallable[..., Any]
Returns
None
func
invokeinvoke(self, /, input_, **kwargs) -> Any
Execute the function node with provided input.
Extracts function arguments from input and executes the function. Handles both synchronous and asynchronous functions.
Args: input_: Input data to pass to the function **kwargs: Additional keyword arguments
Returns: Result of function execution
param
selfparam
input_Any
param
kwargsAny
= {}
Returns
Any
func
get_new_stateget_new_state(self) -> FunctionNodeState
Create new state instance for this function node.
Returns: Fresh FunctionNodeState with empty message history
param
selfReturns
FunctionNodeState
func
_extract_function_args_extract_function_args(self, /, args_dict) -> dict[str, Any]
Extract function arguments based on function signature from provided args dict.
Args: args_dict: Dictionary containing all available arguments
Returns: Dictionary with only the arguments that match function signature
param
selfparam
args_dictdict[str, Any] | None
Returns
dict[str, Any]
Last updated on