mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-07 02:59:05 +00:00
fix(add_guardrail_form.tsx): add validation check to prevent adding empty content filter guardrails
This commit is contained in:
parent
a12d67deff
commit
472546289a
1 changed files with 9 additions and 0 deletions
|
|
@ -324,6 +324,15 @@ const AddGuardrailForm: React.FC<AddGuardrailFormProps> = ({ visible, onClose, a
|
|||
|
||||
// For Content Filter, add patterns, blocked words, and categories
|
||||
if (shouldRenderContentFilterConfigSettings(values.provider)) {
|
||||
// Validate that at least one content filter setting is configured
|
||||
if (selectedPatterns.length === 0 && blockedWords.length === 0 && selectedContentCategories.length === 0) {
|
||||
NotificationsManager.fromBackend(
|
||||
"Please configure at least one content filter setting (category, pattern, or keyword)"
|
||||
);
|
||||
setLoading(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (selectedPatterns.length > 0) {
|
||||
guardrailData.litellm_params.patterns = selectedPatterns.map((p) => ({
|
||||
pattern_type: p.type === "prebuilt" ? "prebuilt" : "regex",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue