.Net: issue-10278 : Change ChatPromptParser to enable 0-n text part instead of single value #10304
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
See Issue #10278
Description
ChatPromptParser.cs
:Remove method
IsValidChildNodes
and its call inIsValidChatMessage
: A chat message is valid as long as it has a role attribute. Messages with no text child or multiple text children are now validChatPromptParserTests
:Remark : The expected behavior for mixed XML content is unclear so I kept it as it was : the content of the message node ends up in a
TextContent
if and only if the message has no valid text or image child node.So for instance, if the prompt has a message that is a mixed XML with content and a child
image
node, the content would be ignored and theChatMessageContent
object will have only anImageContent
itemOther remark :
ChatMessageContent.Content
property only returns/sets the firstTextContent
item.I thought about changing it to :
TextContent
items separated by\n
TextContent
element (or add one if there is none) and remove otherTextContent
itemsBut its current behavior seems intended (it is even included in some unit tests) and I felt like such a change would have too much impact across the code. So I left it as it is. But I think that such a change could be beneficial.
Contribution Checklist
I have the same test fails with the unmodified
main
branch. For instance the testGettingStarted/Step1_Create_Kernel
fails withConfigurationNotFoundException : Configuration section 'OpenAI' not found
. I think there are some missing config files