Skip to main content

What is PII Policy?

PII policies detect and protect personal identifiable information including emails, phone numbers, SSN, addresses, credit cards, driver’s licenses, passports, IP addresses, and other sensitive personal data.

Why its Important?

PII policies are critical for protecting personal identifiable information and ensuring compliance with privacy regulations. These policies prevent sensitive personal data from being sent to LLMs, which helps maintain user privacy, prevent identity theft, and comply with data protection laws.
  • Prevents sending PII to LLM: Blocks emails, addresses, SSN, and other personal data from being processed by language models
  • Protects against identity theft: Prevents sensitive personal information from being exposed or used maliciously
  • Ensures privacy compliance: Helps maintain compliance with GDPR, CCPA, and other data protection regulations

Usage

from upsonic import Agent, Task
from upsonic.safety_engine.policies import PIIAnonymizePolicy

# Automatically hide sensitive info in output only
agent = Agent(
    model="openai/gpt-4o",
    user_policy=PIIAnonymizePolicy,
    debug=True
)

task = Task("My email is [email protected] and phone is 555-0123. Tell me what is my e mail and phone number.")
result = agent.do(task)
print(result)
# Policy will anonymize the email and phone number

# Example output: I'm sorry, but I can't store or recall personal information like emails 
# or phone numbers. If you need them, you might want to check your personal records 
# or devices where they are stored.  

Available Variants

  • PIIBlockPolicy: Blocks any content with PII
  • PIIBlockPolicy_LLM: LLM-powered block messages
  • PIIBlockPolicy_LLM_Finder: LLM detection for better accuracy
  • PIIAnonymizePolicy: Anonymizes PII with unique replacements
  • PIIReplacePolicy: Replaces PII with [PII_REDACTED]
  • PIIRaiseExceptionPolicy: Raises DisallowedOperation exception
  • PIIRaiseExceptionPolicy_LLM: LLM-generated exception messages