Skip to content

Commit

Permalink
Merge pull request #7 from decypher-ai/pii_issues_docs
Browse files Browse the repository at this point in the history
Some changes is sample flows.co
  • Loading branch information
abhijitpal1247 authored Mar 6, 2024
2 parents 7806ae8 + 643096f commit 747fa54
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
9 changes: 4 additions & 5 deletions examples/configs/autoguard/autoguard_config/flows.co
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,15 @@ define flow call autoguard output
$pii_response_input = $input_result['pii_fast']['response']
bot respond pii input


if $output_result["pii_fast"]["guarded"]
$pii_response_output = $output_result['pii_fast']['response']
bot respond pii output

if $output_result["guardrails_triggered"]
$autoguard_output_response = $output_result['combined_response']
bot refuse to respond autoguard output
stop
else
if $output_result["pii_fast"]["guarded"]
$pii_response_output = $output_result['pii_fast']['response']
bot respond pii output
stop
bot respond to question


Expand Down
6 changes: 3 additions & 3 deletions nemoguardrails/library/autoguard/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ def process_autoguard_output(responses: List[Any]):
"""Processes the output provided AutoGuard API"""

response_dict = {"guardrails_triggered": False}
prefixes = []
prefixes = set()
for response in responses:
if response["guarded"]:
if response["task"] == "text_toxicity_extraction":
response_dict["guardrails_triggered"] = True
prefixes += [GUARDRAIL_RESPONSE_TEXT[response["task"]]]
prefixes.add(GUARDRAIL_RESPONSE_TEXT[response["task"]])
suffix = " Toxic phrases: " + ", ".join(response["output_data"])
response_dict[response["task"]] = {
"guarded": True,
Expand All @@ -100,7 +100,7 @@ def process_autoguard_output(responses: List[Any]):
"response": response["response"][start_index:],
}
else:
prefixes += [GUARDRAIL_RESPONSE_TEXT[response["task"]]]
prefixes.add(GUARDRAIL_RESPONSE_TEXT[response["task"]])
response_dict["guardrails_triggered"] = True
response_dict[response["task"]] = {
"guarded": True,
Expand Down

0 comments on commit 747fa54

Please sign in to comment.