-
Notifications
You must be signed in to change notification settings - Fork 22
Migrate AzureOpenAI constructors to OpenAI client #32
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
Conversation
|
@pamelafox 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs. I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review. |
Co-authored-by: pamelafox <297042+pamelafox@users.noreply.github.com>
| api_version="2024-03-01-preview", | ||
| azure_endpoint=f"https://{os.getenv('AZURE_OPENAI_SERVICE')}.openai.azure.com", | ||
| azure_ad_token_provider=token_provider, | ||
| client = openai.OpenAI( |
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.
@copilot Add "/openai/v1" to the endpoint URL
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.
Added /openai/v1 to the endpoint URL. The base_url is now https://{service}.openai.azure.com/openai/v1 for proper Azure OpenAI API access. (4934118)
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.
See comment
Co-authored-by: pamelafox <297042+pamelafox@users.noreply.github.com>
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.
lgtm
This PR migrates the repository from deprecated
AzureOpenAIconstructors to the standardOpenAIclient constructors to maintain compatibility with current OpenAI SDK versions.Changes Made
Updated
example.pyReplaced the deprecated constructor pattern:
Key parameter mappings:
AzureOpenAI→OpenAIazure_endpoint→base_url(with/openai/v1API path)azure_ad_token_provider→api_keyapi_versionparameter (no longer needed)Updated
requirements.txtChanged the OpenAI dependency from
openaitoopenai>=1.108.1to ensure compatibility with the new constructor pattern.Why This Change
The
AzureOpenAIandAsyncAzureOpenAIconstructors are deprecated in recent OpenAI SDK versions. The standardOpenAI/AsyncOpenAIconstructors now fully support Azure OpenAI endpoints and provide the same functionality while maintaining forward compatibility.This change ensures the repository works with OpenAI SDK versions 1.108.1 and later, which is the first version where the standard constructors fully replace the Azure-specific ones.
Fixes #31.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.