-
Notifications
You must be signed in to change notification settings - Fork 759
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
Add OpenAI serialization helper methods. #5697
base: main
Are you sure you want to change the base?
Conversation
/// <param name="options">The <see cref="JsonSerializerOptions"/> governing deserialization of function call content.</param> | ||
/// <param name="cancellationToken">A token used to cancel the operation.</param> | ||
/// <returns>The deserialized list of chat messages and chat options.</returns> | ||
public static async Task<(IList<ChatMessage> Messages, ChatOptions? Options)> DeserializeFromOpenAIAsync( |
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 this about deserializing a request, deserializing a non-streaming response, or deserializing a streaming response? Presumably a request, but we'll want it to be clear in the naming.
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's for deserializing requests. API names are largely placeholders, will refine.
options ??= AIJsonUtilities.DefaultOptions; | ||
|
||
OpenAI.Chat.ChatCompletion openAiChatCompletion = OpenAIModelMappers.ToOpenAIChatCompletion(chatCompletion); | ||
BinaryData binaryData = JsonModelHelpers.Serialize(openAiChatCompletion); |
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.
We can't serialize directly to the stream?
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.
The OpenAI models use the IJsonModel<T>
pattern which doesn't support async streaming serialization.
ac2a89f
to
0041b35
Compare
🎉 Good job! The coverage increased 🎉
Full code coverage report: https://dev.azure.com/dnceng-public/public/_build/results?buildId=881220&view=codecoverage-tab |
0041b35
to
2d25f31
Compare
🎉 Good job! The coverage increased 🎉
Full code coverage report: https://dev.azure.com/dnceng-public/public/_build/results?buildId=881767&view=codecoverage-tab |
2d25f31
to
1c49616
Compare
1c49616
to
21a45ce
Compare
🎉 Good job! The coverage increased 🎉
Full code coverage report: https://dev.azure.com/dnceng-public/public/_build/results?buildId=886081&view=codecoverage-tab |
Very early draft implementation of helper methods for serializing M.E.AI.Abstractions using the OpenAI wire format. Contains three separate commits that should be reviewed separately:
Microsoft Reviewers: Open in CodeFlow