| null;
guardrail_name: string;
guardrail_status: string;
@@ -121,7 +121,8 @@ const formatMode = (mode: GuardrailInformation["guardrail_mode"]): string => {
return s.replace(/_/g, "-").toUpperCase();
};
-const formatDurationMs = (seconds: number): string => {
+const formatDurationMs = (seconds: number | null): string => {
+ if (seconds == null) return "—";
const ms = Math.round(seconds * 1000);
return `${ms}ms`;
};
@@ -364,8 +365,13 @@ interface TimelineEntry {
outcome?: EntryOutcome;
}
+type TimedGuardrailInformation = GuardrailInformation & { start_time: number; end_time: number };
+
+const isTimed = (e: GuardrailInformation): e is TimedGuardrailInformation =>
+ typeof e.start_time === "number" && typeof e.end_time === "number";
+
const RequestLifecycle = ({ entries }: { entries: GuardrailInformation[] }) => {
- const sorted = useMemo(() => [...entries].sort((a, b) => (a.start_time ?? 0) - (b.start_time ?? 0)), [entries]);
+ const sorted = useMemo(() => entries.filter(isTimed).sort((a, b) => a.start_time - b.start_time), [entries]);
const timeline = useMemo(() => {
if (sorted.length === 0) return [];
@@ -669,6 +675,10 @@ const EvaluationCard = ({ entry }: { entry: GuardrailInformation }) => {
)}
+ {outcome === "not_run" && typeof guardrailResponse === "string" && (
+ {guardrailResponse}
+ )}
+
{/* Provider-specific details */}
{guardrailProvider === "presidio" && presidioEntities.length > 0 && (
diff --git a/ui/litellm-dashboard/src/components/view_logs/GuardrailViewer/__tests__/fixtures.ts b/ui/litellm-dashboard/src/components/view_logs/GuardrailViewer/__tests__/fixtures.ts
index fe27428283d..ab121adf6b4 100644
--- a/ui/litellm-dashboard/src/components/view_logs/GuardrailViewer/__tests__/fixtures.ts
+++ b/ui/litellm-dashboard/src/components/view_logs/GuardrailViewer/__tests__/fixtures.ts
@@ -20,13 +20,13 @@ export interface GuardrailEntity {
}
export interface GuardrailInformation {
- duration: number;
- end_time: number;
- start_time: number;
+ duration: number | null;
+ end_time: number | null;
+ start_time: number | null;
guardrail_mode: string | string[] | Record | null;
guardrail_name: string;
guardrail_status: string;
- guardrail_response: GuardrailEntity[] | BedrockGuardrailResponse;
+ guardrail_response: GuardrailEntity[] | BedrockGuardrailResponse | string;
masked_entity_count: Record;
guardrail_usage?: Record;
guardrail_cost?: number;