openai-chat-app-quickstart
openai-chat-app-quickstart copied to clipboard
Migrate from deprecated AzureOpenAI to standard OpenAI client constructors
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
- Updated
src/quartapp/chat.py:- Changed import from
AsyncAzureOpenAItoAsyncOpenAI - Updated client constructor parameters:
azure_endpoint→base_urlazure_ad_token_provider→api_key- Removed
api_versionparameter entirely
- Changed import from
Infrastructure Updates
- Updated
infra/main.bicep: RemovedopenAiApiVersionparameter and related output - Updated
infra/aca.bicep: RemovedAZURE_OPENAI_API_VERSIONenvironment variable - Updated
.env.sample: RemovedAZURE_OPENAI_API_VERSIONconfiguration
Dependencies
- Updated
src/pyproject.toml: Changed OpenAI requirement from"openai"to"openai>=1.108.1" - Regenerated
src/requirements.txt: Now uses OpenAI 1.109.0
Testing
- Updated
tests/test_app.py: Modified test assertion to checkapi_keyproperty instead of the deprecated_azure_ad_token_provider
Migration Example
Before:
bp.openai_client = AsyncAzureOpenAI(
api_version=os.getenv("AZURE_OPENAI_API_VERSION") or "2024-02-15-preview",
azure_endpoint=os.getenv("AZURE_OPENAI_ENDPOINT"),
azure_ad_token_provider=token_provider,
)
After:
bp.openai_client = AsyncOpenAI(
base_url=os.getenv("AZURE_OPENAI_ENDPOINT"),
api_key=token_provider,
)
Validation
- All existing tests continue to pass
- Application functionality remains unchanged
- Code passes linting checks
- Dependencies resolve correctly
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.