---
title: Privateai (NeMo Guardrail)
type: guardrail
provider: nvidia
category: safety
source: 'https://github.com/NVIDIA-NeMo/Guardrails'
license: Apache-2.0
tags:
  - guardrail
  - nemo
  - rails
  - colang
dateAdded: '2026-05-16'
featured: false
origin: official
language: en
description: >-
  PII DETECTION RAILS INPUT RAILS flow detect pii on input """Check if the user
  input has PII.""" $has_pii = await DetectPiiAction(source="input", text=
---

```coffee
#### PII DETECTION RAILS ####

# INPUT RAILS

flow detect pii on input
  """Check if the user input has PII."""
  $has_pii = await DetectPiiAction(source="input", text=$user_message)

  if $has_pii
    bot inform answer unknown
    abort


# INPUT RAILS

flow detect pii on output
  """Check if the bot output has PII."""
  $has_pii = await DetectPiiAction(source="output", text=$bot_message)

  if $has_pii
    bot inform answer unknown
    abort


# RETRIVAL RAILS

flow detect pii on retrieval
  """Check if the relevant chunks from the knowledge base have any PII."""
  $has_pii = await DetectPiiAction(source="retrieval", text=$relevant_chunks)

  if $has_pii
    bot inform answer unknown
    abort


#######################################################


#### PII MASKING RAILS ####

# INPUT RAILS

flow mask pii on input
  """Mask any detected PII in the user input."""
  $masked_input = await MaskPiiAction(source="input", text=$user_message)

  global $user_message
  $user_message = $masked_input


# OUTPUT RAILS

flow mask pii on output
  """Mask any detected PII in the bot output."""
  $bot_message = await MaskPiiAction(source="output", text=$bot_message)


# RETRIVAL RAILS

flow mask pii on retrieval
  """Mask any detected PII in the relevant chunks from the knowledge base."""
  $relevant_chunks = await MaskPiiAction(source="retrieval", text=$relevant_chunks)
```
