Skip to content

Commit 9119184

Browse files
committed
removed duplicate code
1 parent 917c8bb commit 9119184

File tree

2 files changed

+0
-66
lines changed

2 files changed

+0
-66
lines changed

litellm/proxy/guardrails/guardrail_hooks/bedrock_guardrails.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -423,19 +423,6 @@ def _get_bedrock_guardrail_response_status(
423423
return "success"
424424
return "failure"
425425

426-
def _get_http_exception_for_failed_guardrail(
427-
self, response: httpx.Response
428-
) -> HTTPException:
429-
return HTTPException(
430-
status_code=400,
431-
detail={
432-
"error": "Guardrail application failed.",
433-
"bedrock_guardrail_response": json.loads(
434-
response.content.decode("utf-8")
435-
).get("Output", {}),
436-
},
437-
)
438-
439426
def _get_http_exception_for_blocked_guardrail(
440427
self, response: BedrockGuardrailResponse
441428
) -> HTTPException:

tests/test_litellm/proxy/guardrails/guardrail_hooks/test_bedrock_guardrails.py

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,59 +1187,6 @@ async def test_bedrock_guardrail_uses_default_endpoint_when_no_custom_set(monkey
11871187

11881188
print(f"Default endpoint test passed. URL: {prepped_request.url}")
11891189

1190-
1191-
@pytest.mark.asyncio
1192-
async def test_bedrock_guardrail_parameter_takes_precedence_over_env(monkeypatch):
1193-
"""Test that aws_bedrock_runtime_endpoint parameter takes precedence over environment variable
1194-
1195-
This test verifies the corrected behavior where the parameter should take precedence
1196-
over the environment variable, consistent with the endpoint_url logic.
1197-
"""
1198-
1199-
param_endpoint = "https://param-bedrock.example.com"
1200-
env_endpoint = "https://env-bedrock.example.com"
1201-
1202-
# Set environment variable
1203-
monkeypatch.setenv("AWS_BEDROCK_RUNTIME_ENDPOINT", env_endpoint)
1204-
1205-
# Create guardrail with explicit aws_bedrock_runtime_endpoint
1206-
guardrail = BedrockGuardrail(
1207-
guardrailIdentifier="test-guardrail",
1208-
guardrailVersion="DRAFT",
1209-
aws_bedrock_runtime_endpoint=param_endpoint,
1210-
)
1211-
1212-
# Mock credentials
1213-
mock_credentials = MagicMock()
1214-
mock_credentials.access_key = "test-access-key"
1215-
mock_credentials.secret_key = "test-secret-key"
1216-
mock_credentials.token = None
1217-
1218-
# Test data
1219-
data = {"source": "INPUT", "content": [{"text": {"text": "test content"}}]}
1220-
optional_params = {}
1221-
aws_region_name = "us-east-1"
1222-
1223-
# Mock the _load_credentials method
1224-
with patch.object(
1225-
guardrail, "_load_credentials", return_value=(mock_credentials, aws_region_name)
1226-
):
1227-
# Call _prepare_request which internally calls get_runtime_endpoint
1228-
prepped_request = guardrail._prepare_request(
1229-
credentials=mock_credentials,
1230-
data=data,
1231-
optional_params=optional_params,
1232-
aws_region_name=aws_region_name,
1233-
)
1234-
1235-
# Verify that the parameter takes precedence over environment variable
1236-
expected_url = f"{param_endpoint}/guardrail/{guardrail.guardrailIdentifier}/version/{guardrail.guardrailVersion}/apply"
1237-
assert (
1238-
prepped_request.url == expected_url
1239-
), f"Expected parameter endpoint to take precedence. Got: {prepped_request.url}"
1240-
1241-
print(f"Parameter precedence test passed. URL: {prepped_request.url}")
1242-
12431190
@pytest.mark.asyncio
12441191
async def test_bedrock_guardrail_200_with_exception_in_output_raises_and_logs_failure():
12451192
"""

0 commit comments

Comments
 (0)