Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Sep 23, 2025

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):

  • Replaced openai.AsyncAzureOpenAI() with openai.AsyncOpenAI()
  • Changed parameter mapping:
    • azure_endpointbase_url (with "/openai/v1" suffix for Azure OpenAI compatibility)
    • azure_ad_token_providerapi_key
  • Removed the deprecated api_version parameter completely

Infrastructure Updates:

  • Removed AZURE_OPENAI_API_VERSION environment variable references from all Bicep files (infra/main.bicep, infra/aca.bicep)
  • Updated deployment parameters (infra/main.parameters.json)
  • Cleaned up GitHub Actions workflow (.github/workflows/azure-dev.yaml)
  • Updated environment sample file (.env.sample)

Dependency Requirements:

  • Updated src/pyproject.toml to enforce openai>=1.108.1 (the minimum version supporting this migration)

Test Updates:

  • Modified test assertions to validate the new client properties (api_key, base_url) instead of Azure-specific attributes
  • Updated test assertions to expect the "/openai/v1" suffix in base_url
  • Removed obsolete AZURE_OPENAI_VERSION environment variables from test setup

Authentication Compatibility

The migration maintains full compatibility with both authentication patterns:

API Key Authentication:

# Before: AsyncAzureOpenAI(api_key="...", azure_endpoint="...", api_version="...")
# After: AsyncOpenAI(api_key="...", base_url="..."/openai/v1")

Managed Identity Authentication:

# Before: AsyncAzureOpenAI(azure_ad_token_provider=token_provider, azure_endpoint="...", api_version="...")
# After: AsyncOpenAI(api_key=token_provider, base_url="..."/openai/v1")

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.

Copilot AI changed the title [WIP] Migrate AzureOpenAI constructors to OpenAI client Migrate from deprecated AzureOpenAI to OpenAI client constructors Sep 23, 2025
Copilot AI requested a review from pamelafox September 23, 2025 22:07
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")
Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor

@pamelafox pamelafox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate AzureOpenAI constructors to OpenAI client

2 participants