-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Python: Allow AzureOpenAIResponsesClient creation with Foundry project endpoint #3814
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
Python: Allow AzureOpenAIResponsesClient creation with Foundry project endpoint #3814
Conversation
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.
Pull request overview
Adds support for constructing AzureOpenAIResponsesClient via an Azure AI Foundry project (AIProjectClient or project endpoint), aligning it with existing Foundry-enabled client creation patterns elsewhere in the repo.
Changes:
- Added
project_client/project_endpointconstructor parameters toAzureOpenAIResponsesClientand a helper to create an OpenAI client via Foundry projects. - Added unit tests covering initialization via project client/endpoint and basic parameter validation.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
| python/packages/core/agent_framework/azure/_responses_client.py | Adds Foundry project-based client creation path and wiring into constructor. |
| python/packages/core/tests/azure/test_azure_responses_client.py | Adds tests for new constructor parameters and _create_client_from_project behavior. |
python/packages/core/agent_framework/azure/_responses_client.py
Outdated
Show resolved
Hide resolved
python/packages/core/agent_framework/azure/_responses_client.py
Outdated
Show resolved
Hide resolved
python/packages/core/tests/azure/test_azure_responses_client.py
Outdated
Show resolved
Hide resolved
python/packages/core/agent_framework/azure/_responses_client.py
Outdated
Show resolved
Hide resolved
python/packages/core/agent_framework/azure/_responses_client.py
Outdated
Show resolved
Hide resolved
Python Test Coverage Report •
Python Unit Test Overview
|
|||||||||||||||||||||||||||||||||||||||||||||
|
@eavanvalkenburg do you want to address any of Copilot's feedback? |
…dpoints Add project_client and project_endpoint parameters to allow creating the client via an Azure AI Foundry project. When provided, the client uses AIProjectClient.get_openai_client() to obtain the OpenAI client. The azure-ai-projects package is imported lazily and only required when using the project endpoint path. Co-authored-by: eavanvalkenburg <13749212+eavanvalkenburg@users.noreply.github.com>
Co-authored-by: eavanvalkenburg <13749212+eavanvalkenburg@users.noreply.github.com>
- Add 'type: message' to input items in _prepare_message_for_openai to comply with the Responses API schema requirement - Filter out empty dicts from unsupported content types to prevent sending items with invalid empty type values - Add azure_responses_client_with_foundry.py sample demonstrating AzureOpenAIResponsesClient with project_endpoint - Update README and pyrightconfig.samples.json accordingly
94b8c3c to
3f523ae
Compare
Patch agent_framework.azure._responses_client.AIProjectClient instead of azure.ai.projects.aio.AIProjectClient since the import is at module level.
Motivation and Context
AzureOpenAIResponsesClientonly supported direct Azure OpenAI endpoint configuration. Users working with Azure AI Foundry projects had no way to create a responses client from a project endpoint orAIProjectClient, unlikeAzureAIClientwhich already supports this.Description
Adds
project_clientandproject_endpointparameters toAzureOpenAIResponsesClient, enabling client creation via Azure AI Foundry projects.project_client: Pass an existingAIProjectClientdirectlyproject_endpoint+credential: Auto-creates anAIProjectClientfrom the endpointproject_client.get_openai_client()to obtain theAsyncOpenAIclient, which is then passed through the existingasync_clientcode pathazure-ai-projectsis lazily imported — no new hard dependency on the core packageContribution Checklist
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.