This commit is contained in:
Ishaan Jaffer 2026-02-17 18:19:26 -08:00
parent 71a5f00e5d
commit 179397d273
3 changed files with 32 additions and 8 deletions

View file

@ -5,6 +5,7 @@ import BedrockGuardrailDetails, {
BedrockGuardrailResponse,
} from "@/components/view_logs/GuardrailViewer/BedrockGuardrailDetails";
import ContentFilterDetails from "./ContentFilterDetails";
import CompliancePanel from "./CompliancePanel";
// ── Interfaces ──────────────────────────────────────────────────────────────
@ -58,6 +59,14 @@ interface GuardrailInformation {
interface GuardrailViewerProps {
data: GuardrailInformation | GuardrailInformation[];
accessToken?: string | null;
logEntry?: {
request_id: string;
user?: string;
model?: string;
startTime?: string;
metadata?: Record<string, any>;
};
}
// ── Helpers ─────────────────────────────────────────────────────────────────
@ -585,7 +594,7 @@ const EvaluationCard = ({ entry }: { entry: GuardrailInformation }) => {
// ── Main Component ──────────────────────────────────────────────────────────
const GuardrailViewer = ({ data }: GuardrailViewerProps) => {
const GuardrailViewer = ({ data, accessToken, logEntry }: GuardrailViewerProps) => {
const guardrailEntries = useMemo(() => {
return Array.isArray(data)
? data.filter((entry): entry is GuardrailInformation => Boolean(entry))
@ -659,11 +668,6 @@ const GuardrailViewer = ({ data }: GuardrailViewerProps) => {
<div className="text-sm font-medium text-gray-900">
Total: {totalOverheadMs}ms overhead
</div>
{policyTemplates.length > 0 && (
<div className="text-xs text-gray-500 mt-0.5">
Policy: {policyTemplates.join(" / ")}
</div>
)}
</div>
<button
@ -676,6 +680,13 @@ const GuardrailViewer = ({ data }: GuardrailViewerProps) => {
</div>
</div>
{/* ── Compliance Panel ──────────────────────────────────── */}
{accessToken && logEntry && (
<div className="px-6 py-4 border-b border-gray-100">
<CompliancePanel accessToken={accessToken} logEntry={logEntry} />
</div>
)}
{/* ── Body: two columns ──────────────────────────────────── */}
<div className="flex">
{/* Left column: Request Lifecycle */}

View file

@ -4,6 +4,7 @@ import moment from "moment";
import { LogEntry } from "../columns";
import { formatNumberWithCommas } from "@/utils/dataUtils";
import GuardrailViewer from "../GuardrailViewer/GuardrailViewer";
import CompliancePanel from "../GuardrailViewer/CompliancePanel";
import { CostBreakdownViewer } from "../CostBreakdownViewer";
import { ConfigInfoMessage } from "../ConfigInfoMessage";
import { VectorStoreViewer } from "../VectorStoreViewer";
@ -40,6 +41,7 @@ export interface LogDetailContentProps {
onOpenSettings?: () => void;
/** When true, log details (messages/response) are still being lazy-loaded. */
isLoadingDetails?: boolean;
accessToken?: string | null;
}
/**
@ -50,7 +52,7 @@ export interface LogDetailContentProps {
* Designed to be placed inside LogDetailsDrawer's right panel so it can
* be reused for both single-log and session-mode views.
*/
export function LogDetailContent({ logEntry, onOpenSettings, isLoadingDetails = false }: LogDetailContentProps) {
export function LogDetailContent({ logEntry, onOpenSettings, isLoadingDetails = false, accessToken }: LogDetailContentProps) {
const metadata = logEntry.metadata || {};
const hasError = metadata.status === "failure";
const errorInfo = hasError ? metadata.error_information : null;
@ -166,7 +168,17 @@ export function LogDetailContent({ logEntry, onOpenSettings, isLoadingDetails =
{/* Guardrail Data */}
{hasGuardrailData && (
<div id="guardrail-section">
<GuardrailViewer data={guardrailInfo} />
<GuardrailViewer
data={guardrailInfo}
accessToken={accessToken ?? null}
logEntry={{
request_id: logEntry.request_id,
user: logEntry.user,
model: logEntry.model,
startTime: logEntry.startTime,
metadata: logEntry.metadata,
}}
/>
</div>
)}

View file

@ -384,6 +384,7 @@ export function LogDetailsDrawer({
logEntry={enrichedLog}
onOpenSettings={onOpenSettings}
isLoadingDetails={isLoadingDetails}
accessToken={accessToken ?? null}
/>
</div>
</div>