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.
This is a draft of what the public API would look like.
Based on this prototype, my current assessment is that this change does not add a lot of value, and therefore, my current inclination is to not go ahead with it. Let me know what you think.
Summary:
We add a new class that looks like this:
We use it to replace:
ChatCompletion
'sIReadOnlyList<ChatMessageContentPart> Content
property.ChatMessage
'sIList<ChatMessageContentPart> Content
property.Q: How does this affect the code that customers write?
A: I believe it doesn't change much.
🟢 Example 1: Creating a
ChatMessage
To create a
ChatMessage
, it is still more convenient to use the constructors that take a plainstring
or anIEnumerable<ChatMessageContentPart>
than to have to instantiate a newChatMessageContent
using the same plainstring
or anIEnumerable<ChatMessageContentPart>
.🟢 Example 2: Reading the multimodal content of a
ChatMessage
For example, to render the multimodal contents of a
ChatMessage
in some UI, users need to iterate through theParts
of theChatMessageContent
. In other words, the following:foreach (ChatMessageContentPart part in message.Content) { ... }
Becomes:
foreach (ChatMessageContentPart part in message.Content.Parts) { ... }
While relatively trivial, this still looks like a minor regression in usability. We could mitigate it by making
ChatMessageContent
inherit fromCollection<ChatMessageContentPart>
instead of having aParts
property, but all this does is keep the experience the same (not any worse, not any better).