diff --git a/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/LogDetailContent.test.tsx b/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/LogDetailContent.test.tsx index 175088ca0b9..992063fb69b 100644 --- a/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/LogDetailContent.test.tsx +++ b/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/LogDetailContent.test.tsx @@ -113,6 +113,35 @@ describe("LogDetailContent", () => { expect(screen.getAllByText("$0.00200000").length).toBeGreaterThanOrEqual(1); }); + it("should show Input Tokens and Output Tokens for anthropic_messages when uncached text_tokens exist", () => { + render( + , + ); + + expect(screen.getByText("Input Tokens")).toBeInTheDocument(); + expect(screen.getByText("Output Tokens")).toBeInTheDocument(); + expect(screen.getByText("3")).toBeInTheDocument(); + expect(screen.getByText("28")).toBeInTheDocument(); + // Combined TokenFlow line should not appear (would include "prompt tokens") + expect(screen.queryByText(/prompt tokens \+ .* completion tokens/)).not.toBeInTheDocument(); + }); + it("should display ConfigInfoMessage when no messages, response, or error and not loading", () => { render( ): number | undefined { + const raw = + metadata?.additional_usage_values?.prompt_tokens_details?.text_tokens ?? + metadata?.usage_object?.prompt_tokens_details?.text_tokens; + if (raw === undefined || raw === null) return undefined; + const n = Number(raw); + return Number.isFinite(n) ? n : undefined; +} + function MetricsSection({ logEntry, metadata }: { logEntry: LogEntry; metadata: Record }) { const completionStartTime = logEntry.completionStartTime; const ttftMs = @@ -280,17 +293,32 @@ function MetricsSection({ logEntry, metadata }: { logEntry: LogEntry; metadata: ? "red" : "default"; + const uncachedInputTokens = getUncachedInputTextTokens(metadata); + const showAnthropicMessagesInputOutput = + logEntry.call_type === "anthropic_messages" && uncachedInputTokens !== undefined; + return (
- - - + {showAnthropicMessagesInputOutput ? ( + <> + + {formatNumberWithCommas(uncachedInputTokens)} + + + {formatNumberWithCommas(logEntry.completion_tokens)} + + + ) : ( + + + + )} ${formatNumberWithCommas(logEntry.spend || 0, 8)} {logEntry.request_duration_ms != null ? (logEntry.request_duration_ms / 1000).toFixed(3) : "-"} s {ttftMs != null && ttftMs > 0 && ( diff --git a/ui/litellm-dashboard/tsconfig.json b/ui/litellm-dashboard/tsconfig.json index d24bdd340f7..5b0352feb98 100644 --- a/ui/litellm-dashboard/tsconfig.json +++ b/ui/litellm-dashboard/tsconfig.json @@ -14,7 +14,7 @@ "moduleResolution": "bundler", "resolveJsonModule": true, "isolatedModules": true, - "jsx": "react-jsx", + "jsx": "preserve", "incremental": true, "plugins": [ {