From 1b0b855078191870d54e758b69e33f78678febc0 Mon Sep 17 00:00:00 2001 From: letmerecall Date: Mon, 21 Oct 2024 14:54:26 +0530 Subject: [PATCH 1/2] Migrate private ai flow to latest version --- nemoguardrails/library/privateai/flows.co | 31 +++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 nemoguardrails/library/privateai/flows.co diff --git a/nemoguardrails/library/privateai/flows.co b/nemoguardrails/library/privateai/flows.co new file mode 100644 index 000000000..ba7d20679 --- /dev/null +++ b/nemoguardrails/library/privateai/flows.co @@ -0,0 +1,31 @@ +# 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 From 0c3edf5b485a99cfac46a980777f86e49a57840d Mon Sep 17 00:00:00 2001 From: letmerecall Date: Mon, 21 Oct 2024 14:57:52 +0530 Subject: [PATCH 2/2] Fix typo in private ai flow --- nemoguardrails/library/privateai/flows.co | 2 +- nemoguardrails/library/privateai/flows.v1.co | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/nemoguardrails/library/privateai/flows.co b/nemoguardrails/library/privateai/flows.co index ba7d20679..aa4c2b7a0 100644 --- a/nemoguardrails/library/privateai/flows.co +++ b/nemoguardrails/library/privateai/flows.co @@ -9,7 +9,7 @@ flow detect pii on input abort -# INPUT RAILS +# OUTPUT RAILS flow detect pii on output """Check if the bot output has PII.""" diff --git a/nemoguardrails/library/privateai/flows.v1.co b/nemoguardrails/library/privateai/flows.v1.co index a7e4fca55..d50227fc6 100644 --- a/nemoguardrails/library/privateai/flows.v1.co +++ b/nemoguardrails/library/privateai/flows.v1.co @@ -9,7 +9,7 @@ define subflow detect pii on input stop -# INPUT RAILS +# OUTPUT RAILS define subflow detect pii on output """Check if the bot output has PII."""