Basic Usage
To provide your Agent with the PII Detection Guardrail, you need to import it and pass it to the Agent using thepre_hooks
parameter:
PII fields
The default list of PII fields handled by the guardrail are:- Social Security Numbers (SSNs)
- Credit Card Numbers
- Email Addresses
- Phone Numbers
Custom PII fields
You can also extend the list of PII fields handled by the guardrail by adding your own own custom PII patterns. For example, we can add a custom PII pattern for bank account numbers:custom_patterns
parameter will extend, not override, the default list of PII fields. You can stop checking for default PII fields by setting the enable_ssn_check
, enable_credit_card_check
, enable_email_check
, and enable_phone_check
parameters to False
.
Masking PII
By default, the PII Detection Guardrail will raise an error if it detects any PII in the input. However, you can mask the PII in the input instead of raising, by setting themask_pii
parameter to True
:
joe@example.com
, will be masked as **************
.