mirror of
https://github.com/tiennm99/litellm.git
synced 2026-08-02 14:22:16 +00:00
Indent and import fix
This commit is contained in:
@@ -20,6 +20,7 @@ from typing import (
|
||||
AsyncGenerator,
|
||||
List,
|
||||
Literal,
|
||||
NamedTuple,
|
||||
Optional,
|
||||
Tuple,
|
||||
Union,
|
||||
@@ -1291,38 +1292,38 @@ class BedrockGuardrail(CustomGuardrail, BaseAWSLLM):
|
||||
request_data=request_data,
|
||||
)
|
||||
|
||||
bedrock_response = await self.make_bedrock_api_request(
|
||||
source="INPUT",
|
||||
messages=mock_messages,
|
||||
request_data=request_data,
|
||||
bedrock_response = await self.make_bedrock_api_request(
|
||||
source="INPUT",
|
||||
messages=mock_messages,
|
||||
request_data=request_data,
|
||||
)
|
||||
|
||||
if bedrock_response.get("action") == "BLOCKED":
|
||||
raise Exception(
|
||||
f"Content blocked by Bedrock guardrail: {bedrock_response.get('reason', 'Unknown reason')}"
|
||||
)
|
||||
|
||||
if bedrock_response.get("action") == "BLOCKED":
|
||||
raise Exception(
|
||||
f"Content blocked by Bedrock guardrail: {bedrock_response.get('reason', 'Unknown reason')}"
|
||||
)
|
||||
|
||||
# Apply any masking that was applied by the guardrail
|
||||
masked_text = text
|
||||
output_list = bedrock_response.get("output")
|
||||
if output_list:
|
||||
# If the guardrail returned modified content, use that
|
||||
for output_item in output_list:
|
||||
# Apply any masking that was applied by the guardrail
|
||||
masked_text = text
|
||||
output_list = bedrock_response.get("output")
|
||||
if output_list:
|
||||
# If the guardrail returned modified content, use that
|
||||
for output_item in output_list:
|
||||
text_content = output_item.get("text")
|
||||
if text_content:
|
||||
masked_text = str(text_content)
|
||||
break
|
||||
else:
|
||||
outputs_list = bedrock_response.get("outputs")
|
||||
if outputs_list:
|
||||
# Fallback to outputs field if output is not available
|
||||
for output_item in outputs_list:
|
||||
text_content = output_item.get("text")
|
||||
if text_content:
|
||||
masked_text = str(text_content)
|
||||
break
|
||||
else:
|
||||
outputs_list = bedrock_response.get("outputs")
|
||||
if outputs_list:
|
||||
# Fallback to outputs field if output is not available
|
||||
for output_item in outputs_list:
|
||||
text_content = output_item.get("text")
|
||||
if text_content:
|
||||
masked_text = str(text_content)
|
||||
break
|
||||
|
||||
masked_texts.append(masked_text)
|
||||
masked_texts.append(masked_text)
|
||||
|
||||
verbose_proxy_logger.debug(
|
||||
"Bedrock Guardrail: Successfully applied guardrail"
|
||||
|
||||
Reference in New Issue
Block a user