-
Notifications
You must be signed in to change notification settings - Fork 139
Migrate from deprecated AzureOpenAI to standard OpenAI client constructors #340
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
Co-authored-by: pamelafox <[email protected]>
Co-authored-by: pamelafox <[email protected]>
!infra/**/main.parameters.json | ||
|
||
# Pip artifacts and temporary files | ||
=* |
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.
Remove this from gitignore, no changes to gitignore should be needed
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 comments
azure_ad_token_provider=token_provider, | ||
# Create the Asynchronous OpenAI client | ||
bp.openai_client = AsyncOpenAI( | ||
base_url=os.getenv("AZURE_OPENAI_ENDPOINT"), |
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.
This URL needs "/openai/v1" at the end
# This file is autogenerated by pip-compile with Python 3.12 | ||
# by the following command: | ||
# | ||
# pip-compile --output-file=src/requirements.txt src/pyproject.toml |
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.
This change shouldnt be needed, as long as you run the file from inside the src folder
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.
Add an AGENTS.md that shows how to run pip-compile from inside the src folder
This PR migrates the repository from the deprecated Azure-specific OpenAI client constructors (
AsyncAzureOpenAI
) to the standard OpenAI client constructors (AsyncOpenAI
) to maintain compatibility with current and future OpenAI SDK versions.Changes Made
Core Application Updates
src/quartapp/chat.py
:AsyncAzureOpenAI
toAsyncOpenAI
azure_endpoint
→base_url
azure_ad_token_provider
→api_key
api_version
parameter entirelyInfrastructure Updates
infra/main.bicep
: RemovedopenAiApiVersion
parameter and related outputinfra/aca.bicep
: RemovedAZURE_OPENAI_API_VERSION
environment variable.env.sample
: RemovedAZURE_OPENAI_API_VERSION
configurationDependencies
src/pyproject.toml
: Changed OpenAI requirement from"openai"
to"openai>=1.108.1"
src/requirements.txt
: Now uses OpenAI 1.109.0Testing
tests/test_app.py
: Modified test assertion to checkapi_key
property instead of the deprecated_azure_ad_token_provider
Migration Example
Before:
After:
Validation
This migration ensures the codebase uses the supported OpenAI SDK API surface while maintaining full compatibility with Azure OpenAI services.
Fixes #339.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.