Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

addressing comments

yuneng-jiangb65cb646aa99
diff --git a/ui/litellm-dashboard/src/components/view_logs/CostBreakdownViewer.tsx b/ui/litellm-dashboard/src/components/view_logs/CostBreakdownViewer.tsx
index 6c6b72d345d..087863e9478 100644
--- a/ui/litellm-dashboard/src/components/view_logs/CostBreakdownViewer.tsx
+++ b/ui/litellm-dashboard/src/components/view_logs/CostBreakdownViewer.tsx
@@ -21,6 +21,7 @@ interface CostBreakdownViewerProps {
totalSpend: number;
promptTokens?: number;
completionTokens?: number;
+ cacheHit?: string;
}
const formatCost = (cost: number | undefined): string => {
@@ -38,11 +39,11 @@ export const CostBreakdownViewer: React.FC<CostBreakdownViewerProps> = ({
totalSpend,
promptTokens,
completionTokens,
+ cacheHit,
}) => {
- const isCached = totalSpend === 0;
+ const isCached = cacheHit?.toLowerCase() === "true";
const hasTokenCounts = promptTokens !== undefined || completionTokens !== undefined;
- // When cached, show if we have token counts; otherwise need costBreakdown with meaningful data
const hasCostBreakdown = costBreakdown?.input_cost !== undefined || costBreakdown?.output_cost !== undefined;
const hasMeaningfulData =
hasCostBreakdown ||
@@ -54,7 +55,7 @@ export const CostBreakdownViewer: React.FC<CostBreakdownViewerProps> = ({
(costBreakdown.margin_fixed_amount !== undefined && costBreakdown.margin_fixed_amount !== 0) ||
(costBreakdown.margin_total_amount !== undefined && costBreakdown.margin_total_amount !== 0)));
- if (!hasMeaningfulData && !(isCached && hasTokenCounts)) {
+ if (!hasMeaningfulData) {
return null;
}
diff --git a/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/LogDetailContent.tsx b/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/LogDetailContent.tsx
index fcc0c25daac..91233f28536 100644
--- a/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/LogDetailContent.tsx
+++ b/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/LogDetailContent.tsx
@@ -140,6 +140,7 @@ export function LogDetailContent({ logEntry, onOpenSettings, isLoadingDetails =
totalSpend={logEntry.spend ?? 0}
promptTokens={logEntry.prompt_tokens}
completionTokens={logEntry.completion_tokens}
+ cacheHit={logEntry.cache_hit}
/>
{/* Tools */}
@@ -329,25 +330,18 @@ function RequestResponseSection({
const totalTokens = promptTokens + completionTokens;
const costBreakdown = logEntry.metadata?.cost_breakdown;
const useCostBreakdown =
- totalSpend > 0 &&
costBreakdown?.input_cost !== undefined &&
costBreakdown?.output_cost !== undefined;
- const inputCost =
- totalSpend === 0
- ? 0
- : useCostBreakdown
- ? (costBreakdown!.input_cost ?? 0)
- : totalTokens > 0
- ? (totalSpend * promptTokens) / totalTokens
- : 0;
- const outputCost =
- totalSpend === 0
- ? 0
- : useCostBreakdown
- ? (costBreakdown!.output_cost ?? 0)
- : totalTokens > 0
- ? (totalSpend * completionTokens) / totalTokens
- : 0;
+ const inputCost = useCostBreakdown
+ ? (costBreakdown!.input_cost ?? 0)
+ : totalTokens > 0
+ ? (totalSpend * promptTokens) / totalTokens
+ : 0;
+ const outputCost = useCostBreakdown
+ ? (costBreakdown!.output_cost ?? 0)
+ : totalTokens > 0
+ ? (totalSpend * completionTokens) / totalTokens
+ : 0;
return (
<div className="bg-white rounded-lg shadow w-full max-w-full overflow-hidden mb-6">
diff --git a/ui/litellm-dashboard/src/components/view_logs/index.tsx b/ui/litellm-dashboard/src/components/view_logs/index.tsx
index d83b99b9306..12cafcc6f6d 100644
--- a/ui/litellm-dashboard/src/components/view_logs/index.tsx
+++ b/ui/litellm-dashboard/src/components/view_logs/index.tsx
@@ -961,6 +961,7 @@ export function RequestViewer({ row, onOpenSettings }: { row: Row<LogEntry>; onO
totalSpend={row.original.spend ?? 0}
promptTokens={row.original.prompt_tokens}
completionTokens={row.original.completion_tokens}
+ cacheHit={row.original.cache_hit}
/>
{/* Configuration Info Message - Show when data is missing */}