Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make azure_ad_token_provider customizable. #4931

Open
wants to merge 3 commits into
base: 0.2
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions autogen/oai/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,11 +472,14 @@ def _configure_azure_openai(self, config: Dict[str, Any], openai_config: Dict[st
openai_config["azure_endpoint"] = openai_config.get("azure_endpoint", openai_config.pop("base_url", None))

# Create a default Azure token provider if requested
if openai_config.get("azure_ad_token_provider") == "DEFAULT":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default is meant to refer to the DefaultAzureCredential, however the parameter that is being changed here is the scope. I feel it should be added as a separate parameter that is correctly named

azure_ad_token_provider = openai_config.get("azure_ad_token_provider")
if azure_ad_token_provider is not None:
assert isinstance(azure_ad_token_provider, str), "azure_ad_token_provider must be a string"
import azure.identity

if azure_ad_token_provider == "DEFAULT":
azure_ad_token_provider = "https://cognitiveservices.azure.com/.default"
openai_config["azure_ad_token_provider"] = azure.identity.get_bearer_token_provider(
azure.identity.DefaultAzureCredential(), "https://cognitiveservices.azure.com/.default"
azure.identity.DefaultAzureCredential(), azure_ad_token_provider
)

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