Skip to content

OpenAI: Parse detail additional property - #6225

Merged
jozkee merged 6 commits into
mainfrom
openai-detail-property
Apr 2, 2025
Merged

OpenAI: Parse detail additional property#6225
jozkee merged 6 commits into
mainfrom
openai-detail-property

Conversation

@jozkee

@jozkeejozkee commented Apr 1, 2025

Copy link
Copy Markdown
Member

Fixes#6198

Microsoft Reviewers: Open in CodeFlow

@jozkee
jozkee requested a review from a team as a code ownerApril 1, 2025 20:13
@github-actionsgithub-actionsBot added the area-ai Microsoft.Extensions.AI libraries label Apr 1, 2025
Comment threadsrc/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIChatClient.cs Outdated

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

Copy link
Copy Markdown
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?

@jozkeejozkeeApr 2, 2025

Copy link
Copy Markdown
MemberAuthor

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:

varimageContent=newUriContent("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 mainApr 2, 2025
@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-actionsgithub-actionsBot locked and limited conversation to collaborators May 3, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-aiMicrosoft.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

@jozkee@stephentoub