yasmin.cb_state module

class yasmin.cb_state.CbState(outcomes: Set[str], cb: Callable, *args: Any, **kwargs: Any)

Bases: State

Represents a state that executes a callback function.

The CbState class inherits from the State class and is designed to execute a user-defined callback function, utilizing a shared pointer to a Blackboard object to obtain necessary data.

Attributes:

_cb (Callable): Pointer to the callback function to be executed. _args (tuple): Positional arguments passed to the callback. _kwargs (dict): Keyword arguments passed to the callback.

execute(blackboard: Blackboard) str

Executes the callback function.

This function is called to execute the callback and retrieve the result. It may use the provided Blackboard for additional data.

Args:
blackboard (Blackboard): A shared pointer to the Blackboard object

used during execution.

Returns:

str: The result of the callback function execution as a string.

Raises:

RuntimeError: If the callback execution fails.