mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-18 09:45:23 +00:00
refactor(guardrails): annotate read-only mask inputs as Sequence and Mapping
Co-authored-by: feng.tsai <fengtsai@berri.ai> Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
c41ef0f3d9
commit
c9678e52ef
1 changed files with 4 additions and 2 deletions
|
|
@ -3320,7 +3320,7 @@ class BedrockGuardrail(CustomGuardrail, BaseAWSLLM):
|
|||
return updated_messages
|
||||
|
||||
@staticmethod
|
||||
def _mask_leaf(item: object, masked_texts: list[str], masking_index: int) -> tuple[object, int]:
|
||||
def _mask_leaf(item: object, masked_texts: Sequence[str], masking_index: int) -> tuple[object, int]:
|
||||
if isinstance(item, str):
|
||||
if masking_index < len(masked_texts):
|
||||
return masked_texts[masking_index], masking_index + 1
|
||||
|
|
@ -3336,7 +3336,9 @@ class BedrockGuardrail(CustomGuardrail, BaseAWSLLM):
|
|||
return item, masking_index
|
||||
|
||||
@staticmethod
|
||||
def _mask_tool_result(item: dict, masked_texts: list[str], masking_index: int) -> tuple[dict, int]:
|
||||
def _mask_tool_result(
|
||||
item: Mapping[str, object], masked_texts: Sequence[str], masking_index: int
|
||||
) -> tuple[Mapping[str, object], int]:
|
||||
inner: Final = item.get("content")
|
||||
if isinstance(inner, str):
|
||||
masked, masking_index = BedrockGuardrail._mask_leaf(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue