mirror of
https://github.com/tiennm99/litellm.git
synced 2026-08-06 04:23:40 +00:00
fix(presidio_pii_masking.py): enable user to pass ad hoc recognizer for pii masking
This commit is contained in:
@@ -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"
|
||||
}
|
||||
]
|
||||
@@ -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)}")
|
||||
|
||||
Reference in New Issue
Block a user