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]

fix: ensure guardrail patterns persist on edit and mode toggle

naaa760fc4c104f77b4
diff --git a/ui/litellm-dashboard/src/components/guardrails/guardrail_info.tsx b/ui/litellm-dashboard/src/components/guardrails/guardrail_info.tsx
index 0d1a205f66f..29c2e7d13ee 100644
--- a/ui/litellm-dashboard/src/components/guardrails/guardrail_info.tsx
+++ b/ui/litellm-dashboard/src/components/guardrails/guardrail_info.tsx
@@ -270,23 +270,15 @@ const GuardrailInfoView: React.FC<GuardrailInfoProps> = ({ guardrailId, onClose,
updateData.litellm_params.pii_entities_config = newPiiEntitiesConfig;
}
- // Only add Content Filter patterns if there are changes
+ // Always include Content Filter patterns to ensure they persist when other fields change
if (guardrailData.litellm_params?.guardrail === "litellm_content_filter") {
- const originalPatterns = guardrailData.litellm_params?.patterns || [];
- const originalBlockedWords = guardrailData.litellm_params?.blocked_words || [];
-
const formattedData = formatContentFilterDataForAPI(
- contentFilterDataRef.current.patterns,
- contentFilterDataRef.current.blockedWords,
+ contentFilterDataRef.current.patterns || [],
+ contentFilterDataRef.current.blockedWords || [],
);
- if (JSON.stringify(originalPatterns) !== JSON.stringify(formattedData.patterns)) {
- updateData.litellm_params.patterns = formattedData.patterns;
- }
-
- if (JSON.stringify(originalBlockedWords) !== JSON.stringify(formattedData.blocked_words)) {
- updateData.litellm_params.blocked_words = formattedData.blocked_words;
- }
+ updateData.litellm_params.patterns = formattedData.patterns;
+ updateData.litellm_params.blocked_words = formattedData.blocked_words;
}
if (guardrailData.litellm_params?.guardrail === "tool_permission") {