forked from NVIDIA/NeMo-Guardrails
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add flows and small fixes for the predefined rails included in the li…
…brary.
- Loading branch information
Showing
6 changed files
with
62 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
define subflow check facts | ||
"""Check if the previous answer is accurate w.r.t. the relevant chunks. | ||
|
||
This output rail must be enabled explicitly per output message by setting | ||
the $check_facts context variable to True. | ||
""" | ||
if $check_facts == True | ||
$check_facts = False | ||
|
||
$accurate = execute check_facts | ||
if not $accurate | ||
bot inform answer unknown | ||
stop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
define flow hallucination warning | ||
"""Warning rail for hallucination.""" | ||
bot ... | ||
if $hallucination_warning == True | ||
$is_hallucination = execute check_hallucination | ||
$hallucination_warning = False | ||
|
||
if $is_hallucination | ||
bot inform answer prone to hallucination | ||
|
||
define bot inform answer prone to hallucination | ||
"The previous answer is prone to hallucination and may not be accurate. Please double check the answer using additional sources." | ||
"The above response may have been hallucinated, and should be independently verified." | ||
|
||
|
||
define subflow check hallucination | ||
"""Output rail for checking hallucinations.""" | ||
if $check_hallucination == True | ||
$is_hallucination = execute check_hallucination | ||
$check_hallucination = False | ||
|
||
if $is_hallucination | ||
bot inform answer unknown | ||
stop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
define bot inform cannot answer | ||
"I am not able to answer the question." | ||
|
||
define subflow check jailbreak | ||
$allowed = execute check_jailbreak | ||
|
||
if not $allowed | ||
bot inform cannot answer | ||
stop |
17 changes: 10 additions & 7 deletions
17
...ailbreak_check/sample_rails/moderation.co → ...drails/library/output_moderation/flows.co
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,18 @@ | ||
define bot remove last message | ||
"(remove last message)" | ||
|
||
define bot inform cannot answer question | ||
"I cannot answer the question." | ||
|
||
define extension flow check bot response | ||
priority 2 | ||
bot ... | ||
|
||
define subflow output moderation | ||
$allowed = execute output_moderation | ||
|
||
if not $allowed | ||
bot remove last message | ||
bot inform cannot answer question | ||
stop | ||
|
||
|
||
define subflow output moderation v2 | ||
$allowed = execute output_moderation_v2 | ||
|
||
if not $allowed | ||
bot inform cannot answer question | ||
stop |