This example demonstrates how to use Weights & Biases (W&B) Weave with PII redaction in your NeMo Agent toolkit workflows.
- PII Redaction Integration: Demonstrates automatic redaction of Personally Identifiable Information (PII) using Microsoft Presidio within NeMo Agent toolkit workflows for data privacy compliance.
- Weave Observability Platform: Shows integration with Weights & Biases Weave for detailed workflow tracking and visualization with privacy-preserving telemetry.
- Configurable Entity Detection: Supports redaction of multiple PII types including email addresses, phone numbers, credit cards, Social Security Numbers, and person names through configurable entity type selection.
- Custom Key Redaction: Demonstrates redaction of custom sensitive keys like API keys, auth tokens, and other application-specific secrets beyond standard PII entities.
- Privacy-Preserving Monitoring: Shows how to maintain comprehensive observability while ensuring sensitive data is automatically redacted from traces and logs.
If you have not already done so, follow the instructions in the Install Guide to create the development environment and install NeMo Agent Toolkit.
From the root directory of the NeMo Agent toolkit library, run the following commands:
uv pip install -e examples/observability/redact_piiYou need a Weights & Biases account to use Weave observability features. Sign up at https://wandb.ai if you don't have one.
You need to set up API keys for Weave observability. This involves obtaining a Weave API key from your Weights & Biases account and setting it in your environment variables.
export WANDB_API_KEY=your_api_key_hereweave_redact_pii_config.yaml: Workflow configuration that enables Weave telemetry with PII redactionexamples/observability/redact_pii/src/nat_redact_pii/register.py: Contains thepii_redaction_testfunction that generates sample PII data
- An example weave config is provided in the
weave_redact_pii_config.yamlfile.
telemetry:
tracing:
weave:
_type: weave
project: "nvidia-nat-pii"
redact_pii: true
redact_pii_fields:
- EMAIL_ADDRESS
# Uncomment other entity types as needed
# - PHONE_NUMBER
# - CREDIT_CARD
# - US_SSN
# - PERSON redact_keys:
- custom_secret
- api_key
- auth_token- Serve the workflow:
nat serve --config_file examples/observability/redact_pii/configs/weave_redact_pii_config.yml- Invoke the workflow:
In another terminal, submit a POST request to invoke the served workflow
curl -X 'POST' 'http://localhost:8000/generate'
-H 'accept: application/json'
-H 'Content-Type: application/json' -d '{
"input_message": "What is John Doe'\''s contact information?"
}'
{"value":"John Doe's contact information is:\n\n* Email: test@example.com\n* Phone: 555-123-4567"}- Go to your Weights & Biases dashboard (https://wandb.ai) and navigate to the
nvidia-nat-piiproject.
Note: Because observability does not block workflow execution, PII redacted traces might take a few minutes to arrive in the Weights & Biases dashboard.
-
Open the Weave trace viewer to see the redacted PII data. With the default configuration, you'll see:
- Redacted email addresses (
EMAIL_ADDRESS) - Redacted custom keys (
custom_secret,api_key,auth_token)
If you enable additional entity types, you may also see:
- Redacted phone numbers (
PHONE_NUMBER) - Redacted credit card information (
CREDIT_CARD) - Redacted social security numbers (
US_SSN) - Redacted person names (
PERSON)
- Redacted email addresses (
You can customize what gets redacted by modifying these fields in the weave_redact_pii_config.yml file:
The redact_pii_fields array specifies which PII entity types to redact. By default, only EMAIL_ADDRESS is enabled. Additional entity types can be enabled as needed, but may impact tracing latency.
For a full list of entities that can be detected and redacted, see PII entities supported by Presidio.
redact_pii_fields:
- EMAIL_ADDRESS
# Optional entity types (uncomment as needed):
# - PHONE_NUMBER
# - CREDIT_CARD
# - US_SSN
# - PERSON
# Note: Enabling additional entity types may impact tracing latency performanceThe redact_keys array specifies additional keys to redact beyond the default ones:
redact_keys:
- custom_secret
- api_key
- auth_token
# Add your own custom keys here