-
Notifications
You must be signed in to change notification settings - Fork 0
add auth parameter and AzureAuth #15
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
base: main
Are you sure you want to change the base?
Conversation
*, | ||
token_provider: AzureTokenProvider | None = None, | ||
credential: TokenCredential | None = None, | ||
scopes: list[str] = ["https://cognitiveservices.azure.com/.default"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick, parameters of type list[str]
need to be checked correct type passed in. You will get very unexpected results if you accidentally pass in a str
.
src/openai/lib/azure.py
Outdated
token = await self.token_provider() | ||
return token | ||
|
||
if self.credential is not None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The AzureAsyncAuth instance needs to cache the bearer token provider.
src/openai/lib/azure.py
Outdated
raise ImportError( | ||
"azure-identity library is not installed. Please install it to use AzureAuth." | ||
) from err | ||
token_provider = get_bearer_token_provider(self.credential, *self.scopes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to cache this on self
.
Changes being requested
Example usages:
Additional context & links