Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
.Net: issue-10278 : Change ChatPromptParser to enable 0-n text part i…
…nstead of single value (#10304) ### Motivation and Context <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> See [Issue #10278](#10278 ) ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> **`ChatPromptParser.cs` :** Remove method `IsValidChildNodes` and its call in `IsValidChatMessage` : A chat message is valid as long as it has a role attribute. Messages with no text child or multiple text children are now valid **`ChatPromptParserTests` :** - Changed 3rd invalid example since the former one is now valid - Added tests for : Message with multiple text nodes, mixed XML content and empty XML node 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 the `ChatMessageContent` object will have only an `ImageContent` item **Other remark :** `ChatMessageContent.Content` property only returns/sets the first `TextContent` item. I thought about changing it to : - get : return a concatenation of the `TextContent` items separated by `\n` - set : set the first `TextContent` element (or add one if there is none) and remove other `TextContent` items But 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 <!-- Before submitting this PR, please make sure: --> - [x] The code builds clean without any errors or warnings - [x] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [ ] All unit tests pass, and I have added new tests where possible : I have the same test fails with the unmodified `main` branch. For instance the test `GettingStarted/Step1_Create_Kernel` fails with `ConfigurationNotFoundException : Configuration section 'OpenAI' not found`. I think there are some missing config files - [x] I didn't break anyone 😄 --------- Co-authored-by: Thomas DUQUENNOY <[email protected]> Co-authored-by: Mark Wallace <[email protected]> Co-authored-by: Dmytro Struk <[email protected]>
- Loading branch information