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(llmguard): drop call types the proxy never routes through moderation
yuchengc38dda2b2f47
diff --git a/enterprise/litellm_enterprise/enterprise_callbacks/llm_guard.py b/enterprise/litellm_enterprise/enterprise_callbacks/llm_guard.pyindex 1559fff291c..3422e8969b0 100644--- a/enterprise/litellm_enterprise/enterprise_callbacks/llm_guard.py+++ b/enterprise/litellm_enterprise/enterprise_callbacks/llm_guard.py@@ -147,11 +147,6 @@ class _ENTERPRISE_LLMGuard(CustomLogger):"aembedding","image_generation","aimage_generation",- "moderation",- "amoderation",- "audio_transcription",- "transcription",- "atranscription",)if call_type not in accepted_call_types:self.print_verbose(diff --git a/tests/test_litellm/enterprise/enterprise_callbacks/test_llm_guard.py b/tests/test_litellm/enterprise/enterprise_callbacks/test_llm_guard.pyindex 4bb663b3bf0..5695b184479 100644--- a/tests/test_litellm/enterprise/enterprise_callbacks/test_llm_guard.py+++ b/tests/test_litellm/enterprise/enterprise_callbacks/test_llm_guard.py@@ -20,13 +20,8 @@ from litellm.types.utils import CallTypesLiteral("embeddings", "input"),("embedding", "input"),("aembedding", "input"),- ("moderation", "input"),- ("amoderation", "input"),("image_generation", "prompt"),("aimage_generation", "prompt"),- ("audio_transcription", "prompt"),- ("transcription", "prompt"),- ("atranscription", "prompt"),),)@pytest.mark.parametrize("is_valid", (True, False))@@ -68,6 +63,24 @@ async def test_llm_guard_call_type_aliases()[email protected]("call_type", ("amoderation", "atranscription", "aresponses", "aanthropic_messages"))+async def test_llm_guard_ignores_call_types_the_proxy_never_moderates(+ call_type: CallTypesLiteral, monkeypatch: pytest.MonkeyPatch+) -> None:+ monkeypatch.setattr(litellm, "llm_guard_mode", "all")+ llm_guard: Final = _ENTERPRISE_LLMGuard(+ mock_testing=True,+ mock_redacted_text={"sanitized_prompt": "[REDACTED]", "is_valid": False},+ )+ data: Final = {"input": "email: [email protected]"}+ result: Final = await llm_guard.async_moderation_hook(+ data=data, user_api_key_dict=UserAPIKeyAuth(), call_type=call_type+ )+ assert result is data+ assert data["input"] == "email: [email protected]"++@pytest.mark.parametrize("call_type", ("text_completion", "atext_completion"))@pytest.mark.parametrize("is_valid", (True, False))@pytest.mark.asyncio