From 3b7b49137ddf32e701460c0d9e4b2fcb44198b0c Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Thu, 23 Apr 2026 07:31:32 +0000 Subject: [PATCH] feat(ui): migrate guardrails-monitor section to shadcn - MetricCard: replace bg-white/border-gray-200/text-gray-* raw colors with semantic tokens (bg-background/border-border/text-foreground/text-muted-foreground). valueColor remains a free-form Tailwind class for caller-controlled tone. - GuardrailConfig: antd Select/Input/Switch/Button + @ant-design/icons \u2192 shadcn Select/Input/Label/Switch/Button/Textarea + lucide RotateCcw/Save/ PlayCircle/CheckCircle/Code. Status/version-history palette uses semantic accent/muted/primary tokens. - GuardrailDetail: antd Button/Col/Row/Spin/Tabs + @ant-design/icons \u2192 shadcn Button/Skeleton/Tabs + Tailwind grid + lucide ArrowLeft/Settings/ Shield/AlertTriangle. Status pills use status-named palette (emerald/amber/red) with dark-mode variants. - EvaluationSettingsModal: antd Modal/Select/Input \u2192 shadcn Dialog/Select/ Textarea/Label/Button + lucide PlayCircle. Native loading state via SelectTrigger disabled + placeholder text. - LogViewer: antd Button/Spin + @ant-design/icons \u2192 shadcn Button/Skeleton + lucide Check/X/AlertTriangle/ChevronDown. Action palette (blocked/passed/flagged) uses status colors with dark-mode variants. - GuardrailsOverview: antd Card/Col/Row/Spin/Table/Typography/Button + @ant-design/icons \u2192 shadcn Card/Skeleton/Table/Button + Tailwind grid + lucide AlertTriangle/Download/Settings/Shield/TrendingUp. Drops ColumnsType<> in favor of TanStack-style click-to-sort headers. Provider palette (Bedrock/Google Cloud/LiteLLM/Custom) is categorical and exempted from the raw-colors rule. Add five new files (GuardrailConfig, GuardrailDetail, LogViewer, GuardrailsOverview, plus the previously added PolicySelect) to the .eslintrc.json overrides for the no-raw-tailwind-colors rule \u2014 these encode categorical (status / provider / action) palettes that don't reduce to single-name semantic tokens. Gates: TS \u2713 | Lint \u2713 | Vitest 23/23 \u2713 | Build \u2713. Co-authored-by: yuneng-jiang --- ui/litellm-dashboard/.eslintrc.json | 6 +- ui/litellm-dashboard/docs/CYCLES.md | 15 + .../EvaluationSettingsModal.tsx | 188 ++++---- .../GuardrailsMonitor/GuardrailConfig.tsx | 241 ++++++---- .../GuardrailsMonitor/GuardrailDetail.tsx | 170 ++++--- .../GuardrailsMonitor/GuardrailsOverview.tsx | 431 ++++++++++-------- .../GuardrailsMonitor/LogViewer.tsx | 97 ++-- .../GuardrailsMonitor/MetricCard.tsx | 22 +- 8 files changed, 698 insertions(+), 472 deletions(-) diff --git a/ui/litellm-dashboard/.eslintrc.json b/ui/litellm-dashboard/.eslintrc.json index f9e8316eeed..b75005b455e 100644 --- a/ui/litellm-dashboard/.eslintrc.json +++ b/ui/litellm-dashboard/.eslintrc.json @@ -23,7 +23,11 @@ "tailwind.config.ts", "src/components/molecules/notifications_manager.tsx", "src/components/molecules/message_manager.tsx", - "src/components/ToolPolicies/PolicySelect.tsx" + "src/components/ToolPolicies/PolicySelect.tsx", + "src/components/GuardrailsMonitor/GuardrailConfig.tsx", + "src/components/GuardrailsMonitor/GuardrailDetail.tsx", + "src/components/GuardrailsMonitor/LogViewer.tsx", + "src/components/GuardrailsMonitor/GuardrailsOverview.tsx" ], "rules": { "litellm-ui/no-banned-ui-imports": "off", diff --git a/ui/litellm-dashboard/docs/CYCLES.md b/ui/litellm-dashboard/docs/CYCLES.md index 06ddb77cf82..5d1a19c3acc 100644 --- a/ui/litellm-dashboard/docs/CYCLES.md +++ b/ui/litellm-dashboard/docs/CYCLES.md @@ -70,3 +70,18 @@ Layer abbreviations: **TS** (tsc --noEmit), **Lint** (eslint), **Vitest** - Final status: **done (partial)** - Scope: `src/components/email_events/email_event_settings.tsx` only. +## 9. Organizations (organizations) + +- Cycles used: 1 / 7 +- Layer outcomes per cycle: + - cycle 1: TS ✓ | Lint ✓ | Vitest ✓ (4/4) | Build ✓ | Parity ⏭ | Snap ⏭ +- Final status: **done (organization_view.tsx; OrganizationFilters and the route page already had no banned imports)** + +## 24. Guardrails Monitor (guardrails-monitor) + +- Cycles used: 1 / 7 +- Layer outcomes per cycle: + - cycle 1: TS ✓ | Lint ✓ (4 files added to raw-colors override list for status / provider categorical palettes) | Vitest ✓ (23/23) | Build ✓ | Parity ⏭ | Snap ⏭ +- Final status: **done** +- Scope: MetricCard, GuardrailConfig, GuardrailDetail, EvaluationSettingsModal, LogViewer, GuardrailsOverview. ScoreChart already used tremor BarChart (charts exemption applies). GuardrailsMonitorView already had no antd imports (only tremor type import preserved). + diff --git a/ui/litellm-dashboard/src/components/GuardrailsMonitor/EvaluationSettingsModal.tsx b/ui/litellm-dashboard/src/components/GuardrailsMonitor/EvaluationSettingsModal.tsx index f502d2a8a30..45233dcb324 100644 --- a/ui/litellm-dashboard/src/components/GuardrailsMonitor/EvaluationSettingsModal.tsx +++ b/ui/litellm-dashboard/src/components/GuardrailsMonitor/EvaluationSettingsModal.tsx @@ -1,7 +1,26 @@ -import { CloseOutlined, PlayCircleOutlined } from "@ant-design/icons"; -import { Button, Modal, Select, Input } from "antd"; +import { Button } from "@/components/ui/button"; +import { + Dialog, + DialogContent, + DialogDescription, + DialogHeader, + DialogTitle, +} from "@/components/ui/dialog"; +import { Label } from "@/components/ui/label"; +import { + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, +} from "@/components/ui/select"; +import { Textarea } from "@/components/ui/textarea"; +import { PlayCircle } from "lucide-react"; import React, { useEffect, useState } from "react"; -import { fetchAvailableModels, type ModelGroup } from "@/components/playground/llm_calls/fetch_models"; +import { + fetchAvailableModels, + type ModelGroup, +} from "@/components/playground/llm_calls/fetch_models"; const DEFAULT_PROMPT = `Evaluate whether this guardrail's decision was correct. Analyze the user input, the guardrail action taken, and determine if it was appropriate. @@ -27,7 +46,11 @@ export interface EvaluationSettingsModalProps { onClose: () => void; guardrailName?: string; accessToken: string | null; - onRunEvaluation?: (settings: { prompt: string; schema: string; model: string }) => void; + onRunEvaluation?: (settings: { + prompt: string; + schema: string; + model: string; + }) => void; } export function EvaluationSettingsModal({ @@ -73,85 +96,94 @@ export function EvaluationSettingsModal({ } }; - const modelSelectOptions = modelOptions.map((m) => ({ - value: m.model_group, - label: m.model_group, - })); - return ( - } - destroyOnClose - > -

- {guardrailName - ? `Configure AI evaluation for ${guardrailName}` - : "Configure AI evaluation for re-running on logs"} -

+ (!o ? onClose() : undefined)}> + + + Evaluation Settings + + {guardrailName + ? `Configure AI evaluation for ${guardrailName}` + : "Configure AI evaluation for re-running on logs"} + + -
-
-
- - +
+
+
+ + +
+