From 44c1c374527a81d34ade9282de8fd67673b5d287 Mon Sep 17 00:00:00 2001 From: Roger Yang Date: Tue, 21 May 2024 09:41:26 -0700 Subject: [PATCH 1/2] fix: clarify error message for azure api-key --- .../src/phoenix/evals/models/openai.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/phoenix-evals/src/phoenix/evals/models/openai.py b/packages/phoenix-evals/src/phoenix/evals/models/openai.py index 8ef4148bb4..688acfe806 100644 --- a/packages/phoenix-evals/src/phoenix/evals/models/openai.py +++ b/packages/phoenix-evals/src/phoenix/evals/models/openai.py @@ -156,10 +156,16 @@ def _init_open_ai(self) -> None: api_key = os.getenv(OPENAI_API_KEY_ENVVAR_NAME) if api_key is None: # TODO: Create custom AuthenticationError - raise RuntimeError( - "OpenAI's API key not provided. Pass it as an argument to 'api_key' " - "or set it in your environment: 'export OPENAI_API_KEY=sk-****'" - ) + if self._is_azure: + raise RuntimeError( + "Azure API key not provided. Pass it as an argument to 'api_key' " + "or set it in your environment: 'export OPENAI_API_KEY=****'" + ) + else: + raise RuntimeError( + "OpenAI's API key not provided. Pass it as an argument to 'api_key' " + "or set it in your environment: 'export OPENAI_API_KEY=sk-****'" + ) self.api_key = api_key # Set the version, organization, and base_url - default to openAI From a532bfd3a817d1e4df8652c2072abc17b8cbce3d Mon Sep 17 00:00:00 2001 From: Roger Yang Date: Tue, 21 May 2024 09:53:01 -0700 Subject: [PATCH 2/2] clean up --- .../phoenix-evals/src/phoenix/evals/models/openai.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/phoenix-evals/src/phoenix/evals/models/openai.py b/packages/phoenix-evals/src/phoenix/evals/models/openai.py index 688acfe806..81e792f02d 100644 --- a/packages/phoenix-evals/src/phoenix/evals/models/openai.py +++ b/packages/phoenix-evals/src/phoenix/evals/models/openai.py @@ -161,11 +161,10 @@ def _init_open_ai(self) -> None: "Azure API key not provided. Pass it as an argument to 'api_key' " "or set it in your environment: 'export OPENAI_API_KEY=****'" ) - else: - raise RuntimeError( - "OpenAI's API key not provided. Pass it as an argument to 'api_key' " - "or set it in your environment: 'export OPENAI_API_KEY=sk-****'" - ) + raise RuntimeError( + "OpenAI's API key not provided. Pass it as an argument to 'api_key' " + "or set it in your environment: 'export OPENAI_API_KEY=sk-****'" + ) self.api_key = api_key # Set the version, organization, and base_url - default to openAI