-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
[Bug Fix] Bedrock Guardrail - Don't raise exception on intervene action #11875
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a bug with the Bedrock Guardrail not correctly handling intervention actions by only raising exceptions for BLOCKED actions and leaving ANONYMIZED actions untouched. It also introduces new tests to verify the guardrail’s behavior and updates several methods to improve code readability and consistency.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
tests/guardrails_tests/test_bedrock_guardrails.py | Added tests to validate that only BLOCKED actions trigger exceptions and that masking with anonymized responses work as expected |
litellm/proxy/guardrails/guardrail_hooks/bedrock_guardrails.py | Revised guardrail exception logic to only raise exceptions on BLOCKED actions and updated message-masking functions with clearer formatting |
# Should use the masked content from guardrail output | ||
assert response is not None | ||
assert response["messages"][0]["content"] == "Hello, my phone number is {PHONE} and email is {EMAIL}" | ||
print("✅ Masked output was applied even without masking flags enabled") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider replacing the print statement with a logger call to maintain consistency with the rest of the codebase's logging practices.
print("✅ Masked output was applied even without masking flags enabled") | |
logger.info("✅ Masked output was applied even without masking flags enabled") |
Copilot uses AI. Check for mistakes.
[Bug Fix] Bedrock Guardrail - Don't raise exception on intervene action
Relevant issues
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
tests/litellm/
directory, Adding at least 1 test is a hard requirement - see detailsmake test-unit
Type
🐛 Bug Fix
✅ Test
Changes