Skip to content
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: Align the behavior of the ChatMessageContent.Content property setter with streaming counterpart #6753

Merged

Conversation

SergeyMenshykh
Copy link
Member

Motivation and Context

This is a follow-up fix for the ChatMessageContent.Content property setter, similar to the one that was done to the StreamingChatMessageContent.Content property when addressing the PR comment: #6449 (comment).

Description

This change updates the text of the first text item regardless of the value being set. This helps avoid inconsistency that occurs when text content already exists in the items collection, null is set via the Content property, and the setter does nothing, while the getter returns the text message content:

var items = new ChatMessageContentItemCollection
{
    new TextContent("Hi AI."),
};

var chatMessage = new ChatMessageContent(AuthorRole.User, items: items);
chatMessage.Content = null; // The property setter does nothing if the value is null.

// Fails
Assert.Null(chatMessage.Content); // The property getter returns the "Hi AI." text.

…tter with the behavior of the StreamingChatMessageContent.Content one.
@SergeyMenshykh SergeyMenshykh added the .NET Issue or Pull requests regarding .NET code label Jun 17, 2024
@SergeyMenshykh SergeyMenshykh self-assigned this Jun 17, 2024
@SergeyMenshykh SergeyMenshykh requested a review from a team as a code owner June 17, 2024 19:31
@markwallace-microsoft markwallace-microsoft added kernel Issues or pull requests impacting the core kernel kernel.core labels Jun 17, 2024
@SergeyMenshykh SergeyMenshykh added this pull request to the merge queue Jun 19, 2024
Merged via the queue into microsoft:main with commit 95e4c42 Jun 19, 2024
18 checks passed
@SergeyMenshykh SergeyMenshykh deleted the align-content-property-behavior branch June 19, 2024 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kernel.core kernel Issues or pull requests impacting the core kernel .NET Issue or Pull requests regarding .NET code
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

4 participants