From 120c52589bee9f2d2be1acdd000fc31cc5f18ee6 Mon Sep 17 00:00:00 2001 From: mebstyne-msft <136742741+mebstyne-msft@users.noreply.github.com> Date: Thu, 13 Jul 2023 15:05:47 -0500 Subject: [PATCH] Enabled Azure Active Directory token-based auth access to OpenAI completions (#6313) With AzureOpenAI openai_api_type defaulted to "azure" the logic in utils' get_from_dict_or_env() function triggered by the root validator never looks to environment for the user's runtime openai_api_type values. This inhibits folks using token-based auth, or really any auth model other than "azure." By removing the "default" value, this allows environment variables to be pulled at runtime for the openai_api_type and thus enables the other api_types which are expected to work. --------- Co-authored-by: Ebo Co-authored-by: Dev 2049 --- langchain/llms/openai.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/langchain/llms/openai.py b/langchain/llms/openai.py index 4eb28f3b90..e241ed7fb8 100644 --- a/langchain/llms/openai.py +++ b/langchain/llms/openai.py @@ -617,7 +617,7 @@ class AzureOpenAI(BaseOpenAI): deployment_name: str = "" """Deployment name to use.""" - openai_api_type: str = "azure" + openai_api_type: str = "" openai_api_version: str = "" @root_validator() @@ -628,9 +628,7 @@ class AzureOpenAI(BaseOpenAI): "OPENAI_API_VERSION", ) values["openai_api_type"] = get_from_dict_or_env( - values, - "openai_api_type", - "OPENAI_API_TYPE", + values, "openai_api_type", "OPENAI_API_TYPE", "azure" ) return values