-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
.Net: Add Support for 'dall-e-3' Model in OpenAIImageGeneration Class (…
…#6623) ### Motivation and Context Closes #3435 <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [ ] The code builds clean without any errors or warnings - [ ] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [ ] All unit tests pass, and I have added new tests where possible - [ ] I didn't break anyone 😄 Co-authored-by: SergeyMenshykh <68852919+SergeyMenshykh@users.noreply.github.com>
- Loading branch information
1 parent
3c5e053
commit ddf1d46
Showing
10 changed files
with
174 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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
85 changes: 85 additions & 0 deletions
85
dotnet/src/IntegrationTests/Connectors/OpenAI/OpenAITextToImageTests.cs
This file contains 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,85 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
|
||
using System.Threading.Tasks; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.SemanticKernel; | ||
using Microsoft.SemanticKernel.TextToImage; | ||
using SemanticKernel.IntegrationTests.TestSettings; | ||
using Xunit; | ||
|
||
namespace SemanticKernel.IntegrationTests.Connectors.OpenAI; | ||
public sealed class OpenAITextToImageTests | ||
{ | ||
private readonly IConfigurationRoot _configuration = new ConfigurationBuilder() | ||
.AddJsonFile(path: "testsettings.json", optional: false, reloadOnChange: true) | ||
.AddJsonFile(path: "testsettings.development.json", optional: true, reloadOnChange: true) | ||
.AddEnvironmentVariables() | ||
.AddUserSecrets<OpenAITextToAudioTests>() | ||
.Build(); | ||
|
||
[Fact(Skip = "This test is for manual verification.")] | ||
public async Task OpenAITextToImageTestAsync() | ||
{ | ||
// Arrange | ||
OpenAIConfiguration? openAIConfiguration = this._configuration.GetSection("OpenAITextToImage").Get<OpenAIConfiguration>(); | ||
Assert.NotNull(openAIConfiguration); | ||
|
||
var kernel = Kernel.CreateBuilder() | ||
.AddOpenAITextToImage(apiKey: openAIConfiguration.ApiKey) | ||
.Build(); | ||
|
||
var service = kernel.GetRequiredService<ITextToImageService>(); | ||
|
||
// Act | ||
var result = await service.GenerateImageAsync("The sun rises in the east and sets in the west.", 512, 512); | ||
|
||
// Assert | ||
Assert.NotNull(result); | ||
Assert.NotEmpty(result); | ||
} | ||
|
||
[Fact(Skip = "This test is for manual verification.")] | ||
public async Task OpenAITextToImageByModelTestAsync() | ||
{ | ||
// Arrange | ||
OpenAIConfiguration? openAIConfiguration = this._configuration.GetSection("OpenAITextToImage").Get<OpenAIConfiguration>(); | ||
Assert.NotNull(openAIConfiguration); | ||
|
||
var kernel = Kernel.CreateBuilder() | ||
.AddOpenAITextToImage(apiKey: openAIConfiguration.ApiKey, modelId: openAIConfiguration.ModelId) | ||
.Build(); | ||
|
||
var service = kernel.GetRequiredService<ITextToImageService>(); | ||
|
||
// Act | ||
var result = await service.GenerateImageAsync("The sun rises in the east and sets in the west.", 1024, 1024); | ||
|
||
// Assert | ||
Assert.NotNull(result); | ||
Assert.NotEmpty(result); | ||
} | ||
|
||
[Fact(Skip = "This test is for manual verification.")] | ||
public async Task AzureOpenAITextToImageTestAsync() | ||
{ | ||
// Arrange | ||
AzureOpenAIConfiguration? azureOpenAIConfiguration = this._configuration.GetSection("AzureOpenAITextToImage").Get<AzureOpenAIConfiguration>(); | ||
Assert.NotNull(azureOpenAIConfiguration); | ||
|
||
var kernel = Kernel.CreateBuilder() | ||
.AddAzureOpenAITextToImage( | ||
azureOpenAIConfiguration.DeploymentName, | ||
azureOpenAIConfiguration.Endpoint, | ||
azureOpenAIConfiguration.ApiKey) | ||
.Build(); | ||
|
||
var service = kernel.GetRequiredService<ITextToImageService>(); | ||
|
||
// Act | ||
var result = await service.GenerateImageAsync("The sun rises in the east and sets in the west.", 1024, 1024); | ||
|
||
// Assert | ||
Assert.NotNull(result); | ||
Assert.NotEmpty(result); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
dotnet/src/IntegrationTests/CrossLanguage/PromptWithComplexObjectsTest.cs
This file contains 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
2 changes: 1 addition & 1 deletion
2
dotnet/src/IntegrationTests/CrossLanguage/PromptWithHelperFunctionsTest.cs
This file contains 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 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