mirror of
https://github.com/BerriAI/litellm.git
synced 2026-08-28 05:25:59 +00:00
fix(guardrails): annotate policy pipeline state casts
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
95427d3396
commit
4fd0cbffb5
1 changed files with 10 additions and 2 deletions
|
|
@ -432,12 +432,20 @@ def _policy_state_metadata(data: Mapping[str, object]) -> Mapping[str, object]:
|
|||
|
||||
def _policy_pipelines(data: Mapping[str, object]) -> tuple[tuple[str, "GuardrailPipeline"], ...]:
|
||||
pipelines: Final = _policy_state_metadata(data).get("_guardrail_pipelines")
|
||||
return tuple(cast("Sequence[tuple[str, GuardrailPipeline]]", pipelines)) if pipelines else ()
|
||||
return (
|
||||
tuple(cast("Sequence[tuple[str, GuardrailPipeline]]", pipelines)) # cast-ok: the policy engine wrote the slot
|
||||
if pipelines
|
||||
else ()
|
||||
)
|
||||
|
||||
|
||||
def _pipeline_managed_guardrail_names(data: Mapping[str, object]) -> frozenset[str]:
|
||||
managed: Final = _policy_state_metadata(data).get("_pipeline_managed_guardrails")
|
||||
return frozenset(cast("Collection[str]", managed)) if managed else frozenset()
|
||||
return (
|
||||
frozenset(cast("Collection[str]", managed)) # cast-ok: the policy engine wrote these guardrail names
|
||||
if managed
|
||||
else frozenset()
|
||||
)
|
||||
|
||||
|
||||
def _prompt_block_text(block: object) -> str:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue