nemoguardrails.library.sensitive_data_detection.actions

View as Markdown

Module Contents

Functions

NameDescription
_get_ad_hoc_recognizersHelper to compute the ad hoc recognizers for a config.
_get_analyzer-
_mask_sensitive_data_outcome-
_sensitive_data_detection_outcome-
detect_sensitive_dataChecks whether the provided text contains any sensitive data.
mask_sensitive_dataChecks whether the provided text contains any sensitive data.

Data

log

API

nemoguardrails.library.sensitive_data_detection.actions._get_ad_hoc_recognizers(
sdd_config: nemoguardrails.rails.llm.config.SensitiveDataDetection
)

Helper to compute the ad hoc recognizers for a config.

nemoguardrails.library.sensitive_data_detection.actions._get_analyzer(
score_threshold: float = 0.4
)
nemoguardrails.library.sensitive_data_detection.actions._mask_sensitive_data_outcome(
source: str,
original_text: str,
masked_text: str
) -> nemoguardrails.actions.rail_outcome.RailOutcome
nemoguardrails.library.sensitive_data_detection.actions._sensitive_data_detection_outcome(
has_sensitive_data: bool
) -> nemoguardrails.actions.rail_outcome.RailOutcome
nemoguardrails.library.sensitive_data_detection.actions.detect_sensitive_data(
source: str,
text: str,
config: nemoguardrails.RailsConfig,
kwargs = {}
) -> nemoguardrails.actions.rail_outcome.RailOutcome
async

Checks whether the provided text contains any sensitive data.

Args source: The source for the text, i.e. “input”, “output”, “retrieval”. text: The text to check. config: The rails configuration object.

Returns RailOutcome.block() if sensitive data has been detected, RailOutcome.allow() otherwise.

nemoguardrails.library.sensitive_data_detection.actions.mask_sensitive_data(
source: str,
text: str,
config: nemoguardrails.RailsConfig
) -> nemoguardrails.actions.rail_outcome.RailOutcome
async

Checks whether the provided text contains any sensitive data.

Args source: The source for the text, i.e. “input”, “output”, “retrieval”. text: The text to check. config: The rails configuration object.

Returns RailOutcome.transform() with the altered text if it changed, RailOutcome.allow() otherwise.

nemoguardrails.library.sensitive_data_detection.actions.log = logging.getLogger(__name__)