-
Notifications
You must be signed in to change notification settings - Fork 3.9k
.Net: Support BinaryContent in OpenAI Connector #11644
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: Support BinaryContent in OpenAI Connector #11644
Conversation
Hi @nkeenan38 Thanks for the contribution, Please add one Integration Test and a Sample ensuring it works as expected and the file content is passed down to the API. Concept Samples - Similar to thisIntegration Tests - Similar to this:Line 166 in 9c9aec0
|
@microsoft-github-policy-service agree |
153a362
to
f0a5119
Compare
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.
LGTM, just need some extra tests
dotnet/src/Connectors/Connectors.OpenAI/Core/ClientCore.ChatCompletion.cs
Show resolved
Hide resolved
fb69f2b
to
7895d54
Compare
7895d54
to
5cad4b3
Compare
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.
@nkeenan38 Thanks for addressing all feedback and putting forward this PR.
All looks good to me.
…nto openai-connector-binary-content
…nkeenan38/semantic-kernel into openai-connector-binary-content
The OpenAI Connector only supports `TextContent`, `ImageContent`, and `AudioContent` KernelContent types. However, the Chat Completion API supports uploading other file types encoded as a base64 string. This change leverages that behavior to add support for `BinaryContent`. This change adds support for `BinaryContent` KernelContent types by using `ChatMessageContentPart.CreateFilePart` to create the corresponding `ChatMessageContentPart`. - [x] The code builds clean without any errors or warnings - [x] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [x] All unit tests pass, and I have added new tests where possible - [x] I didn't break anyone 😄 --------- Co-authored-by: Roger Barreto <19890735+RogerBarreto@users.noreply.github.com>
Motivation and Context
The OpenAI Connector only supports
TextContent
,ImageContent
, andAudioContent
KernelContent types. However, the Chat Completion API supports uploading other file types encoded as a base64 string. This change leverages that behavior to add support forBinaryContent
.Description
This change adds support for
BinaryContent
KernelContent types by usingChatMessageContentPart.CreateFilePart
to create the correspondingChatMessageContentPart
.Contribution Checklist