Fix Issue #6650: Enable Azure Active Directory token-based auth access for AzureChatOpenAI (#8622)

When using AzureChatOpenAI the openai_api_type defaults to "azure". The
utils' get_from_dict_or_env() function triggered by the root validator
does not look for user provided values from environment variables
OPENAI_API_TYPE, so other values like "azure_ad" are replaced with
"azure". This does not allow the use of token-based auth.

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.

This fixes #6650

---------

Co-authored-by: Bagatur <baskaryan@gmail.com>
pull/8738/head
Vasileios Mansolas 1 year ago committed by GitHub
parent 29f51055e8
commit e68a1d73d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -45,7 +45,7 @@ class AzureChatOpenAI(ChatOpenAI):
"""
deployment_name: str = ""
openai_api_type: str = "azure"
openai_api_type: str = ""
openai_api_base: str = ""
openai_api_version: str = ""
openai_api_key: str = ""
@ -71,9 +71,7 @@ class AzureChatOpenAI(ChatOpenAI):
"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", default="azure"
)
values["openai_organization"] = get_from_dict_or_env(
values,

Loading…
Cancel
Save