Skip to content
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

.Net: Add support for image quality, style, and detail level #7086

Open
SergeyMenshykh opened this issue Jul 3, 2024 · 7 comments · May be fixed by #8068
Open

.Net: Add support for image quality, style, and detail level #7086

SergeyMenshykh opened this issue Jul 3, 2024 · 7 comments · May be fixed by #8068
Assignees
Labels
Ignite needs discussion Issues that require discussion by the internal Semantic Kernel team before proceeding .NET Issue or Pull requests regarding .NET code openai_sdk_v2 Related to the OpenAI V2 SDK upgrade sk team issue A tag to denote issues that where created by the Semantic Kernel team (i.e., not the community)

Comments

@SergeyMenshykh
Copy link
Member

SergeyMenshykh commented Jul 3, 2024

Context:

  • Text to image {Azure}OpenAI connectors:
    AzureOpenAI SDK v2 allows the specification of image style (Vivid & Natural) and image quality (High & Standard) when generating an image from text.:
    internal async Task<string> GenerateImageAsync(
        string prompt,
        int width,
        int height,
        CancellationToken cancellationToken)
    {
        ...
    
        var imageOptions = new ImageGenerationOptions()
        {
            Size = size,
            ResponseFormat = GeneratedImageFormat.Uri,
            Quality = GeneratedImageQuality.High, // It's not supported by SK yet.
            Style = GeneratedImageStyle.Vivid, // It's not supported by SK yet.
        };
    
        ...
    }
  • Chat completion {Azure}OpenAI connectors:
    AzureOpenAI SDK v2 allows the specification of image detail level (Low, High, and Auto) when sending an image to the model:
    private static ChatMessageContentPart GetImageContentItem(ImageContent imageContent)
    {
       ...
       return ChatMessageContentPart.CreateImageMessageContentPart(
             BinaryData.FromBytes(data),
             imageContent.MimeType,
             ImageChatMessageContentPartDetail.Auto); // It's not supported by SK yet.
    
       ...
    }

ToDo:
Consider extending the SK public API surface to support the options mentioned above.

Notes
Decide whether the support should be shipped as part of the Azure OpenAI v2 migration initiative or afterward.

@markwallace-microsoft markwallace-microsoft added .NET Issue or Pull requests regarding .NET code triage needs discussion Issues that require discussion by the internal Semantic Kernel team before proceeding and removed triage labels Jul 3, 2024
@AdriaanLarcai
Copy link

Yes, please prioritize this. This is something we need for our projects. Specifically for chat completion.

@markwallace-microsoft markwallace-microsoft added the openai_sdk_v2 Related to the OpenAI V2 SDK upgrade label Jul 16, 2024
@aghimir3
Copy link

Hello,

I was going to use quality and style for my hobby project. Then I thought maybe I could contribute.

I have a draft PR up into 'feature-connectors-openai' and it would be great to know if I am moving in the right direction: #8064

Thank you for your time!

@RogerBarreto
Copy link
Member

@aghimir3 You approach is good but actually the ideal is to update our ITextToImage abstractions to accept a ExecutionSettings which can contain all those special details when requesting for a ImageGeneration.

I'm currently working on this PR to resolve this issue as part of it.

@aghimir3
Copy link

Thank you for the response!

I noticed that the GetImageContentsAsync method in OpenAITextToImageService.cs hasn't been implemented yet. I'd be thrilled to contribute to it if you're open to that!
Or, if you could guide me to any other .NET tasks related to OpenAI that need attention, I'd be more than happy to help out.

@aghimir3
Copy link

@RogerBarreto
Copy link
Member

RogerBarreto commented Aug 13, 2024

This changes are not part of the OpenAI V2 feature they introduce a new Abstraction update for all connectors.

As the feature-connectors-openai is the newer version, this PR brings the abstraction implementation to the current main code base for this PR, consider using the V1 version

And as soon the feature branch merges to main, we update the code to the new pattern.

@aghimir3
Copy link

Hi @RogerBarreto ,

Thanks for merging my changes into #8068 .

Since the OpenAI V2 version is still missing support for quality and style, can I branch off of feature-connectors-openai and work on it?

Thank you for your time!

@evchaki evchaki added the sk team issue A tag to denote issues that where created by the Semantic Kernel team (i.e., not the community) label Aug 28, 2024
@RogerBarreto RogerBarreto self-assigned this Aug 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ignite needs discussion Issues that require discussion by the internal Semantic Kernel team before proceeding .NET Issue or Pull requests regarding .NET code openai_sdk_v2 Related to the OpenAI V2 SDK upgrade sk team issue A tag to denote issues that where created by the Semantic Kernel team (i.e., not the community)
Projects
Status: Sprint: In Review
6 participants