Repository navigation
.Net: Feature gpt image 1 support - #12866
Ramin Ahmadi (AhmadiRamin) wants to merge 3 commits into
Conversation
|
What's next in the merging process? Are we waiting for microsoft/octo-semantickernel-pr-dotnet to review the code? |
| /// <param name="cancellationToken">Cancellation token</param> | ||
| /// <returns>Generated image contents</returns> | ||
| [Experimental("SKEXP0001")] | ||
| Task<IReadOnlyList<ImageContent>> GenerateEditImageAsync( |
There was a problem hiding this comment.
Thanks for the contribution.
Recently we have new Text-to-Image abstractions available in Microsoft.Extensions.AI including openai implementations available for editing images as well.
Due to that we will be moving away from our experimental abstractions for Text-to-Image in favor of the new experimental M.E.AI abstractions using the IImageGenerator interface.
Suggest updating this PR to move our existing OpenAITextToImageService internal implementations using the new OpenAIImageGenerator, without our specific logic.
package: Microsoft.Extensions.AI.OpenAI
using Microsoft.Extensions.AI;
var imageGenerator = azureOpenAiClient.GetImage().AsIImageGenerator();There was a problem hiding this comment.
Thanks Roger Barreto (@rogerbarreto) for your comments, I will update the PR as you suggested.
There was a problem hiding this comment.
Hi Roger Barreto (@rogerbarreto), I've updated the PR, please let me know if you want to update anything else.
There was a problem hiding this comment.
Roger Barreto (@rogerbarreto) Have you had a chance to review this?
26d9f71 to
0b8aab5
Compare
Keep existing SK image contracts while using MEAI for generation. Support native generation and editing registrations with telemetry. Refs microsoft#12866
There was a problem hiding this comment.
🔵 Needs a closer look
Runtime compatibility of the shared legacy image path with the experimental adapters across both providers remains unverified.
No open issues 🎉
What changed in this PR
Adds OpenAI and Azure OpenAI image generation through Microsoft.Extensions.AI, using Semantic Kernel’s existing registration patterns while adapting its legacy text-to-image services.
Changes:
- Adds
IImageGeneratorregistrations with telemetry and logging support. - Routes legacy image generation through the new abstraction and supports data URI results.
- Adds tests for registration, generation, editing, settings preservation, and error handling.
| File | Description |
|---|---|
dotnet/src/SemanticKernel.Abstractions/AI/TextToImage/TextToImageServiceExtensions.cs |
Returns image URLs or data URIs. |
dotnet/src/Connectors/Connectors.OpenAI/Services/OpenAITextToImageService.cs |
Documents delegation and the new registration API. |
dotnet/src/Connectors/Connectors.OpenAI/Extensions/OpenAIServiceCollectionExtensions.DependencyInjection.cs |
Adds OpenAI image-generator service registrations. |
dotnet/src/Connectors/Connectors.OpenAI/Extensions/OpenAIKernelBuilderExtensions.cs |
Adds OpenAI kernel-builder registration overloads. |
dotnet/src/Connectors/Connectors.OpenAI/Core/ClientCore.TextToImage.cs |
Adapts legacy requests and responses through IImageGenerator. |
dotnet/src/Connectors/Connectors.OpenAI.UnitTests/Services/OpenAITextToImageServiceTests.cs |
Tests data URIs, settings, errors, and cancellation. |
dotnet/src/Connectors/Connectors.OpenAI.UnitTests/Extensions/ServiceCollectionExtensionsTests.cs |
Tests registration, telemetry, generation, and editing. |
dotnet/src/Connectors/Connectors.OpenAI.UnitTests/Extensions/KernelBuilderExtensionsTests.cs |
Tests kernel-builder image-generator registration. |
dotnet/src/Connectors/Connectors.AzureOpenAI/Services/AzureOpenAITextToImageService.cs |
Documents delegation and the new registration API. |
dotnet/src/Connectors/Connectors.AzureOpenAI/Extensions/AzureOpenAIServiceCollectionExtensions.DependencyInjection.cs |
Adds Azure image-generator service registrations. |
dotnet/src/Connectors/Connectors.AzureOpenAI/Extensions/AzureOpenAIKernelBuilderExtensions.cs |
Adds Azure kernel-builder registration overloads. |
dotnet/src/Connectors/Connectors.AzureOpenAI.UnitTests/Services/AzureOpenAITextToImageServiceTests.cs |
Tests data URIs and preservation of Azure request settings. |
dotnet/src/Connectors/Connectors.AzureOpenAI.UnitTests/Extensions/AzureOpenAIServiceCollectionExtensionsTests.cs |
Tests registration, authentication, telemetry, and editing. |
dotnet/src/Connectors/Connectors.AzureOpenAI.UnitTests/Extensions/AzureOpenAIKernelBuilderExtensionsTests.cs |
Tests Azure kernel-builder image-generator registration. |
Review effort: Balanced
Summary
This PR adds support for Azure OpenAI and OpenAI image generation models using the new Microsoft.Extensions.AI abstractions, enabling developers to use gpt-image-1, DALL-E 3, and other image models through Semantic Kernel's familiar registration patterns.
Motivation and Context
Changes
Added Microsoft.Extensions.AI Integration
Multi-Modal Support
Usage Examples
Basic Setup
Multi-Modal Application
Usage Example
Contribution Checklist