From d706d3b6723dcd73cbf85d37a4858485ce130e69 Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Tue, 20 Feb 2024 16:01:15 -0800 Subject: [PATCH] fix(presidio_pii_masking.py): enable user to pass ad hoc recognizer for pii masking --- .../example_presidio_ad_hoc_recognizer.json | 28 +++++++++++++++++++ litellm/proxy/hooks/presidio_pii_masking.py | 4 ++- 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 litellm/proxy/hooks/example_presidio_ad_hoc_recognizer.json diff --git a/litellm/proxy/hooks/example_presidio_ad_hoc_recognizer.json b/litellm/proxy/hooks/example_presidio_ad_hoc_recognizer.json new file mode 100644 index 0000000000..6a94d8de12 --- /dev/null +++ b/litellm/proxy/hooks/example_presidio_ad_hoc_recognizer.json @@ -0,0 +1,28 @@ +[ + { + "name": "Zip code Recognizer", + "supported_language": "en", + "patterns": [ + { + "name": "zip code (weak)", + "regex": "(\\b\\d{5}(?:\\-\\d{4})?\\b)", + "score": 0.01 + } + ], + "context": ["zip", "code"], + "supported_entity": "ZIP" + }, + { + "name": "Swiss AHV Number Recognizer", + "supported_language": "en", + "patterns": [ + { + "name": "AHV number (strong)", + "regex": "(756\\.\\d{4}\\.\\d{4}\\.\\d{2})|(756\\d{10})", + "score": 0.95 + } + ], + "context": ["AHV", "social security", "Swiss"], + "supported_entity": "AHV_NUMBER" + } +] \ No newline at end of file diff --git a/litellm/proxy/hooks/presidio_pii_masking.py b/litellm/proxy/hooks/presidio_pii_masking.py index 99e501589f..86c88975e0 100644 --- a/litellm/proxy/hooks/presidio_pii_masking.py +++ b/litellm/proxy/hooks/presidio_pii_masking.py @@ -235,7 +235,9 @@ class _OPTIONAL_PresidioPIIMasking(CustomLogger): messages[index][ "content" ] = r # replace content with redacted string - verbose_proxy_logger.debug(f"Redacted pii message: {data['messages']}") + verbose_proxy_logger.info( + f"Presidio PII Masking: Redacted pii message: {data['messages']}" + ) return data except Exception as e: verbose_proxy_logger.info(f"An error occurred - {str(e)}")