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
LEGACY_UNMANIFESTED_LIBRARY_PACKAGES
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.
Load pre-manifest library packages that register actions directly.
Manifested library actions are indexed as lazy refs by
_register_manifest_action_refs; only the packages in
LEGACY_UNMANIFESTED_LIBRARY_PACKAGES still register eagerly.
Normalize the action name to the required format.
Sanitize values before logging to prevent log injection.
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[RegisteredAction]
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 or runnable object.
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.
Bases: Mapping[str, RegisteredAction]
Read-only view over registered and lazily declared actions.
Iteration, in, and len reflect every registered and lazily declared
action name. Subscripting (and therefore dict(view)) resolves a lazy
action on demand, importing its module and raising KeyError if it cannot
be resolved. values and items deliberately expose only actions that
are already resolved, so iterating them never triggers a lazy import or
fails on an action whose optional dependency is missing.
Heuristics for determining if a Python file can have actions or not.
Currently, it only excludes the `init.py files.