Repository navigation
Add AI support to the Microsoft.Testing.Platform
#6777
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
Merged
Marco Rossignoli (MarcoRossignoli)
merged 21 commits into
microsoft:main
from
MarcoRossignoli:dev/mr/addai2
Oct 28, 2025
Merged
Changes from 12 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
896004a
Add AI support to MTP
3ead977
Update TestFx.slnx
MarcoRossignoli 52922ee
Update TestFx.slnx
MarcoRossignoli aa40dad
Address PR feedback
9a0cc8e
Remove old AzFoundry directory
62473bb
Rename to IChatClientProvider
7e99cf9
Add IsShipping = false
a2ec275
Merge branch 'main' into dev/mr/addai2
MarcoRossignoli 30bfac1
Update visibility
4816d44
Refactor Azure OpenAI provider to use extension method and internal i…
6ce7fda
Add MSBuild registration mechanism for AzureFoundry extension
7135242
Fix TestingPlatformBuilderHook to use correct method name AddAzureOpe…
ac4f580
Merge branch 'main' into dev/mr/addai2
MarcoRossignoli 68be1df
Add IsAvailable property to IChatClientProvider interface
d16c442
Add RFC 001: AI-Powered Extensibility for Testing Platform
aa12146
Do not fail playground
8a4116a
Fix Playground
bfcdbf2
Merge branch 'main' into dev/mr/addai2
MarcoRossignoli 567f73c
Address PR feedback: refactor AI extensibility APIs
5fee4f9
Merge branch 'main' into dev/mr/addai2
MarcoRossignoli fb8d514
Rename methods for clarity
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
...icrosoft.Testing.Extensions.AzureFoundry/Microsoft.Testing.Extensions.AzureFoundry.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
Youssef1313 marked this conversation as resolved.
Resolved
|
||
|
|
||
| <PropertyGroup> | ||
| <TargetFrameworks>netstandard2.0;$(SupportedNetFrameworks)</TargetFrameworks> | ||
| <IsShipping>false</IsShipping> | ||
| </PropertyGroup> | ||
|
|
||
| <!-- NuGet package layout --> | ||
| <!-- NuGet folders https://learn.microsoft.com/nuget/create-packages/creating-a-package#from-a-convention-based-working-directory --> | ||
| <ItemGroup> | ||
| <Content Include="buildMultiTargeting/**"> | ||
|
MarcoRossignoli marked this conversation as resolved.
Resolved
|
||
| <Pack>true</Pack> | ||
| <PackagePath>buildMultiTargeting</PackagePath> | ||
| </Content> | ||
| <TfmSpecificPackageFile Include="buildTransitive/**"> | ||
| <PackagePath>buildTransitive/$(TargetFramework)</PackagePath> | ||
| </TfmSpecificPackageFile> | ||
| <TfmSpecificPackageFile Include="build/**"> | ||
| <PackagePath>build/$(TargetFramework)</PackagePath> | ||
| </TfmSpecificPackageFile> | ||
|
MarcoRossignoli marked this conversation as resolved.
Resolved
|
||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PackageReference Include="Azure.AI.OpenAI" /> | ||
| <PackageReference Include="Microsoft.Extensions.AI.OpenAI" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <ProjectReference Include="$(RepoRoot)src\Platform\Microsoft.Testing.Platform.AI\Microsoft.Testing.Platform.AI.csproj" /> | ||
| </ItemGroup> | ||
|
|
||
| </Project> | ||
66 changes: 66 additions & 0 deletions
66
src/Platform/Microsoft.Testing.Extensions.AzureFoundry/OpenAIChatClientProvider.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
|
||
| using System.ClientModel; | ||
|
|
||
| using Azure.AI.OpenAI; | ||
|
|
||
| using Microsoft.Extensions.AI; | ||
| using Microsoft.Testing.Extensions.AzureFoundry.Resources; | ||
| using Microsoft.Testing.Platform.AI; | ||
| using Microsoft.Testing.Platform.Helpers; | ||
| using Microsoft.Testing.Platform.Services; | ||
|
|
||
| namespace Microsoft.Testing.Extensions.AzureFoundry; | ||
|
|
||
| /// <summary> | ||
| /// Provider for creating Azure OpenAI chat clients. | ||
| /// </summary> | ||
| internal sealed class AzureOpenAIChatClientProvider : IChatClientProvider | ||
| { | ||
| private readonly IEnvironment _environment; | ||
|
|
||
| /// <summary> | ||
| /// Initializes a new instance of the <see cref="AzureOpenAIChatClientProvider"/> class. | ||
| /// </summary> | ||
| /// <param name="serviceProvider">The service provider.</param> | ||
| internal AzureOpenAIChatClientProvider(IServiceProvider serviceProvider) | ||
|
MarcoRossignoli marked this conversation as resolved.
Resolved
|
||
| { | ||
| _environment = serviceProvider.GetRequiredService<IEnvironment>(); | ||
| } | ||
|
|
||
| /// <inheritdoc /> | ||
| public bool SupportsToolCalling => true; | ||
|
|
||
| /// <inheritdoc /> | ||
| public string ModelName => _environment.GetEnvironmentVariable("AZURE_OPENAI_DEPLOYMENT_NAME") ?? "unknown"; | ||
|
|
||
| /// <inheritdoc /> | ||
| public Task<IChatClient> CreateChatClientAsync(CancellationToken cancellationToken) | ||
| { | ||
| string? endpoint = _environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT"); | ||
| string? deploymentName = _environment.GetEnvironmentVariable("AZURE_OPENAI_DEPLOYMENT_NAME"); | ||
| string? apiKey = _environment.GetEnvironmentVariable("AZURE_OPENAI_API_KEY"); | ||
|
|
||
| if (string.IsNullOrEmpty(endpoint)) | ||
| { | ||
| throw new InvalidOperationException(ExtensionResources.AzureOpenAIEndpointNotSet); | ||
| } | ||
|
|
||
| if (string.IsNullOrEmpty(deploymentName)) | ||
| { | ||
| throw new InvalidOperationException(ExtensionResources.AzureOpenAIDeploymentNameNotSet); | ||
| } | ||
|
|
||
| if (string.IsNullOrEmpty(apiKey)) | ||
| { | ||
| throw new InvalidOperationException(ExtensionResources.AzureOpenAIApiKeyNotSet); | ||
| } | ||
|
|
||
| var client = new AzureOpenAIClient( | ||
| new Uri(endpoint!), | ||
| new ApiKeyCredential(apiKey!)); | ||
|
|
||
| return Task.FromResult(client.GetChatClient(deploymentName).AsIChatClient()); | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.