-
Notifications
You must be signed in to change notification settings - Fork 829
OpenAI: Parse detail additional property #6225
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
Conversation
src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIChatClient.cs
Outdated
Show resolved
Hide resolved
test/Libraries/Microsoft.Extensions.AI.OpenAI.Tests/Microsoft.Extensions.AI.OpenAI.Tests.csproj
Show resolved
Hide resolved
test/Libraries/Microsoft.Extensions.AI.OpenAI.Tests/OpenAIChatClientTests.cs
Outdated
Show resolved
Hide resolved
|
||
private static ChatImageDetailLevel? GetImageDetail(AIContent content) | ||
{ | ||
if (content.AdditionalProperties?.TryGetValue("detail", out string? value) == true) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
* OpenAI: Parse detail additional property * Update tests to use AsIChatClient * Don't throw when type is not string * Match OpenAI.Chat.ChatImageDetailLevel
Fixes #6198
Microsoft Reviewers: Open in CodeFlow