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>
pull/7675/head
mebstyne-msft 1 year ago committed by GitHub
parent c7b687e944
commit 120c52589b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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

Loading…
Cancel
Save