fix: Cache Token拆分为缓存创建和缓存读取
This commit is contained in:
@@ -63,7 +63,8 @@ const chartColors = computed(() => ({
|
||||
grid: isDarkMode.value ? '#374151' : '#e5e7eb',
|
||||
input: '#3b82f6',
|
||||
output: '#10b981',
|
||||
cache: '#f59e0b'
|
||||
cacheCreation: '#f59e0b',
|
||||
cacheRead: '#06b6d4'
|
||||
}))
|
||||
|
||||
const chartData = computed(() => {
|
||||
@@ -89,10 +90,18 @@ const chartData = computed(() => {
|
||||
tension: 0.3
|
||||
},
|
||||
{
|
||||
label: 'Cache',
|
||||
data: props.trendData.map((d) => d.cache_tokens),
|
||||
borderColor: chartColors.value.cache,
|
||||
backgroundColor: `${chartColors.value.cache}20`,
|
||||
label: 'Cache Creation',
|
||||
data: props.trendData.map((d) => d.cache_creation_tokens),
|
||||
borderColor: chartColors.value.cacheCreation,
|
||||
backgroundColor: `${chartColors.value.cacheCreation}20`,
|
||||
fill: true,
|
||||
tension: 0.3
|
||||
},
|
||||
{
|
||||
label: 'Cache Read',
|
||||
data: props.trendData.map((d) => d.cache_read_tokens),
|
||||
borderColor: chartColors.value.cacheRead,
|
||||
backgroundColor: `${chartColors.value.cacheRead}20`,
|
||||
fill: true,
|
||||
tension: 0.3
|
||||
}
|
||||
|
||||
@@ -133,6 +133,8 @@ export default {
|
||||
requests: 'Requests',
|
||||
inputTokens: 'Input Tokens',
|
||||
outputTokens: 'Output Tokens',
|
||||
cacheCreationTokens: 'Cache Creation',
|
||||
cacheReadTokens: 'Cache Read',
|
||||
totalTokens: 'Total Tokens',
|
||||
cost: 'Cost',
|
||||
// Status
|
||||
@@ -155,11 +157,19 @@ export default {
|
||||
subscriptionExpires: 'Subscription Expires',
|
||||
// Usage stat cells
|
||||
todayRequests: 'Today Requests',
|
||||
todayInputTokens: 'Today Input',
|
||||
todayOutputTokens: 'Today Output',
|
||||
todayTokens: 'Today Tokens',
|
||||
todayCacheCreation: 'Today Cache Creation',
|
||||
todayCacheRead: 'Today Cache Read',
|
||||
todayCost: 'Today Cost',
|
||||
rpmTpm: 'RPM / TPM',
|
||||
totalRequests: 'Total Requests',
|
||||
totalInputTokens: 'Total Input',
|
||||
totalOutputTokens: 'Total Output',
|
||||
totalTokensLabel: 'Total Tokens',
|
||||
totalCacheCreation: 'Total Cache Creation',
|
||||
totalCacheRead: 'Total Cache Read',
|
||||
totalCost: 'Total Cost',
|
||||
avgDuration: 'Avg Duration',
|
||||
// Messages
|
||||
|
||||
@@ -133,6 +133,8 @@ export default {
|
||||
requests: '请求数',
|
||||
inputTokens: '输入 Tokens',
|
||||
outputTokens: '输出 Tokens',
|
||||
cacheCreationTokens: '缓存创建',
|
||||
cacheReadTokens: '缓存读取',
|
||||
totalTokens: '总 Tokens',
|
||||
cost: '费用',
|
||||
// Status
|
||||
@@ -155,11 +157,19 @@ export default {
|
||||
subscriptionExpires: '订阅到期',
|
||||
// Usage stat cells
|
||||
todayRequests: '今日请求',
|
||||
todayInputTokens: '今日输入',
|
||||
todayOutputTokens: '今日输出',
|
||||
todayTokens: '今日 Tokens',
|
||||
todayCacheCreation: '今日缓存创建',
|
||||
todayCacheRead: '今日缓存读取',
|
||||
todayCost: '今日费用',
|
||||
rpmTpm: 'RPM / TPM',
|
||||
totalRequests: '累计请求',
|
||||
totalInputTokens: '累计输入',
|
||||
totalOutputTokens: '累计输出',
|
||||
totalTokensLabel: '累计 Tokens',
|
||||
totalCacheCreation: '累计缓存创建',
|
||||
totalCacheRead: '累计缓存读取',
|
||||
totalCost: '累计费用',
|
||||
avgDuration: '平均耗时',
|
||||
// Messages
|
||||
|
||||
@@ -1098,7 +1098,8 @@ export interface TrendDataPoint {
|
||||
requests: number
|
||||
input_tokens: number
|
||||
output_tokens: number
|
||||
cache_tokens: number
|
||||
cache_creation_tokens: number
|
||||
cache_read_tokens: number
|
||||
total_tokens: number
|
||||
cost: number // 标准计费
|
||||
actual_cost: number // 实际扣除
|
||||
@@ -1109,6 +1110,8 @@ export interface ModelStat {
|
||||
requests: number
|
||||
input_tokens: number
|
||||
output_tokens: number
|
||||
cache_creation_tokens: number
|
||||
cache_read_tokens: number
|
||||
total_tokens: number
|
||||
cost: number // 标准计费
|
||||
actual_cost: number // 实际扣除
|
||||
|
||||
@@ -302,6 +302,8 @@
|
||||
<th class="px-4 py-3 text-right text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-dark-400">{{ t('keyUsage.requests') }}</th>
|
||||
<th class="px-4 py-3 text-right text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-dark-400">{{ t('keyUsage.inputTokens') }}</th>
|
||||
<th class="px-4 py-3 text-right text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-dark-400">{{ t('keyUsage.outputTokens') }}</th>
|
||||
<th class="px-4 py-3 text-right text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-dark-400">{{ t('keyUsage.cacheCreationTokens') }}</th>
|
||||
<th class="px-4 py-3 text-right text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-dark-400">{{ t('keyUsage.cacheReadTokens') }}</th>
|
||||
<th class="px-4 py-3 text-right text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-dark-400">{{ t('keyUsage.totalTokens') }}</th>
|
||||
<th class="px-4 py-3 text-right text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-dark-400">{{ t('keyUsage.cost') }}</th>
|
||||
</tr>
|
||||
@@ -316,6 +318,8 @@
|
||||
<td class="px-4 py-3 text-sm tabular-nums text-right text-gray-700 dark:text-dark-200">{{ fmtNum(m.requests) }}</td>
|
||||
<td class="px-4 py-3 text-sm tabular-nums text-right text-gray-700 dark:text-dark-200">{{ fmtNum(m.input_tokens) }}</td>
|
||||
<td class="px-4 py-3 text-sm tabular-nums text-right text-gray-700 dark:text-dark-200">{{ fmtNum(m.output_tokens) }}</td>
|
||||
<td class="px-4 py-3 text-sm tabular-nums text-right text-gray-700 dark:text-dark-200">{{ fmtNum(m.cache_creation_tokens) }}</td>
|
||||
<td class="px-4 py-3 text-sm tabular-nums text-right text-gray-700 dark:text-dark-200">{{ fmtNum(m.cache_read_tokens) }}</td>
|
||||
<td class="px-4 py-3 text-sm tabular-nums text-right text-gray-700 dark:text-dark-200">{{ fmtNum(m.total_tokens) }}</td>
|
||||
<td class="px-4 py-3 text-sm tabular-nums text-right font-medium text-gray-900 dark:text-white">{{ usd(m.actual_cost != null ? m.actual_cost : m.cost) }}</td>
|
||||
</tr>
|
||||
@@ -694,11 +698,19 @@ const usageStatCells = computed<StatCell[]>(() => {
|
||||
|
||||
return [
|
||||
{ label: t('keyUsage.todayRequests'), value: fmtNum(today.requests) },
|
||||
{ label: t('keyUsage.todayInputTokens'), value: fmtNum(today.input_tokens) },
|
||||
{ label: t('keyUsage.todayOutputTokens'), value: fmtNum(today.output_tokens) },
|
||||
{ label: t('keyUsage.todayTokens'), value: fmtNum(today.total_tokens) },
|
||||
{ label: t('keyUsage.todayCacheCreation'), value: fmtNum(today.cache_creation_tokens) },
|
||||
{ label: t('keyUsage.todayCacheRead'), value: fmtNum(today.cache_read_tokens) },
|
||||
{ label: t('keyUsage.todayCost'), value: usd(today.actual_cost) },
|
||||
{ label: t('keyUsage.rpmTpm'), value: `${usage.rpm || 0} / ${usage.tpm || 0}` },
|
||||
{ label: t('keyUsage.totalRequests'), value: fmtNum(total.requests) },
|
||||
{ label: t('keyUsage.totalInputTokens'), value: fmtNum(total.input_tokens) },
|
||||
{ label: t('keyUsage.totalOutputTokens'), value: fmtNum(total.output_tokens) },
|
||||
{ label: t('keyUsage.totalTokensLabel'), value: fmtNum(total.total_tokens) },
|
||||
{ label: t('keyUsage.totalCacheCreation'), value: fmtNum(total.cache_creation_tokens) },
|
||||
{ label: t('keyUsage.totalCacheRead'), value: fmtNum(total.cache_read_tokens) },
|
||||
{ label: t('keyUsage.totalCost'), value: usd(total.actual_cost) },
|
||||
{ label: t('keyUsage.avgDuration'), value: usage.average_duration_ms ? `${Math.round(usage.average_duration_ms)} ms` : '-' },
|
||||
]
|
||||
|
||||
@@ -113,6 +113,9 @@
|
||||
|
||||
<!-- Actions -->
|
||||
<div class="ml-auto flex items-center gap-3">
|
||||
<button @click="applyFilters" :disabled="loading" class="btn btn-secondary">
|
||||
{{ t('common.refresh') }}
|
||||
</button>
|
||||
<button @click="resetFilters" class="btn btn-secondary">
|
||||
{{ t('common.reset') }}
|
||||
</button>
|
||||
|
||||
Reference in New Issue
Block a user