Пример #1
0
    def _register_all_actions(self) -> None:
        """Scan for all user subclasses of `Action`, and register them."""
        import inspect

        actions = utils.all_subclasses(Action)

        for action in actions:
            if (not action.__module__.startswith("rasa_core.")
                    and not action.__module__.startswith("rasa.")
                    and not action.__module__.startswith("rasa_sdk.")
                    and not action.__module__.startswith("rasa_core_sdk.")
                    and not inspect.isabstract(action)):
                self.register_action(action)
Пример #2
0
    def register_package(self, package):
        try:
            self._import_submodules(package)
        except ImportError:
            logger.exception(
                "Failed to register package '{}'.".format(package))

        actions = utils.all_subclasses(Action)

        for action in actions:
            meta = action.__dict__.get("Meta", False)
            abstract = getattr(meta, "abstract", False)
            if (not action.__module__.startswith("rasa_core.")
                    and not action.__module__.startswith("rasa.")
                    and not action.__module__.startswith("rasa_sdk.")
                    and not action.__module__.startswith("rasa_core_sdk.")
                    and not abstract):
                self.register_action(action)
Пример #3
0
    def register_package(self, package: Union[Text, types.ModuleType]) -> None:
        from rasa_sdk.interfaces import Action

        try:
            self._import_submodules(package)
        except ImportError:
            logger.exception(f"Failed to register package '{package}'.")
            sys.exit(1)

        actions = utils.all_subclasses(Action)

        for action in actions:
            meta = action.__dict__.get("Meta", False)
            abstract = getattr(meta, "abstract", False)
            if (not action.__module__.startswith("rasa_core.")
                    and not action.__module__.startswith("rasa.")
                    and not action.__module__.startswith("rasa_sdk.")
                    and not action.__module__.startswith("rasa_core_sdk.")
                    and not abstract):
                self.register_action(action)