Liman

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

attributespec_type
= FunctionNodeSpec
attributestate_type
= FunctionNodeState
attributeregistry
= 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

paramself
paramspecFunctionNodeSpec
paramregistryRegistry
paraminitial_datadict[str, Any] | None
= None
paramyaml_pathstr | None
= None
paramstrictbool
= False
paramdefault_langstr
= 'en'
paramfallback_langstr
= 'en'

Returns

None
funccompilecompile(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

paramself

Returns

None
funcset_funcset_func(self, /, func) -> None

Manually set the function for this function node.

Args: func: Callable function to execute during invocation

paramself
paramfuncCallable[..., Any]

Returns

None
funcinvokeinvoke(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

paramself
paraminput_Any
paramkwargsAny
= {}

Returns

Any
funcget_new_stateget_new_state(self) -> FunctionNodeState

Create new state instance for this function node.

Returns: Fresh FunctionNodeState with empty message history

paramself

Returns

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

paramself
paramargs_dictdict[str, Any] | None

Returns

dict[str, Any]

Last updated on