diff --git a/frontend/src/i18n/locales/en.ts b/frontend/src/i18n/locales/en.ts index 16ff379e..b9420eab 100644 --- a/frontend/src/i18n/locales/en.ts +++ b/frontend/src/i18n/locales/en.ts @@ -266,6 +266,8 @@ export default { sync: 'Sync', in: 'In', out: 'Out', + cacheRead: 'Read', + cacheWrite: 'Write', rate: 'Rate', original: 'Original', billed: 'Billed', diff --git a/frontend/src/i18n/locales/zh.ts b/frontend/src/i18n/locales/zh.ts index f80b5c89..0e2e9ec5 100644 --- a/frontend/src/i18n/locales/zh.ts +++ b/frontend/src/i18n/locales/zh.ts @@ -266,6 +266,8 @@ export default { sync: '同步', in: '输入', out: '输出', + cacheRead: '读取', + cacheWrite: '写入', rate: '倍率', original: '原始', billed: '计费', diff --git a/frontend/src/views/admin/UsageView.vue b/frontend/src/views/admin/UsageView.vue index d0aec771..5c5a69c7 100644 --- a/frontend/src/views/admin/UsageView.vue +++ b/frontend/src/views/admin/UsageView.vue @@ -194,17 +194,40 @@ @@ -457,6 +480,16 @@ const formatTokens = (value: number): string => { return value.toLocaleString() } +// Compact format for cache tokens in table cells +const formatCacheTokens = (value: number): string => { + if (value >= 1_000_000) { + return `${(value / 1_000_000).toFixed(1)}M` + } else if (value >= 1_000) { + return `${(value / 1_000).toFixed(1)}K` + } + return value.toLocaleString() +} + const formatDateTime = (dateString: string): string => { const date = new Date(dateString) return date.toLocaleString('en-US', { @@ -537,7 +570,7 @@ const exportToCSV = () => { return } - const headers = ['User', 'API Key', 'Model', 'Type', 'Input Tokens', 'Output Tokens', 'Cache Tokens', 'Total Cost', 'Billing Type', 'Duration (ms)', 'Time'] + const headers = ['User', 'API Key', 'Model', 'Type', 'Input Tokens', 'Output Tokens', 'Cache Read Tokens', 'Cache Write Tokens', 'Total Cost', 'Billing Type', 'Duration (ms)', 'Time'] const rows = usageLogs.value.map(log => [ log.user?.email || '', log.api_key?.name || '', @@ -546,6 +579,7 @@ const exportToCSV = () => { log.input_tokens, log.output_tokens, log.cache_read_tokens, + log.cache_creation_tokens, log.total_cost.toFixed(6), log.billing_type === 1 ? 'Subscription' : 'Balance', log.duration_ms, diff --git a/frontend/src/views/user/UsageView.vue b/frontend/src/views/user/UsageView.vue index eda1f021..c8c40b9d 100644 --- a/frontend/src/views/user/UsageView.vue +++ b/frontend/src/views/user/UsageView.vue @@ -137,17 +137,40 @@ @@ -331,6 +354,16 @@ const formatTokens = (value: number): string => { return value.toLocaleString() } +// Compact format for cache tokens in table cells +const formatCacheTokens = (value: number): string => { + if (value >= 1_000_000) { + return `${(value / 1_000_000).toFixed(1)}M` + } else if (value >= 1_000) { + return `${(value / 1_000).toFixed(1)}K` + } + return value.toLocaleString() +} + const formatDateTime = (dateString: string): string => { const date = new Date(dateString) return date.toLocaleString('en-US', { @@ -415,13 +448,14 @@ const exportToCSV = () => { return } - const headers = ['Model', 'Type', 'Input Tokens', 'Output Tokens', 'Cache Tokens', 'Total Cost', 'Billing Type', 'First Token (ms)', 'Duration (ms)', 'Time'] + const headers = ['Model', 'Type', 'Input Tokens', 'Output Tokens', 'Cache Read Tokens', 'Cache Write Tokens', 'Total Cost', 'Billing Type', 'First Token (ms)', 'Duration (ms)', 'Time'] const rows = usageLogs.value.map(log => [ log.model, log.stream ? 'Stream' : 'Sync', log.input_tokens, log.output_tokens, log.cache_read_tokens, + log.cache_creation_tokens, log.total_cost.toFixed(6), log.billing_type === 1 ? 'Subscription' : 'Balance', log.first_token_ms ?? '',