From 93595826fb6756e39f3a40995d79f9c486100b1e Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Mon, 10 Feb 2025 16:53:55 -0800 Subject: [PATCH] fix(guardrails.tsx): style improvements --- .../src/components/guardrails.tsx | 35 +++++++++++++++---- 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/ui/litellm-dashboard/src/components/guardrails.tsx b/ui/litellm-dashboard/src/components/guardrails.tsx index 19af63233cf..48ee730af33 100644 --- a/ui/litellm-dashboard/src/components/guardrails.tsx +++ b/ui/litellm-dashboard/src/components/guardrails.tsx @@ -15,6 +15,10 @@ interface GuardrailsPanelProps { accessToken: string | null; } +interface GuardrailsResponse { + guardrails: GuardrailItem[]; +} + interface GuardrailItem { name: string; mode: string; @@ -32,7 +36,10 @@ const GuardrailsPanel: React.FC = ({ accessToken }) => { const fetchGuardrails = async () => { try { const response = await getGuardrailsList(accessToken); - setGuardrailsList(response); + const data: GuardrailsResponse = await response.json(); + + setGuardrailsList(data.guardrails); + } catch (error) { console.error('Error fetching guardrails:', error); } @@ -43,8 +50,18 @@ const GuardrailsPanel: React.FC = ({ accessToken }) => { return (
+ + Configured guardrails and their current status. Setup guardrails in config.yaml.{" "} + + Docs + + - Configured guardrails and their current status. @@ -55,15 +72,21 @@ const GuardrailsPanel: React.FC = ({ accessToken }) => { - {guardrailsList.map((guardrail: GuardrailItem, index: number) => ( - + { (!guardrailsList || guardrailsList.length === 0) ? ( + + No guardrails configured + + ) : ( + guardrailsList?.map((guardrail: GuardrailItem, index: number) => ( + {guardrail.name} {guardrail.mode} {guardrail.status === 'always_on' ? 'Always On' : 'Per Request'} - - ))} + + )) + )}