Skip to content

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]

content filter test fix

yuneng-jiang8d10311b4b23
diff --git a/litellm/proxy/guardrails/guardrail_hooks/litellm_content_filter/content_filter.py b/litellm/proxy/guardrails/guardrail_hooks/litellm_content_filter/content_filter.py
index 9d64aea8910..9b2b43c6fcb 100644
--- a/litellm/proxy/guardrails/guardrail_hooks/litellm_content_filter/content_filter.py
+++ b/litellm/proxy/guardrails/guardrail_hooks/litellm_content_filter/content_filter.py
@@ -29,10 +29,7 @@ from fastapi import HTTPException
from litellm import Router
from litellm._logging import verbose_proxy_logger
-from litellm.integrations.custom_guardrail import (
- CustomGuardrail,
- log_guardrail_information,
-)
+from litellm.integrations.custom_guardrail import CustomGuardrail
from litellm.proxy._types import UserAPIKeyAuth
from litellm.types.utils import ModelResponseStream
@@ -1056,7 +1053,6 @@ class ContentFilterGuardrail(CustomGuardrail):
masked_entity_count=masked_entity_count,
)
- @log_guardrail_information
async def apply_guardrail(
self,
inputs: "GenericGuardrailAPIInputs",
diff --git a/tests/code_coverage_tests/check_guardrail_apply_decorator.py b/tests/code_coverage_tests/check_guardrail_apply_decorator.py
index 18a86277aa9..523b9f5b35b 100644
--- a/tests/code_coverage_tests/check_guardrail_apply_decorator.py
+++ b/tests/code_coverage_tests/check_guardrail_apply_decorator.py
@@ -83,6 +83,12 @@ def test_guardrail_apply_decorator():
if python_file.name == "bedrock_guardrails.py":
continue
+ # Skip content_filter.py - it implements its own detailed logging via
+ # _log_guardrail_information with detections, masked_entity_count, etc.
+ # Using the decorator would cause duplicate entries.
+ if python_file.name == "content_filter.py":
+ continue
+
results = find_apply_guardrail_methods(python_file)
for class_name, line_num, has_decorator in results: