Files
semantic-kernel/python/semantic_kernel/functions
Eduard van Valkenburg 75089cb711 Python: Enhance Chat Message Content creation and parsing (#5520)
### 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.
-->
Introduces a polymorphic approach to creating and rendering Chat Message
Contents and it's subclasses, leverages Pydantic Rootmodel for that.

Fixes #5496 

### Description

<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->
Adds ChatMessageContentBase that can create all types of CMC's, based on
a type field (str)
Redoes some of the rendering and parsing
also retooled the hierarchy structure for Contents, including
introducing a StreamingContentMixin instead of the
StreamingKernelContent (which was never used), now all content classes
(TextContent, CMC, etc) determine the fields used, while the Mixin adds
one additional field and two additional methods for streaming messages,
especially __add__
everything else runs the same way.

### 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
- [x] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone 😄
2024-03-28 12:45:56 +00:00
..