-
Notifications
You must be signed in to change notification settings - Fork 19
Migrate from deprecated AzureOpenAI to OpenAI client constructors #62
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]>
…irements Co-authored-by: pamelafox <[email protected]>
src/quartapp/chat.py
Outdated
| bp.openai_client = openai.AsyncAzureOpenAI( | ||
| api_version=os.getenv("AZURE_OPENAI_API_VERSION") or "2024-02-15-preview", | ||
| azure_endpoint=os.getenv("AZURE_OPENAI_ENDPOINT"), | ||
| client_args["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.
@copilot This needs to have "/openai/v1" at end of the 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" suffix to the Azure OpenAI endpoint URL. The base_url now correctly appends "/openai/v1" to the AZURE_OPENAI_ENDPOINT environment variable value. Also updated the test assertions to expect this suffix. Changes in commit fa1f8ea.
pamelafox
left a comment
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 <[email protected]>
This PR migrates the repository from the deprecated Azure-specific OpenAI client constructors (
AsyncAzureOpenAI) to the standard OpenAI constructors (AsyncOpenAI) to maintain compatibility with current and future OpenAI SDK versions.Changes Made
Core Client Migration (
src/quartapp/chat.py):openai.AsyncAzureOpenAI()withopenai.AsyncOpenAI()azure_endpoint→base_url(with "/openai/v1" suffix for Azure OpenAI compatibility)azure_ad_token_provider→api_keyapi_versionparameter completelyInfrastructure Updates:
AZURE_OPENAI_API_VERSIONenvironment variable references from all Bicep files (infra/main.bicep,infra/aca.bicep)infra/main.parameters.json).github/workflows/azure-dev.yaml).env.sample)Dependency Requirements:
src/pyproject.tomlto enforceopenai>=1.108.1(the minimum version supporting this migration)Test Updates:
api_key,base_url) instead of Azure-specific attributesAZURE_OPENAI_VERSIONenvironment variables from test setupAuthentication Compatibility
The migration maintains full compatibility with both authentication patterns:
API Key Authentication:
Managed Identity Authentication:
All tests continue to pass (6/6), ensuring no functional regressions while adopting the supported SDK API surface.
Fixes #61.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.