feat(openai): add Azure OpenAI client support#482
Open
kime541200 wants to merge 2 commits into
Open
Conversation
|
No linked issues found. Please link an issue in your pull request description or title. Per our Contributing Guidelines, all PRs must:
You can also use cross-repo references like |
Allow Azure OpenAI clients to initialize with Azure AD token credentials instead of requiring an API key. Document Azure OpenAI usage and cover token-based auth paths in tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #49. Related to #99.
Feature
Adds native Azure OpenAI client initialization to the existing OpenAI provider.
When callers provide Azure OpenAI client kwargs such as
azure_endpoint,api_version,azure_ad_token,azure_ad_token_provider, orazure_deployment,OpenAILanguageModelnow initializesopenai.AzureOpenAIinstead of the standard
openai.OpenAIclient. These Azure-specific kwargs arekept as client configuration and are not forwarded as chat completions request
parameters.
This preserves the existing OpenAI-compatible
base_urlpath when Azure kwargsare not provided. It also allows Azure OpenAI authentication with either an API
key, an Azure AD token, or an Azure AD token provider.
How Has This Been Tested?
Additional local verification: I installed
langextractfrom this PR branch ina downstream sample project and ran an Azure OpenAI extraction smoke check,
verifying a successful Azure OpenAI response with exact text alignment.
Checklist:
Code of conduct.
Contributing
page, and I either signed the Google
Individual CLA
or am covered by my company's
Corporate CLA.
issue(s) and we have agreed upon the general approach.
issue(s) that documentation elsewhere needs updating.
Google's Python Style Guide
and ran
pylintover the affected code.