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 <mebstyne@microsoft.com>
Co-authored-by: Dev 2049 <dev.dev2049@gmail.com>
This commit is contained in:
mebstyne-msft 2023-07-13 15:05:47 -05:00 committed by GitHub
parent c7b687e944
commit 120c52589b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -617,7 +617,7 @@ class AzureOpenAI(BaseOpenAI):
deployment_name: str = "" deployment_name: str = ""
"""Deployment name to use.""" """Deployment name to use."""
openai_api_type: str = "azure" openai_api_type: str = ""
openai_api_version: str = "" openai_api_version: str = ""
@root_validator() @root_validator()
@ -628,9 +628,7 @@ class AzureOpenAI(BaseOpenAI):
"OPENAI_API_VERSION", "OPENAI_API_VERSION",
) )
values["openai_api_type"] = get_from_dict_or_env( values["openai_api_type"] = get_from_dict_or_env(
values, values, "openai_api_type", "OPENAI_API_TYPE", "azure"
"openai_api_type",
"OPENAI_API_TYPE",
) )
return values return values