-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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: Fix serialization of OpenAIChatMessageContent type #5301
Merged
SergeyMenshykh
merged 14 commits into
microsoft:main
from
SergeyMenshykh:serialization-fix
Mar 5, 2024
Merged
.Net: Fix serialization of OpenAIChatMessageContent type #5301
SergeyMenshykh
merged 14 commits into
microsoft:main
from
SergeyMenshykh:serialization-fix
Mar 5, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SergeyMenshykh
requested review from
stephentoub,
dmytrostruk,
RogerBarreto and
markwallace-microsoft
March 4, 2024 23:07
markwallace-microsoft
added
the
kernel
Issues or pull requests impacting the core kernel
label
Mar 4, 2024
markwallace-microsoft
approved these changes
Mar 5, 2024
…/semantic-kernel into serialization-fix
…/semantic-kernel into serialization-fix
dmytrostruk
approved these changes
Mar 5, 2024
dmytrostruk
approved these changes
Mar 5, 2024
github-merge-queue
bot
removed this pull request from the merge queue due to failed status checks
Mar 5, 2024
github-merge-queue
bot
removed this pull request from the merge queue due to failed status checks
Mar 5, 2024
github-merge-queue
bot
removed this pull request from the merge queue due to failed status checks
Mar 5, 2024
dmytrostruk
approved these changes
Mar 5, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation and Context
This PR fixes the #5264 issue that prevents auto calling of kernel functions created from prompt.
Description
ChatMessageContent
or its subtype and returns theChatMessageContent.Content
property value if that's the case. Otherwise, if the check was not provided, there would be an attempt to serialize the class and because theOpenAIChatMessageContent
is not and can't be registered for polymorphic serialization on the KernelContent class, the serialization would fail with the exception - "System.NotSupportedException: Runtime type 'Microsoft.SemanticKernel.Connectors.OpenAI.OpenAIChatMessageContent' is not supported by polymorphic type 'Microsoft.SemanticKernel.KernelContent'." Alternatively, instead of the type check above, the function result serializer could be configured with a custom JsonTypeInfoResolver to handle polymorphic serialization of theOpenAIChatMessageContent
class. However, in this case, all the public properties - ModelId, Metadata, Content, Items, Encoding, etc. of theOpenAIChatMessageContent
class would be unnecessarily serialized.ToolCallBehavior.FunctionResultSerializerOptions
to manage the serialization behavior of function execution results. It can be used to provide a JsonTypeInfoResolver for the polymorphic serialization of a custom subclass of theKernelContent
class.Contribution Checklist