File tree Expand file tree Collapse file tree 4 files changed +85
-0
lines changed
examples/configs/sensitive_data_detection_v2 Expand file tree Collapse file tree 4 files changed +85
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Presidio-based Sensitive Data Detection Example
2
+
3
+ This example demonstrates how to detect and redact sensitive data using [ Presidio] ( https://github.com/Microsoft/presidio ) .
4
+
5
+ ## Prerequisites
6
+
7
+ - ` Presidio `
8
+
9
+ You can install it with:
10
+
11
+ ``` bash
12
+ poetry run pip install presidio-analyzer presidio-anonymizer
13
+ ```
14
+
15
+ > ** Note**
16
+ >
17
+ > Presidio may come with an unsupported version of ` numpy ` . To reinstall the supported version, run:
18
+ > ``` bash
19
+ > poetry install
20
+ > ` ` `
21
+
22
+ - ` en_core_web_lg` spaCy model
23
+
24
+ You can download it with:
25
+
26
+ ` ` ` bash
27
+ poetry run python -m spacy download en_core_web_lg
28
+ ```
29
+
30
+ ## Running example
31
+
32
+ To test this configuration, run the CLI chat from the ` examples/configs/sensitive_data_detection_v2 ` directory:
33
+
34
+ ``` bash
35
+ poetry run nemoguardrails chat --config=.
36
+ ```
37
+
38
+ ## Documentation
39
+
40
+ - [ Presidio-based Sensitive Data Detection configuration] ( ../../../docs/user-guides/guardrails-library.md#presidio-based-sensitive-data-detection )
41
+ - [ Presidio Integration guide] ( ../../../docs/user-guides/community/presidio.md )
Original file line number Diff line number Diff line change
1
+ colang_version : " 2.x"
2
+
3
+ models :
4
+ - type : main
5
+ engine : openai
6
+ model : gpt-4o-mini
7
+
8
+ rails :
9
+ config :
10
+ sensitive_data_detection :
11
+ input :
12
+ score_threshold : 0.4
13
+ entities :
14
+ - PERSON
15
+ - EMAIL_ADDRESS
16
+ - PHONE_NUMBER
17
+ - CREDIT_CARD
18
+ - US_SSN
19
+ - LOCATION
20
+
21
+ output :
22
+ score_threshold : 0.4
23
+ entities :
24
+ - PERSON
25
+ - EMAIL_ADDRESS
26
+ - PHONE_NUMBER
27
+ - CREDIT_CARD
28
+ - US_SSN
29
+ - LOCATION
Original file line number Diff line number Diff line change
1
+ import guardrails
2
+ import nemoguardrails.library.sensitive_data_detection
3
+
4
+ flow input rails $input_text
5
+ """Check user utterances before they get further processed."""
6
+ await mask sensitive data on input
7
+
8
+ flow output rails $output_text
9
+ """Check response before sending it to user."""
10
+ await mask sensitive data on output
Original file line number Diff line number Diff line change
1
+ import core
2
+ import llm
3
+
4
+ flow main
5
+ activate llm continuation
You can’t perform that action at this time.
0 commit comments