[#131] DynamoDbChatStorage option to replace sensitive content by placeholder #326
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.
Title:
Add support for replacing sensitive content in
DynamoDbChatStorage
[Issue #131] @brnaba-awsDescription:
Overview:
This PR introduces the ability to replace sensitive content in chat messages when using the
DynamoDbChatStorage
class. This is useful for ensuring that sensitive information (e.g., secret data, personal information) is masked before it is stored or retrieved from DynamoDB.Changes:
sensitive_mappings
parameter to theDynamoDbChatStorage
class, which contains a dictionary of words/phrases to be masked and their replacements._anonymized_content
method to handle the masking and unmasking of sensitive content in both directions (save and fetch).How It Works:
save_chat_messages()
, the content is processed through the_anonymized_content
method, where sensitive words (defined insensitive_mappings
) are replaced with asterisks (e.g.,"secret"
becomes"******"
).fetch_chat()
, the same_anonymized_content
method is used with thereverse=True
flag to unmask previously masked content for retrieval.Test Changes:
Why This Is Useful:
Testing:
"secret"
and"classified"
. These words are masked (e.g.,secret
→******
) when saved and unmasked when retrieved.How to Test:
DynamoDbChatStorage
class for thesensitive_mappings
parameter.