nemoguardrails.actions.action_dispatcher
nemoguardrails.actions.action_dispatcher
Module for the calling proper action endpoints based on events received at action server endpoint
Module Contents
Classes
Functions
Data
API
Gets the dictionary of registered actions. Returns: dict: A dictionary where keys are action names and values are callable action functions.
Loop through all the subdirectories and check for the class with @action decorator and add in action_classes dict.
Parameters:
The directory to search for actions.
Returns: Dict
Dictionary of found actions.
Loads the actions from the specified python module.
Parameters:
The path of the Python module.
Returns:
Dictionary of loaded actions.
Normalize the action name to the required format.
Execute a registered action.
Parameters:
The name of the action to execute.
Parameters for the action.
Returns: Tuple[Union[Optional[str], Dict[str, Any]], str]
Tuple[Union[str, Dict[str, Any]], str]: A tuple containing the result and status.
Get the registered action by name.
Parameters:
The name of the action.
Returns: Optional[Callable]
The registered action.
Get the list of available actions.
Returns: List[str]
List[str]: List of available actions.
Check if an action is registered.
Loads all actions from the specified path.
This method loads all actions from the actions.py file if it exists and
all actions inside the actions folder if it exists.
Parameters:
A string representing the path from which to load actions.
Registers an action with the given name.
Parameters:
The action function.
The name of the action. Defaults to None.
If an action already exists, whether it should be overridden or not.
Registers all the actions from the given object.
Parameters:
The object containing actions.
If an action already exists, whether it should be overridden or not.
Heuristics for determining if a Python file can have actions or not.
Currently, it only excludes the `init.py files.