The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
fix(guardrails): drop the types import CodeQL reads as a package cycle
mateo-berri93f3911b32e0
diff --git a/litellm/llms/base_llm/guardrail_translation/utils.py b/litellm/llms/base_llm/guardrail_translation/utils.pyindex 1172c93959b..34d648cf184 100644--- a/litellm/llms/base_llm/guardrail_translation/utils.py+++ b/litellm/llms/base_llm/guardrail_translation/utils.py@@ -2,7 +2,6 @@ from __future__ import annotationsimport jsonfrom collections.abc import Callable, Iterator, Mapping, Sequence-from types import MappingProxyTypefrom typing import Final, TypeVar, cast # noqa: TID251 # a rebuilt chat row has no typed constructor across rolesfrom pydantic import BaseModel@@ -390,13 +389,10 @@ def _part_with_text(part: object, text: str) -> object:def _content_with_slot_texts(content: Sequence[object], texts: Sequence[str]) -> Sequence[object]:- text_part_indices: Final = tuple(- index for index, part in enumerate(content) if _content_part_text(part) is not None- )- replacement_by_index: Final = MappingProxyType(dict(zip(text_part_indices, texts)))+ remaining_texts: Final = iter(texts)return [ # mutable-ok: message content stays a JSON list- _part_with_text(part, replacement_by_index[index]) if index in replacement_by_index else part- for index, part in enumerate(content)+ _part_with_text(part, next(remaining_texts)) if _content_part_text(part) is not None else part+ for part in content]