diff --git a/src/app/[locale]/dashboard/logs/_components/error-details-dialog.tsx b/src/app/[locale]/dashboard/logs/_components/error-details-dialog.tsx index d05fa4148..f420880dc 100644 --- a/src/app/[locale]/dashboard/logs/_components/error-details-dialog.tsx +++ b/src/app/[locale]/dashboard/logs/_components/error-details-dialog.tsx @@ -380,7 +380,7 @@ export function ErrorDetailsDialog({ {formatTokenAmount(outputTokens)} tokens - {cacheCreation5mInputTokens && cacheCreation5mInputTokens > 0 && ( + {(cacheCreation5mInputTokens ?? 0) > 0 && (
{t("logs.billingDetails.cacheWrite5m")}: @@ -391,7 +391,7 @@ export function ErrorDetailsDialog({
)} - {cacheCreation1hInputTokens && cacheCreation1hInputTokens > 0 && ( + {(cacheCreation1hInputTokens ?? 0) > 0 && (
{t("logs.billingDetails.cacheWrite1h")}: @@ -402,7 +402,7 @@ export function ErrorDetailsDialog({
)} - {cacheReadInputTokens && cacheReadInputTokens > 0 && ( + {(cacheReadInputTokens ?? 0) > 0 && (
{t("logs.billingDetails.cacheRead")}: diff --git a/src/app/[locale]/dashboard/logs/_components/usage-logs-table.tsx b/src/app/[locale]/dashboard/logs/_components/usage-logs-table.tsx index c9c23180d..f51f54138 100644 --- a/src/app/[locale]/dashboard/logs/_components/usage-logs-table.tsx +++ b/src/app/[locale]/dashboard/logs/_components/usage-logs-table.tsx @@ -277,22 +277,19 @@ export function UsageLogsTable({ {t("logs.billingDetails.output")}:{" "} {formatTokenAmount(log.outputTokens)} tokens
- {log.cacheCreation5mInputTokens && - log.cacheCreation5mInputTokens > 0 && ( -
- {t("logs.billingDetails.cacheWrite5m")}:{" "} - {formatTokenAmount(log.cacheCreation5mInputTokens)} tokens - (1.25x) -
- )} - {log.cacheCreation1hInputTokens && - log.cacheCreation1hInputTokens > 0 && ( -
- {t("logs.billingDetails.cacheWrite1h")}:{" "} - {formatTokenAmount(log.cacheCreation1hInputTokens)} tokens (2x) -
- )} - {log.cacheReadInputTokens && log.cacheReadInputTokens > 0 && ( + {(log.cacheCreation5mInputTokens ?? 0) > 0 && ( +
+ {t("logs.billingDetails.cacheWrite5m")}:{" "} + {formatTokenAmount(log.cacheCreation5mInputTokens)} tokens (1.25x) +
+ )} + {(log.cacheCreation1hInputTokens ?? 0) > 0 && ( +
+ {t("logs.billingDetails.cacheWrite1h")}:{" "} + {formatTokenAmount(log.cacheCreation1hInputTokens)} tokens (2x) +
+ )} + {(log.cacheReadInputTokens ?? 0) > 0 && (
{t("logs.billingDetails.cacheRead")}:{" "} {formatTokenAmount(log.cacheReadInputTokens)} tokens (0.1x) diff --git a/src/app/v1/_lib/proxy/response-handler.ts b/src/app/v1/_lib/proxy/response-handler.ts index d4f2e204a..4a4725a49 100644 --- a/src/app/v1/_lib/proxy/response-handler.ts +++ b/src/app/v1/_lib/proxy/response-handler.ts @@ -353,6 +353,9 @@ export class ProxyResponseHandler { outputTokens: usageMetrics?.output_tokens, cacheCreationInputTokens: usageMetrics?.cache_creation_input_tokens, cacheReadInputTokens: usageMetrics?.cache_read_input_tokens, + cacheCreation5mInputTokens: usageMetrics?.cache_creation_5m_input_tokens, + cacheCreation1hInputTokens: usageMetrics?.cache_creation_1h_input_tokens, + cacheTtlApplied: usageMetrics?.cache_ttl ?? null, providerChain: session.getProviderChain(), model: session.getCurrentModel() ?? undefined, // ⭐ 更新重定向后的模型 providerId: session.provider?.id, // ⭐ 更新最终供应商ID(重试切换后) @@ -897,6 +900,9 @@ export class ProxyResponseHandler { outputTokens: usageForCost?.output_tokens, cacheCreationInputTokens: usageForCost?.cache_creation_input_tokens, cacheReadInputTokens: usageForCost?.cache_read_input_tokens, + cacheCreation5mInputTokens: usageForCost?.cache_creation_5m_input_tokens, + cacheCreation1hInputTokens: usageForCost?.cache_creation_1h_input_tokens, + cacheTtlApplied: usageForCost?.cache_ttl ?? null, providerChain: session.getProviderChain(), model: session.getCurrentModel() ?? undefined, // ⭐ 更新重定向后的模型 providerId: session.provider?.id, // ⭐ 更新最终供应商ID(重试切换后) @@ -1107,7 +1113,10 @@ export class ProxyResponseHandler { try { reader.releaseLock(); } catch (releaseError) { - logger.warn("Failed to release reader lock", { taskId, releaseError }); + logger.warn("Failed to release reader lock", { + taskId, + releaseError, + }); } AsyncTaskManager.cleanup(taskId); } @@ -1422,7 +1431,9 @@ async function updateRequestCostFromUsage( costMultiplier: number = 1.0 ): Promise { if (!usage) { - logger.warn("[CostCalculation] No usage data, skipping cost update", { messageId }); + logger.warn("[CostCalculation] No usage data, skipping cost update", { + messageId, + }); return; }