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: test_sentence[dt_8]
Sameer Kankute8288e351ef20
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.pyindex d569e69e56e..d0ad9eb4044 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@@ -214,6 +214,10 @@ class ContentFilterGuardrail(CustomGuardrail):self.category_keywords: Dict[str, Tuple[str, str, ContentFilterAction]] = ({}) # keyword -> (category, severity, action)+ # Always-block keywords are checked before exceptions (cannot be bypassed)+ self.always_block_category_keywords: Dict[+ str, Tuple[str, str, ContentFilterAction]+ ] = {}# Store conditional categories (identifier_words + block_words)self.conditional_categories: Dict[str, Dict[str, Any]] = ({}@@ -452,7 +456,7 @@ class ContentFilterGuardrail(CustomGuardrail):keyword = keyword_data["keyword"].lower()severity = keyword_data.get("severity", "high")if self._should_apply_severity(severity, severity_threshold):- self.category_keywords[keyword] = (+ self.always_block_category_keywords[keyword] = (category_name,severity,category_action,@@ -1064,6 +1068,20 @@ class ContentFilterGuardrail(CustomGuardrail):"""text_lower = text.lower()+ # Always-block keywords are matched first — exceptions do not apply to them.+ for keyword, (category, severity, action) in self.always_block_category_keywords.items():+ keyword_pattern_str = self._keyword_to_regex_pattern(keyword)+ if " " in keyword:+ keyword_found = bool(re.search(keyword_pattern_str, text_lower))+ else:+ keyword_pattern = r"\b" + keyword_pattern_str + r"\b"+ keyword_found = bool(re.search(keyword_pattern, text_lower))+ if keyword_found:+ verbose_proxy_logger.debug(+ f"Always-block keyword '{keyword}' found in category '{category}'"+ )+ return (keyword, category, severity, action)+# First check if any exception appliesfor exception in exceptions:if exception in text_lower:@@ -1571,6 +1589,7 @@ class ContentFilterGuardrail(CustomGuardrail):len(self.compiled_patterns)+ len(self.blocked_words)+ len(self.category_keywords)+ + len(self.always_block_category_keywords))def _get_policy_templates(self) -> Optional[str]:diff --git a/litellm/proxy/guardrails/guardrail_hooks/litellm_content_filter/policy_templates/sg_mas_human_oversight.yaml b/litellm/proxy/guardrails/guardrail_hooks/litellm_content_filter/policy_templates/sg_mas_human_oversight.yamlindex dfca04f9013..0e9e336dbe9 100644--- a/litellm/proxy/guardrails/guardrail_hooks/litellm_content_filter/policy_templates/sg_mas_human_oversight.yaml+++ b/litellm/proxy/guardrails/guardrail_hooks/litellm_content_filter/policy_templates/sg_mas_human_oversight.yaml@@ -74,16 +74,16 @@ always_block_keywords:exceptions:- "human in the loop"- "human on the loop"- - "human review"- - "human oversight"+ - "add human review"+ - "with human review"- "manual review"- "escalation"- "appeals process"- "override mechanism"- - "explain"+ - "explain what"+ - "explain how"- "what is"- "research"- "improve oversight"- - "add human review"- "compliance"- "governance"diff --git a/litellm/proxy/guardrails/guardrail_hooks/litellm_content_filter/policy_templates/sg_mas_transparency_explainability.yaml b/litellm/proxy/guardrails/guardrail_hooks/litellm_content_filter/policy_templates/sg_mas_transparency_explainability.yamlindex 19b999729bb..0a08abd86e8 100644--- a/litellm/proxy/guardrails/guardrail_hooks/litellm_content_filter/policy_templates/sg_mas_transparency_explainability.yaml+++ b/litellm/proxy/guardrails/guardrail_hooks/litellm_content_filter/policy_templates/sg_mas_transparency_explainability.yaml@@ -73,7 +73,8 @@ exceptions:- "interpretability"- "model card"- "audit trail"- - "explain"+ - "explain what"+ - "explain how"- "what is"- "SHAP"- "LIME"