From 6b94cf800529686c1983de511b776e22551fb679 Mon Sep 17 00:00:00 2001 From: Michael Anstis Date: Fri, 10 Jan 2025 11:56:16 +0000 Subject: [PATCH] Remove more ANSIBLE_AI_MODEL_MESH_xxx env vars. --- .../ai/api/model_pipelines/http/configuration.py | 2 +- .../ai/api/model_pipelines/llamacpp/configuration.py | 2 +- .../ai/api/model_pipelines/wca/configuration_base.py | 2 +- .../ai/api/pipelines/completion_stages/inference.py | 3 +-- ansible_ai_connect/ai/api/views.py | 2 +- ansible_ai_connect/main/settings/base.py | 8 ++++---- tools/docker-compose/compose.yaml | 1 - 7 files changed, 9 insertions(+), 11 deletions(-) diff --git a/ansible_ai_connect/ai/api/model_pipelines/http/configuration.py b/ansible_ai_connect/ai/api/model_pipelines/http/configuration.py index d23f75275..c9a361ed7 100644 --- a/ansible_ai_connect/ai/api/model_pipelines/http/configuration.py +++ b/ansible_ai_connect/ai/api/model_pipelines/http/configuration.py @@ -66,4 +66,4 @@ def __init__(self, **kwargs): @Register(api_type="http") class HttpConfigurationSerializer(BaseConfigSerializer): - verify_ssl = serializers.BooleanField(required=False, default=False) + verify_ssl = serializers.BooleanField(required=False, default=True) diff --git a/ansible_ai_connect/ai/api/model_pipelines/llamacpp/configuration.py b/ansible_ai_connect/ai/api/model_pipelines/llamacpp/configuration.py index a1a3d60e8..a96a141f5 100644 --- a/ansible_ai_connect/ai/api/model_pipelines/llamacpp/configuration.py +++ b/ansible_ai_connect/ai/api/model_pipelines/llamacpp/configuration.py @@ -66,4 +66,4 @@ def __init__(self, **kwargs): @Register(api_type="llamacpp") class LlamaCppConfigurationSerializer(BaseConfigSerializer): - verify_ssl = serializers.BooleanField(required=False, default=False) + verify_ssl = serializers.BooleanField(required=False, default=True) diff --git a/ansible_ai_connect/ai/api/model_pipelines/wca/configuration_base.py b/ansible_ai_connect/ai/api/model_pipelines/wca/configuration_base.py index b67603d1f..fdbcaf215 100644 --- a/ansible_ai_connect/ai/api/model_pipelines/wca/configuration_base.py +++ b/ansible_ai_connect/ai/api/model_pipelines/wca/configuration_base.py @@ -77,7 +77,7 @@ def __init__(self, provider: t_model_mesh_api_type, config: WCABaseConfiguration class WCABaseConfigurationSerializer(BaseConfigSerializer): api_key = serializers.CharField(required=False, allow_null=True, allow_blank=True) - verify_ssl = serializers.BooleanField(required=False, default=False) + verify_ssl = serializers.BooleanField(required=False, default=True) retry_count = serializers.IntegerField(required=False, default=4) enable_ari_postprocessing = serializers.BooleanField(required=False, default=False) health_check_api_key = serializers.CharField(required=True) diff --git a/ansible_ai_connect/ai/api/pipelines/completion_stages/inference.py b/ansible_ai_connect/ai/api/pipelines/completion_stages/inference.py index 97dd4de6e..193a8b191 100644 --- a/ansible_ai_connect/ai/api/pipelines/completion_stages/inference.py +++ b/ansible_ai_connect/ai/api/pipelines/completion_stages/inference.py @@ -19,7 +19,6 @@ from ansible_anonymizer import anonymizer from django.apps import apps -from django.conf import settings from django_prometheus.conf import NAMESPACE from prometheus_client import Histogram @@ -124,7 +123,7 @@ def process(self, context: CompletionContext) -> None: except ModelTimeoutError as e: exception = e logger.warning( - f"model timed out after {settings.ANSIBLE_AI_MODEL_MESH_API_TIMEOUT} " + f"model timed out after {model_mesh_client.config.timeout} " f"seconds (per task) for suggestion {suggestion_id}" ) raise ModelTimeoutException(cause=e) diff --git a/ansible_ai_connect/ai/api/views.py b/ansible_ai_connect/ai/api/views.py index 97cc3ddcd..5113b5a1a 100644 --- a/ansible_ai_connect/ai/api/views.py +++ b/ansible_ai_connect/ai/api/views.py @@ -601,7 +601,7 @@ def perform_content_matching( except ModelTimeoutError as e: exception = e logger.warn( - f"model timed out after {settings.ANSIBLE_AI_MODEL_MESH_API_TIMEOUT} seconds" + f"model timed out after {model_mesh_client.config.timeout} seconds" f" for suggestion {suggestion_id}" ) raise ModelTimeoutException(cause=e) diff --git a/ansible_ai_connect/main/settings/base.py b/ansible_ai_connect/main/settings/base.py index a6bfc15ea..90e0fe6e4 100644 --- a/ansible_ai_connect/main/settings/base.py +++ b/ansible_ai_connect/main/settings/base.py @@ -77,7 +77,7 @@ # ANSIBLE_AI_MODEL_MESH_MODEL_ID = os.getenv("ANSIBLE_AI_MODEL_MESH_MODEL_NAME") # Model API Timeout (in seconds). Default is None. -ANSIBLE_AI_MODEL_MESH_API_TIMEOUT = os.getenv("ANSIBLE_AI_MODEL_MESH_API_TIMEOUT") +# ANSIBLE_AI_MODEL_MESH_API_TIMEOUT = os.getenv("ANSIBLE_AI_MODEL_MESH_API_TIMEOUT") # WCA - General ANSIBLE_WCA_IDP_URL = os.getenv("ANSIBLE_WCA_IDP_URL") or "https://iam.cloud.ibm.com/identity" @@ -185,9 +185,9 @@ def is_ssl_enabled(value: str) -> bool: AAP_API_URL = os.environ.get("AAP_API_URL") AAP_API_PROVIDER_NAME = os.environ.get("AAP_API_PROVIDER_NAME", "Ansible Automation Platform") SOCIAL_AUTH_VERIFY_SSL = is_ssl_enabled(os.getenv("SOCIAL_AUTH_VERIFY_SSL", "True")) -ANSIBLE_AI_MODEL_MESH_API_VERIFY_SSL = is_ssl_enabled( - os.getenv("ANSIBLE_AI_MODEL_MESH_API_VERIFY_SSL", "True") -) +# ANSIBLE_AI_MODEL_MESH_API_VERIFY_SSL = is_ssl_enabled( +# os.getenv("ANSIBLE_AI_MODEL_MESH_API_VERIFY_SSL", "True") +# ) SOCIAL_AUTH_AAP_KEY = os.environ.get("SOCIAL_AUTH_AAP_KEY") SOCIAL_AUTH_AAP_SECRET = os.environ.get("SOCIAL_AUTH_AAP_SECRET") SOCIAL_AUTH_AAP_SCOPE = ["read"] diff --git a/tools/docker-compose/compose.yaml b/tools/docker-compose/compose.yaml index 8c03a1931..31eacd343 100644 --- a/tools/docker-compose/compose.yaml +++ b/tools/docker-compose/compose.yaml @@ -39,7 +39,6 @@ services: - SECRET_KEY=${SECRET_KEY:-somesecret} - SEGMENT_WRITE_KEY=${SEGMENT_WRITE_KEY} - SEGMENT_ANALYTICS_WRITE_KEY=${SEGMENT_ANALYTICS_WRITE_KEY} - - ANSIBLE_AI_MODEL_MESH_API_TIMEOUT=${ANSIBLE_AI_MODEL_MESH_API_TIMEOUT:-120} - COMPLETION_USER_RATE_THROTTLE=${COMPLETION_USER_RATE_THROTTLE} - SOCIAL_AUTH_OIDC_OIDC_ENDPOINT=${SOCIAL_AUTH_OIDC_OIDC_ENDPOINT} - SOCIAL_AUTH_OIDC_KEY=${SOCIAL_AUTH_OIDC_KEY}