mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-09 22:31:41 +00:00
addressing comments
This commit is contained in:
parent
938a920372
commit
b65cb646aa
3 changed files with 16 additions and 20 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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">
|
||||
|
|
|
|||
|
|
@ -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 */}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue