diff --git a/server/__init__.py b/server/__init__.py index 6ae0154f07..f17b32b02e 100644 --- a/server/__init__.py +++ b/server/__init__.py @@ -36,6 +36,7 @@ from server.lib.disaster_dashboard import get_disaster_dashboard_data import server.lib.i18n as i18n import server.lib.util as libutil +import server.services.ai as ai from server.services.discovery import configure_endpoints_from_ingress from server.services.discovery import get_health_check_urls @@ -288,7 +289,11 @@ def create_app(): app.config['BABEL_DEFAULT_LOCALE'] = i18n.DEFAULT_LOCALE app.config['BABEL_TRANSLATION_DIRECTORIES'] = 'i18n' - # Initialize the AI module. + # Enable the AI module. + if cfg.ENABLE_AI: + app.config['AI_CONTEXT'] = ai.Context() + + # # Enable the NL model. if os.environ.get('ENABLE_MODEL') == 'true': libutil.check_backend_ready([app.config['NL_ROOT'] + '/healthz']) # Some specific imports for the NL Interface. diff --git a/server/app_env/_base.py b/server/app_env/_base.py index 7280f45442..3fb0a76f0c 100644 --- a/server/app_env/_base.py +++ b/server/app_env/_base.py @@ -30,6 +30,7 @@ class Config: os.environ.get('MIXER_HASH')) API_ROOT = 'http://127.0.0.1:8081' # Port for Kubernetes ESP. NL_ROOT = 'http://127.0.0.1:6060' # Port for Kubernetes ESP. + ENABLE_AI = False AI_CONFIG_PATH = '/datacommons/ai/ai.yaml' SECRET_PROJECT = os.environ.get('SECRET_PROJECT') or '' MAPS_API_KEY = os.environ.get('MAPS_API_KEY') or '' diff --git a/server/app_env/autopush.py b/server/app_env/autopush.py index 86010f87a3..d4d65c0bb2 100644 --- a/server/app_env/autopush.py +++ b/server/app_env/autopush.py @@ -18,4 +18,5 @@ class Config(_base.Config): GA_ACCOUNT = 'G-Y6ZXZ9JK3H' GCS_BUCKET = 'datcom-website-autopush-resources' + ENABLE_AI = True LOG_QUERY = True \ No newline at end of file diff --git a/server/app_env/local.py b/server/app_env/local.py index 7f61fe05ca..9e43b9c711 100644 --- a/server/app_env/local.py +++ b/server/app_env/local.py @@ -22,7 +22,7 @@ class Config(_base.Config): API_ROOT = 'https://autopush.api.datacommons.org' API_PROJECT = 'datcom-mixer-autopush' AI_CONFIG_PATH = os.path.abspath( - os.path.join(os.path.curdir, '..', 'deploy/overlays/local/ai.yaml')) + os.path.join(os.path.curdir, 'deploy/overlays/local/ai.yaml')) SCHEME = 'http' GCS_BUCKET = 'datcom-website-autopush-resources' LOG_QUERY = True