-
Notifications
You must be signed in to change notification settings - Fork 835
Remove Azure.AI.OpenAI dependency from templates and tests #6873
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
...soft.Extensions.AI.Templates/src/ChatWithCustomData/ChatWithCustomData-CSharp.Web/Program.cs
Outdated
Show resolved
Hide resolved
...soft.Extensions.AI.Templates/src/ChatWithCustomData/ChatWithCustomData-CSharp.Web/Program.cs
Outdated
Show resolved
Hide resolved
@stephentoub I pushed a commit that addressed a related and some unrelated issues with our use of bool symbols in the template logic. The tests for this were failing and that sent me down a rabbit hole. Those changes ended up fixing a bug in the README where we were failing to include a block of text when we should have for Azure prereqs. Everything should be passing now, and I cherry-picked the commit from #6874 into here too. That might result in a merge conflict, but I can help resolve if so. Please review the actual changes you were aiming to have in this PR though to ensure those still land the way you expected. |
6ec55f7
to
ebd5d3f
Compare
@trrwilson, does this replacement for Azure.AI.OpenAI look like what you'd expect? e.g. https://github.com/dotnet/extensions/pull/6873/files#diff-07c36055059da3158abf7c72aabe24f5e5a634a6dcb05700b3654f3ce6d5c306R28 |
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
This PR removes all direct dependencies on the Azure.AI.OpenAI
package from project templates and test code, replacing them with the standard OpenAI
client library configured to work with Azure OpenAI endpoints. This aligns with the approach from a previous effort to consolidate on the standard OpenAI client.
Key changes include:
- Updating integration test helpers to use
OpenAIClient
instead ofAzureOpenAIClient
- Removing
Azure.AI.OpenAI
package references from project files and replacing withAzure.Core
where needed - Updating project template code to use the standard OpenAI client with Azure-compatible endpoints
Reviewed Changes
Copilot reviewed 27 out of 27 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
test/Libraries/Microsoft.Extensions.AI.OpenAI.Tests/IntegrationTestHelpers.cs | Updated to use OpenAIClient with Azure endpoint configuration and Bearer token authentication |
test/Libraries/Microsoft.Extensions.AI.Evaluation.Integration.Tests/Setup.cs | Migrated from AzureOpenAIClient to OpenAIClient with Azure endpoint support |
Multiple .csproj files | Removed Azure.AI.OpenAI package references and added Azure.Core where needed |
src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/ChatWithCustomData/ChatWithCustomData-CSharp.Web/Program.cs | Updated template code to use OpenAIClient with Azure endpoint configuration |
Multiple template files | Updated conditional compilation directives from "Use*" to "Is*" pattern |
test/Libraries/Microsoft.Extensions.AI.OpenAI.Tests/IntegrationTestHelpers.cs
Outdated
Show resolved
Hide resolved
test/Libraries/Microsoft.Extensions.AI.Evaluation.Integration.Tests/Setup.cs
Outdated
Show resolved
Hide resolved
...soft.Extensions.AI.Templates/src/ChatWithCustomData/ChatWithCustomData-CSharp.Web/Program.cs
Outdated
Show resolved
Hide resolved
@jeffhandley, would you mind taking a look at the CI failures in the template tests? (CreateRestoreAndBuild_BasicTemplate) |
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
ebd5d3f
to
4b0880d
Compare
var endpoint = new Uri(Settings.Current.Endpoint); | ||
AzureOpenAIClientOptions options = new(); | ||
var credential = new ChainedTokenCredential(new AzureCliCredential(), new DefaultAzureCredential()); | ||
// Use Azure endpoint with /openai/v1 suffix |
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.
If this is documented on MS learn somewhere, could you please include a link in this comment?
Also wondering whether we should demostrate the same in the eval samples (in the dotnet/ai-samples repo). Out of curiosity, what is the motivation for removing the Azure.OpenAI reference?
modelVersion: "1"); | ||
#endif | ||
#if (UseAzureAISearch) | ||
#if (IsAzureAISearch) |
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.
Why the parens?
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.
Ah, is this some kind of metavariable that gets substituted during template expansion?
This PR removes all direct dependencies on the
Azure.AI.OpenAI
SDK package from project templates and test code, replacing them with the standardOpenAI
client library configured to work with Azure OpenAI endpoints.Background
Following the approach from PR #6861, this change eliminates the
Azure.AI.OpenAI
package dependency while preserving all Azure OpenAI functionality by using the standard OpenAI client with Azure-compatible endpoints.Changes
Test Projects
Integration test helpers now use
OpenAIClient
instead ofAzureOpenAIClient
/openai/v1
suffix to the base URLApiKeyCredential
formattest/Libraries/Microsoft.Extensions.AI.OpenAI.Tests/IntegrationTestHelpers.cs
test/Libraries/Microsoft.Extensions.AI.Evaluation.Integration.Tests/Setup.cs
Package references updated:
Azure.AI.OpenAI
from test project.csproj
filesAzure.Core
where needed for Azure authentication supportProject Templates
Template source code updated to use standard OpenAI client:
src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/ChatWithCustomData/ChatWithCustomData-CSharp.Web/Program.cs
AzureOpenAIClient
instantiation withOpenAIClient
configured for Azure endpointsTemplate snapshots updated:
Azure.AI.OpenAI
package references from snapshot test.csproj
filesTechnical Details
For Azure OpenAI scenarios, the implementation:
/openai/v1
to the base URLOpenAIClientOptions
to set the custom endpointApiKeyCredential
ApiKeyCredential
Example of the new pattern:
Notes
The
Aspire.Azure.AI.OpenAI
package reference remains in Aspire-enabled templates, as this is a higher-level integration package that abstracts the underlying client implementation.All affected projects build successfully with these changes.
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.
Microsoft Reviewers: Open in CodeFlow