Skip to content

Commit 5eff9f6

Browse files
committed
added tooltip for guardrail failure state
1 parent 5b080e2 commit 5eff9f6

File tree

1 file changed

+33
-20
lines changed

1 file changed

+33
-20
lines changed

ui/litellm-dashboard/src/components/view_logs/GuardrailViewer/GuardrailViewer.tsx

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import React, { useState } from "react";
2+
import { Tooltip } from "antd";
23
import PresidioDetectedEntities from "./PresidioDetectedEntities";
34
import BedrockGuardrailDetails, {
45
BedrockGuardrailResponse,
5-
} from "@/components/view_logs/GuardrailViewer/BedrockGuardrailDetails"
6+
} from "@/components/view_logs/GuardrailViewer/BedrockGuardrailDetails";
67

78
interface RecognitionMetadata {
89
recognizer_name: string;
@@ -44,9 +45,13 @@ const GuardrailViewer = ({ data }: GuardrailViewerProps) => {
4445
// Default to presidio for backwards compatibility
4546
const guardrailProvider = data.guardrail_provider ?? "presidio";
4647

47-
if (!data) {
48-
return null;
49-
}
48+
if (!data) return null;
49+
50+
const isSuccess =
51+
typeof data.guardrail_status === "string" &&
52+
data.guardrail_status.toLowerCase() === "success";
53+
54+
const tooltipTitle = isSuccess ? null : "Guardrail failed to run.";
5055

5156
// Calculate total masked entities
5257
const totalMaskedEntities = data.masked_entity_count ?
@@ -73,13 +78,18 @@ const GuardrailViewer = ({ data }: GuardrailViewerProps) => {
7378
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M9 5l7 7-7 7" />
7479
</svg>
7580
<h3 className="text-lg font-medium">Guardrail Information</h3>
76-
<span className={`ml-3 px-2 py-1 rounded-md text-xs font-medium inline-block ${
77-
data.guardrail_status === "success"
78-
? 'bg-green-100 text-green-800'
79-
: 'bg-red-100 text-red-800'
80-
}`}>
81-
{data.guardrail_status}
82-
</span>
81+
82+
{/* Header status chip with tooltip */}
83+
<Tooltip title={tooltipTitle} placement="top" arrow destroyTooltipOnHide>
84+
<span
85+
className={`ml-3 px-2 py-1 rounded-md text-xs font-medium inline-block ${
86+
isSuccess ? "bg-green-100 text-green-800" : "bg-red-100 text-red-800 cursor-help"
87+
}`}
88+
>
89+
{data.guardrail_status}
90+
</span>
91+
</Tooltip>
92+
8393
{totalMaskedEntities > 0 && (
8494
<span className="ml-3 px-2 py-1 bg-blue-50 text-blue-700 rounded-md text-xs font-medium">
8595
{totalMaskedEntities} masked {totalMaskedEntities === 1 ? 'entity' : 'entities'}
@@ -104,15 +114,18 @@ const GuardrailViewer = ({ data }: GuardrailViewerProps) => {
104114
</div>
105115
<div className="flex">
106116
<span className="font-medium w-1/3">Status:</span>
107-
<span className={`px-2 py-1 rounded-md text-xs font-medium inline-block ${
108-
data.guardrail_status === "success"
109-
? 'bg-green-100 text-green-800'
110-
: 'bg-red-100 text-red-800'
111-
}`}>
112-
{data.guardrail_status}
113-
</span>
117+
<Tooltip title={tooltipTitle} placement="top" arrow destroyTooltipOnHide>
118+
<span
119+
className={`px-2 py-1 rounded-md text-xs font-medium inline-block ${
120+
isSuccess ? "bg-green-100 text-green-800" : "bg-red-100 text-red-800 cursor-help"
121+
}`}
122+
>
123+
{data.guardrail_status}
124+
</span>
125+
</Tooltip>
114126
</div>
115127
</div>
128+
116129
<div className="space-y-2">
117130
<div className="flex">
118131
<span className="font-medium w-1/3">Start Time:</span>
@@ -158,6 +171,6 @@ const GuardrailViewer = ({ data }: GuardrailViewerProps) => {
158171
)}
159172
</div>
160173
);
161-
}
174+
};
162175

163-
export default GuardrailViewer;
176+
export default GuardrailViewer;

0 commit comments

Comments
 (0)