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: Allow custom serialization options to be passed to TextMemoryPlugin. #7098

Merged
merged 2 commits into from
Jul 4, 2024

Conversation

westey-m
Copy link
Contributor

@westey-m westey-m commented Jul 4, 2024

Motivation and Context

When TextMemoryPlugin gets back multiple results from the memory store during recall, it uses json serialization to
turn these multiple results into a single string.
In some cases, this may cause unintended side-affects, e.g. when non-latin script is present in the results, JsonSerializer automatically escapes these characters.
Adding support for passing custom JsonSerializerOptions into the TextMemoryPlugin to customize the serialization behavior.

See #6593

Description

Added optional JsonSerializerOptions to the TextMemoryPlugin constructor.
Added example to demonstrate this scenario.

Contribution Checklist

…o allow non-latin script to be serialized without escaping.
@westey-m westey-m requested a review from a team as a code owner July 4, 2024 13:59
@markwallace-microsoft markwallace-microsoft added .NET Issue or Pull requests regarding .NET code documentation labels Jul 4, 2024
@github-actions github-actions bot changed the title Allow custom serialization options to be passed to TextMemoryPlugin. .Net: Allow custom serialization options to be passed to TextMemoryPlugin. Jul 4, 2024
@westey-m westey-m added this pull request to the merge queue Jul 4, 2024
Merged via the queue into microsoft:main with commit c8fa30b Jul 4, 2024
15 checks passed
@westey-m westey-m deleted the text-memory-plugin-encoding-fix branch July 4, 2024 15:37
LudoCorporateShark pushed a commit to LudoCorporateShark/semantic-kernel that referenced this pull request Aug 25, 2024
…ugin. (microsoft#7098)

### Motivation and Context

When `TextMemoryPlugin` gets back multiple results from the memory store
during recall, it uses json serialization to
turn these multiple results into a single string.
In some cases, this may cause unintended side-affects, e.g. when
non-latin script is present in the results, `JsonSerializer`
automatically escapes these characters.
Adding support for passing custom `JsonSerializerOptions` into the
`TextMemoryPlugin` to customize the serialization behavior.

See microsoft#6593

### Description

Added optional `JsonSerializerOptions` to the `TextMemoryPlugin`
constructor.
Added example to demonstrate this scenario.

### 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 😄
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation .NET Issue or Pull requests regarding .NET code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants