Skip to content

Conversation

jozkee
Copy link
Member

@jozkee jozkee commented Apr 1, 2025

Fixes #6198

Microsoft Reviewers: Open in CodeFlow

@jozkee jozkee requested a review from a team as a code owner April 1, 2025 20:13
@github-actions github-actions bot added the area-ai Microsoft.Extensions.AI libraries label Apr 1, 2025

private static ChatImageDetailLevel? GetImageDetail(AIContent content)
{
if (content.AdditionalProperties?.TryGetValue("detail", out string? value) == true)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible someone might try putting a ChatImageDetailLevel into the properties?

Copy link
Member Author

@jozkee jozkee Apr 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It definitely is possible since AdditionalProperties' TValue is object? and we would be ignoring it.
This is what it would look like:

var imageContent = new UriContent("http://localhost/my-image.png", "image/png")
{
    AdditionalProperties = new() 
    { 
        { "detail", OpenAI.Chat.ChatImageDetailLevel.High } 
    }
};

We could match ChatImageDetailLevel as well.

@jozkee jozkee merged commit 5d99c3f into main Apr 2, 2025
6 checks passed
@jozkee jozkee deleted the openai-detail-property branch April 2, 2025 18:16
joperezr pushed a commit to joperezr/extensions that referenced this pull request Apr 8, 2025
* OpenAI: Parse detail additional property

* Update tests to use AsIChatClient

* Don't throw when type is not string

* Match OpenAI.Chat.ChatImageDetailLevel
@github-actions github-actions bot locked and limited conversation to collaborators May 3, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-ai Microsoft.Extensions.AI libraries
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[API Proposal]: [MEAI] Add possibility to set image detail level for OpenAI.
2 participants