Skip to content

Commit 7ec7506

Browse files
chingancrysweetjackgerrits
authored
Make azure_ad_token_provider customizable. (#4931)
## Why are these changes needed? Currently, when using azure openai, `azure_ad_token_provider` in `OAI_CONFIG_LIST` can only take a value of "DEFAULT" which uses the default token provider "https://cognitiveservices.azure.com/.default". This patch would allow users providing custom token providers by setting `azure_ad_token_provider` to other values. ## Checks - [ x] I've included any doc changes needed for https://microsoft.github.io/autogen/. See https://microsoft.github.io/autogen/docs/Contribute#documentation to build and test documentation locally. - [ x] I've made sure all auto checks have passed. --------- Co-authored-by: Ryan Sweet <[email protected]> Co-authored-by: Jack Gerrits <[email protected]> Co-authored-by: Jack Gerrits <[email protected]>
1 parent 14fbb3b commit 7ec7506

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

autogen/oai/client.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,8 +475,11 @@ def _configure_azure_openai(self, config: Dict[str, Any], openai_config: Dict[st
475475
if openai_config.get("azure_ad_token_provider") == "DEFAULT":
476476
import azure.identity
477477

478+
azure_ad_token_provider_scope = openai_config.get(
479+
"azure_ad_token_provider_scope", "https://cognitiveservices.azure.com/.default"
480+
)
478481
openai_config["azure_ad_token_provider"] = azure.identity.get_bearer_token_provider(
479-
azure.identity.DefaultAzureCredential(), "https://cognitiveservices.azure.com/.default"
482+
azure.identity.DefaultAzureCredential(), azure_ad_token_provider_scope
480483
)
481484

482485
def _configure_openai_config_for_bedrock(self, config: Dict[str, Any], openai_config: Dict[str, Any]) -> None:

0 commit comments

Comments
 (0)