Creates a guardrail that detects personally identifiable information in input text and either blocks or warns.
Arguments
- detect
Character vector of PII types to look for. Default:
c("ssn", "email", "phone", "credit_card"). Seepii_patterns()for valid types.- action
Character(1). What to do when PII is found:
"block"(default) fails the check,"warn"passes with advisory warnings.
Examples
g <- guard_input_pii()
run_guardrail(g, "My SSN is 123-45-6789")
#> <guardrail_result> FAIL
#> Reason: PII detected in input: ssn (1)
run_guardrail(g, "Please help me with R code")
#> <guardrail_result> PASS