def __init__(self, app=None, blueprint=None, route=None, dev_token=None, client_token=None):

        self.app = app
        self.blueprint = blueprint
        self._route = route
        self._intent_action_funcs = {}
        self._intent_mappings = {}
        self._intent_converts = {}
        self._intent_defaults = {}
        self._intent_fallbacks = {}
        self._intent_prompts = {}
        self._intent_events = {}
        self._required_contexts = {}
        self._context_funcs = {}
        self._func_contexts = {}

        self.api = ApiAi(dev_token, client_token)

        if route is None and app is not None:

            logger.warn("""WARNING:
                No route was provided for the Assistant object, but a flask `app` object given
                The Assistant will be mapped to the app's '/' endpoint.
                If this is a problem please initialize the Assitant with the 'route' parameter
                """)

            self._route = '/'

        if app is not None:
            self.init_app(app)
        elif blueprint is not None:
            self.init_blueprint(blueprint)
Exemple #2
0
    def __init__(
        self,
        app=None,
        blueprint=None,
        route=None,
        project_id=None,
        dev_token=None,
        client_token=None,
        client_id=None,
    ):

        self.app = app
        self.blueprint = blueprint
        self._route = route
        self.project_id = project_id
        self.client_id = client_id
        self._intent_action_funcs = {}
        self._intent_mappings = {}
        self._intent_converts = {}
        self._intent_defaults = {}
        self._intent_fallbacks = {}
        self._intent_prompts = {}
        self._intent_events = {}
        self._required_contexts = {}
        self._context_funcs = {}
        self._func_contexts = {}

        self.api = ApiAi(dev_token, client_token)

        if route is None and app is not None:
            self._route = "/"

        if app is not None:
            self.init_app(app)
        elif blueprint is not None:
            self.init_blueprint(blueprint)
        else:
            raise ValueError(
                "Assistant object must be intialized with either an app or blueprint"
            )

        if self.client_id is None:
            self.client_id = self.app.config.get("AOG_CLIENT_ID")

        if project_id is None:
            import warnings

            warnings.warn(
                """\nGoogle Cloud Project ID is required to manage contexts using flask-assistant\n
                Please initialize the Assistant object with a project ID
                assist = Assistant(app, project_id='YOUR_PROJECT_ID")""",
                stacklevel=2,
            )
Exemple #3
0
    def __init__(self, app=None, route='/'):

        self.app = app
        self._route = route
        self._intent_action_funcs = {}
        self._intent_mappings = {}
        self._intent_converts = {}
        self._intent_defaults = {}
        self._intent_prompts = {}
        self._required_contexts = {}
        self._context_funcs = {}
        self._func_contexts = {}

        self.api = ApiAi()

        if app is not None:
            self.init_app(app)