@@ -15,6 +15,10 @@ interface GuardrailsPanelProps {
15
15
accessToken : string | null ;
16
16
}
17
17
18
+ interface GuardrailsResponse {
19
+ guardrails : GuardrailItem [ ] ;
20
+ }
21
+
18
22
interface GuardrailItem {
19
23
name : string ;
20
24
mode : string ;
@@ -32,7 +36,10 @@ const GuardrailsPanel: React.FC<GuardrailsPanelProps> = ({ accessToken }) => {
32
36
const fetchGuardrails = async ( ) => {
33
37
try {
34
38
const response = await getGuardrailsList ( accessToken ) ;
35
- setGuardrailsList ( response ) ;
39
+ const data : GuardrailsResponse = await response . json ( ) ;
40
+
41
+ setGuardrailsList ( data . guardrails ) ;
42
+
36
43
} catch ( error ) {
37
44
console . error ( 'Error fetching guardrails:' , error ) ;
38
45
}
@@ -43,8 +50,18 @@ const GuardrailsPanel: React.FC<GuardrailsPanelProps> = ({ accessToken }) => {
43
50
44
51
return (
45
52
< div className = "w-full mx-auto flex-auto overflow-y-auto m-8 p-2" >
53
+ < Text className = "mb-4" >
54
+ Configured guardrails and their current status. Setup guardrails in config.yaml.{ " " }
55
+ < a
56
+ href = "https://docs.litellm.ai/docs/proxy/guardrails/quick_start"
57
+ target = "_blank"
58
+ rel = "noopener noreferrer"
59
+ className = "text-blue-500 hover:text-blue-700 underline"
60
+ >
61
+ Docs
62
+ </ a >
63
+ </ Text >
46
64
< Card >
47
- < Text > Configured guardrails and their current status.</ Text >
48
65
< Table >
49
66
< TableHead >
50
67
< TableRow >
@@ -55,15 +72,21 @@ const GuardrailsPanel: React.FC<GuardrailsPanelProps> = ({ accessToken }) => {
55
72
</ TableHead >
56
73
57
74
< TableBody >
58
- { guardrailsList . map ( ( guardrail : GuardrailItem , index : number ) => (
59
- < TableRow key = { index } >
75
+ { ( ! guardrailsList || guardrailsList . length === 0 ) ? (
76
+ < TableRow >
77
+ < TableCell colSpan = { 3 } className = "mt-4 text-gray-500 text-center py-4" > No guardrails configured</ TableCell >
78
+ </ TableRow >
79
+ ) : (
80
+ guardrailsList ?. map ( ( guardrail : GuardrailItem , index : number ) => (
81
+ < TableRow key = { index } >
60
82
< TableCell > { guardrail . name } </ TableCell >
61
83
< TableCell > { guardrail . mode } </ TableCell >
62
84
< TableCell >
63
85
{ guardrail . status === 'always_on' ? 'Always On' : 'Per Request' }
64
86
</ TableCell >
65
- </ TableRow >
66
- ) ) }
87
+ </ TableRow >
88
+ ) )
89
+ ) }
67
90
</ TableBody >
68
91
</ Table >
69
92
</ Card >
0 commit comments