diff --git a/validmind/ai/utils.py b/validmind/ai/utils.py index 00a5c13c2..0e40d2ef5 100644 --- a/validmind/ai/utils.py +++ b/validmind/ai/utils.py @@ -3,9 +3,8 @@ # SPDX-License-Identifier: AGPL-3.0 AND ValidMind Commercial import os -from urllib.parse import urljoin -from openai import AzureOpenAI, Client, OpenAI +from openai import AzureOpenAI, OpenAI from ..logging import get_logger from ..utils import md_to_html @@ -83,28 +82,9 @@ def get_client_and_model(): logger.debug(f"Using Azure OpenAI {__model} for generating descriptions") else: - try: - # TODO: fix circular import - from ..api_client import get_ai_key, get_api_host - - response = get_ai_key() - __client = Client( - base_url=( - # TODO: improve this to be a bit more dynamic - "http://localhost:4000/genai" - if "localhost" in get_api_host() - else urljoin(get_api_host(), "/genai") - ), - api_key=response["key"], - ) - __model = "gpt-4o" # TODO: backend should tell us which model to use - logger.debug(f"Using ValidMind {__model} for generating descriptions") - except Exception as e: - logger.debug(f"Failed to get API key: {e}") - raise ValueError( - "OPENAI_API_KEY, AZURE_OPENAI_KEY must be set, or your account " - "must be setup to use ValidMind's LLM in order to use LLM features" - ) + raise ValueError( + "OPENAI_API_KEY, AZURE_OPENAI_KEY must be setup to use LLM features" + ) return __client, __model diff --git a/validmind/api_client.py b/validmind/api_client.py index 51e03d547..7bee2290b 100644 --- a/validmind/api_client.py +++ b/validmind/api_client.py @@ -525,21 +525,6 @@ def log_metric( ) -def get_ai_key() -> Dict[str, Any]: - """Calls the API to get an API key for our LLM proxy.""" - r = requests.get( - url=_get_url("ai/key"), - headers=_get_api_headers(), - ) - - if r.status_code != 200: - # TODO: improve error handling when there's no Open AI API or AI key available - # logger.error("Could not get AI key from ValidMind API") - raise_api_error(r.text) - - return r.json() - - def generate_test_result_description(test_result_data: Dict[str, Any]) -> str: r = requests.post( url=_get_url("ai/generate/test_result_description"),