Skip to content

The agent engineering platform.

Reset deanonymizer mapping (#11559)

maks-operlejn-dsf64522fbafe9
diff --git a/libs/experimental/langchain_experimental/data_anonymizer/base.py b/libs/experimental/langchain_experimental/data_anonymizer/base.py
index 6cca949c0d..6092ec8fb7 100644
--- a/libs/experimental/langchain_experimental/data_anonymizer/base.py
+++ b/libs/experimental/langchain_experimental/data_anonymizer/base.py
@@ -47,3 +47,7 @@ class ReversibleAnonymizerBase(AnonymizerBase):
deanonymizer_matching_strategy: Callable[[str, MappingDataType], str],
) -> str:
"""Abstract method to deanonymize text"""
+
+ @abstractmethod
+ def reset_deanonymizer_mapping(self) -> None:
+ """Abstract method to reset deanonymizer mapping"""
diff --git a/libs/experimental/langchain_experimental/data_anonymizer/presidio.py b/libs/experimental/langchain_experimental/data_anonymizer/presidio.py
index 0b4012cdb7..b10841b4d8 100644
--- a/libs/experimental/langchain_experimental/data_anonymizer/presidio.py
+++ b/libs/experimental/langchain_experimental/data_anonymizer/presidio.py
@@ -313,6 +313,10 @@ class PresidioReversibleAnonymizer(PresidioAnonymizerBase, ReversibleAnonymizerB
return text_to_deanonymize
+ def reset_deanonymizer_mapping(self) -> None:
+ """Reset the deanonymizer mapping"""
+ self._deanonymizer_mapping = DeanonymizerMapping()
+
def save_deanonymizer_mapping(self, file_path: Union[Path, str]) -> None:
"""Save the deanonymizer mapping to a JSON or YAML file.