Open will-gao42 opened 4 months ago
I concur, but it's even worse. Currently the GUARDRAILS_BODY_KEY is using "..Assessment" instead of "...Action" whereas the body returned (using boto3/core v 1.34.162) returns ..."Action" as mentioned in the original post. The op is also correct about the value: it returns INTERVENED and the code still checks for GUARDRAILS_INTERVENED
Current: line 40: GUARDRAILS_BODY_KEY = "amazon-bedrock-guardrailAssessment" Should be: GUARDRAILS_BODY_KEY = "amazon-bedrock-guardrailAction"
in
llms/bedrock.py
, line 682 the function_is_guardrails_intervention
usesbody.get(GUARDRAILS_BODY_KEY) == "GUARDRAIL_INTERVENED"
to detect intervention, where GUARDRAILS_BODY_KEY is defined as "amazon-bedrock-guardrailAction" on line 35. However the payload from Bedrock actually uses'amazon-bedrock-guardrailAction': 'INTERVENED'
to indicate intervention.Fix: line 35: GUARDRAILS_BODY_KEY=amazon-bedrock-guardrailAction line 682: body.get(GUARDRAILS_BODY_KEY) == "INTERVENED"