From e336434b27be43b5de967032dd174f884c9be1d7 Mon Sep 17 00:00:00 2001 From: yuneng-jiang Date: Sun, 2 Nov 2025 09:05:00 -0800 Subject: [PATCH] [Feature] UI - Guardrail Info Page Show PII Config (#16164) * Guardrail info page fix * Make the Configurations more readable and render in a table --- .../guardrails/guardrail_info.test.tsx | 37 ++++++++++++++++ .../components/guardrails/guardrail_info.tsx | 44 ++++++++++++------- 2 files changed, 66 insertions(+), 15 deletions(-) diff --git a/ui/litellm-dashboard/src/components/guardrails/guardrail_info.test.tsx b/ui/litellm-dashboard/src/components/guardrails/guardrail_info.test.tsx index 301045103bc..bd2b45d6f34 100644 --- a/ui/litellm-dashboard/src/components/guardrails/guardrail_info.test.tsx +++ b/ui/litellm-dashboard/src/components/guardrails/guardrail_info.test.tsx @@ -110,4 +110,41 @@ describe("Guardrail Info", () => { }); } }); + + it("should render the guardrail info", async () => { + // Mock the network responses + vi.mocked(networking.getGuardrailInfo).mockResolvedValue({ + guardrail_id: "123", + guardrail_name: "Test Guardrail", + litellm_params: { + guardrail: "presidio", + mode: "pre_call", + default_on: true, + pii_entities_config: { + PERSON: "MASK", + EMAIL: "REDACT", + }, + }, + created_at: "2024-01-01T00:00:00Z", + updated_at: "2024-01-01T00:00:00Z", + guardrail_definition_location: "database", + }); + + vi.mocked(networking.getGuardrailUISettings).mockResolvedValue({ + supported_entities: ["PERSON", "EMAIL"], + supported_actions: ["MASK", "REDACT"], + pii_entity_categories: [], + supported_modes: ["pre_call", "post_call"], + }); + + vi.mocked(networking.getGuardrailProviderSpecificParams).mockResolvedValue({}); + + const { getByText } = render( + {}} accessToken="123" isAdmin={true} />, + ); + + await waitFor(() => { + expect(getByText("PII Entity Configuration")).toBeInTheDocument(); + }); + }); }); diff --git a/ui/litellm-dashboard/src/components/guardrails/guardrail_info.tsx b/ui/litellm-dashboard/src/components/guardrails/guardrail_info.tsx index d783108de3c..d314cbc5ebe 100644 --- a/ui/litellm-dashboard/src/components/guardrails/guardrail_info.tsx +++ b/ui/litellm-dashboard/src/components/guardrails/guardrail_info.tsx @@ -14,7 +14,7 @@ import { TextInput, } from "@tremor/react"; import { Button, Form, Input, Select, Divider, Tooltip } from "antd"; -import { InfoCircleOutlined } from "@ant-design/icons"; +import { InfoCircleOutlined, EyeInvisibleOutlined, StopOutlined } from "@ant-design/icons"; import { getGuardrailInfo, updateGuardrailCall, @@ -414,21 +414,35 @@ const GuardrailInfoView: React.FC = ({ guardrailId, onClose, )} - {guardrailData.guardrail_info && Object.keys(guardrailData.guardrail_info).length > 0 && ( - - Guardrail Info -
- {Object.entries(guardrailData.guardrail_info).map(([key, value]) => ( -
- {key} - - {typeof value === "object" ? JSON.stringify(value, null, 2) : String(value)} - + {guardrailData.litellm_params?.pii_entities_config && + Object.keys(guardrailData.litellm_params.pii_entities_config).length > 0 && ( + + PII Entity Configuration +
+
+ Entity Type + Configuration
- ))} -
-
- )} +
+ {Object.entries(guardrailData.litellm_params?.pii_entities_config).map(([key, value]) => ( +
+ {key} + + + {value === "MASK" ? : } + {String(value)} + + +
+ ))} +
+
+ + )} {/* Settings Panel (only for admins) */}