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-
detect_sensitive_dataChecks whether the provided text contains any sensitive data.
detect_sensitive_data_mappingMapping for detect_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.detect_sensitive_data(
source: str,
text: str,
config: nemoguardrails.RailsConfig,
kwargs = {}
)
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 True if any sensitive data has been detected, False otherwise.

nemoguardrails.library.sensitive_data_detection.actions.detect_sensitive_data_mapping(
result: bool
) -> bool

Mapping for detect_sensitive_data.

Since the function returns True when sensitive data is detected, we block if result is True.

nemoguardrails.library.sensitive_data_detection.actions.mask_sensitive_data(
source: str,
text: str,
config: nemoguardrails.RailsConfig
)
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 The altered text, if applicable.

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