Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Sep 23, 2025

This PR migrates the repository from deprecated AzureOpenAI constructors to the standard OpenAI client constructors to maintain compatibility with current OpenAI SDK versions.

Changes Made

Updated example.py

Replaced the deprecated constructor pattern:

# Before
client = openai.AzureOpenAI(
    api_version="2024-03-01-preview",
    azure_endpoint=f"https://{os.getenv('AZURE_OPENAI_SERVICE')}.openai.azure.com",
    azure_ad_token_provider=token_provider,
)

# After
client = openai.OpenAI(
    base_url=f"https://{os.getenv('AZURE_OPENAI_SERVICE')}.openai.azure.com/openai/v1",
    api_key=token_provider,
)

Key parameter mappings:

  • AzureOpenAIOpenAI
  • azure_endpointbase_url (with /openai/v1 API path)
  • azure_ad_token_providerapi_key
  • Removed api_version parameter (no longer needed)

Updated requirements.txt

Changed the OpenAI dependency from openai to openai>=1.108.1 to ensure compatibility with the new constructor pattern.

Why This Change

The AzureOpenAI and AsyncAzureOpenAI constructors are deprecated in recent OpenAI SDK versions. The standard OpenAI / AsyncOpenAI constructors 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.

Copy link
Contributor Author

Copilot AI commented Sep 23, 2025

@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>
Copilot AI changed the title [WIP] Migrate AzureOpenAI constructors to OpenAI client Migrate AzureOpenAI constructors to OpenAI client Sep 23, 2025
Copilot AI requested a review from pamelafox September 23, 2025 21:26
Copilot finished work on behalf of pamelafox September 23, 2025 21:26
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(
Copy link
Contributor

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

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 to the endpoint URL. The base_url is now https://{service}.openai.azure.com/openai/v1 for proper Azure OpenAI API access. (4934118)

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

Co-authored-by: pamelafox <297042+pamelafox@users.noreply.github.com>
Copilot AI requested a review from pamelafox September 24, 2025 00:12
Copilot finished work on behalf of pamelafox September 24, 2025 00:12
@pamelafox pamelafox marked this pull request as ready for review September 24, 2025 12:13
Copy link
Collaborator

@madebygps madebygps left a comment

Choose a reason for hiding this comment

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

lgtm

@pamelafox pamelafox merged commit 0930e9d into main Sep 24, 2025
1 check passed
@pamelafox pamelafox deleted the copilot/fix-31 branch September 24, 2025 16:46
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

4 participants