nemoguardrails.library.privateai.actions
PII detection using Private AI.
Module Contents
Functions
Data
API
async
Checks whether the provided text contains any PII.
Args source: The source for the text, i.e. “input”, “output”, “retrieval”. text: The text to check. config: The rails configuration object.
Returns True if PII is detected, False otherwise.
Raises:
ValueError: If PAI_API_KEY is missing when using cloud API or if the response is invalid.
Mapping for detect_pii.
Since the function returns True when PII is detected, we block if result is True.
async
Masks any detected PII in the provided text.
Parameters:
source
The source for the text, i.e. “input”, “output”, “retrieval”.
text
The text to check.
config
The rails configuration object.
Returns:
The altered text with PII masked.
Raises:
ValueError: If PAI_API_KEY is missing when using cloud API or if the response is invalid.