fix Bedrock Guardrails intervention detection
in llms/bedrock.py, line 682 the function _is_guardrails_intervention uses body.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"
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"
#299 was merged, I guess this should be closed, as it should be fixed on the next release
@3coins