add token sum
This commit is contained in:
parent
559f8fc878
commit
c793f86f94
@ -406,6 +406,7 @@
|
||||
"statistics": "Statistics",
|
||||
"inputTokens": "Input Tokens",
|
||||
"outputTokens": "Output Tokens",
|
||||
"totalTokens": "Total Tokens",
|
||||
"totalCost": "Total Cost",
|
||||
"duration": "Duration",
|
||||
"copiedToClipboard": "Copied to clipboard",
|
||||
|
@ -406,6 +406,7 @@
|
||||
"statistics": "统计信息",
|
||||
"inputTokens": "输入Token",
|
||||
"outputTokens": "输出Token",
|
||||
"totalTokens": "总Token数",
|
||||
"totalCost": "总费用",
|
||||
"duration": "持续时间",
|
||||
"copiedToClipboard": "已复制到剪贴板",
|
||||
|
@ -21,7 +21,8 @@ import {
|
||||
RefreshCw,
|
||||
Zap,
|
||||
DollarSign,
|
||||
Copy
|
||||
Copy,
|
||||
BarChart3
|
||||
} from 'lucide-react'
|
||||
import Link from 'next/link'
|
||||
import { formatDistanceToNow } from 'date-fns'
|
||||
@ -164,7 +165,14 @@ export default function SimulatorPage() {
|
||||
const completed = runs.filter(run => run.status === 'completed').length
|
||||
const running = runs.filter(run => run.status === 'running').length
|
||||
const failed = runs.filter(run => run.status === 'failed').length
|
||||
return { total, completed, running, failed }
|
||||
|
||||
// Calculate total tokens and cost
|
||||
const totalInputTokens = runs.reduce((sum, run) => sum + (run.inputTokens || 0), 0)
|
||||
const totalOutputTokens = runs.reduce((sum, run) => sum + (run.outputTokens || 0), 0)
|
||||
const totalTokens = totalInputTokens + totalOutputTokens
|
||||
const totalCost = runs.reduce((sum, run) => sum + (run.totalCost || 0), 0)
|
||||
|
||||
return { total, completed, running, failed, totalTokens, totalCost }
|
||||
}
|
||||
|
||||
if (authLoading) {
|
||||
@ -208,13 +216,13 @@ export default function SimulatorPage() {
|
||||
|
||||
{/* Stats */}
|
||||
{runs.length > 0 && (
|
||||
<div className="grid grid-cols-2 md:grid-cols-4 gap-4 mt-6">
|
||||
<div className="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-4 mt-6">
|
||||
<Card className="p-4">
|
||||
<div className="flex items-center space-x-2">
|
||||
<Database className="h-4 w-4 text-muted-foreground" />
|
||||
<div>
|
||||
<div className="text-2xl font-bold">{stats.total}</div>
|
||||
<div className="text-xs text-muted-foreground">Total Runs</div>
|
||||
<div className="text-xs text-muted-foreground">{t('allRuns')}</div>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
@ -223,7 +231,7 @@ export default function SimulatorPage() {
|
||||
<CheckCircle2 className="h-4 w-4 text-green-500" />
|
||||
<div>
|
||||
<div className="text-2xl font-bold">{stats.completed}</div>
|
||||
<div className="text-xs text-muted-foreground">Completed</div>
|
||||
<div className="text-xs text-muted-foreground">{t('completed')}</div>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
@ -232,7 +240,7 @@ export default function SimulatorPage() {
|
||||
<RefreshCw className="h-4 w-4 text-blue-500" />
|
||||
<div>
|
||||
<div className="text-2xl font-bold">{stats.running}</div>
|
||||
<div className="text-xs text-muted-foreground">Running</div>
|
||||
<div className="text-xs text-muted-foreground">{t('running')}</div>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
@ -241,7 +249,25 @@ export default function SimulatorPage() {
|
||||
<XCircle className="h-4 w-4 text-red-500" />
|
||||
<div>
|
||||
<div className="text-2xl font-bold">{stats.failed}</div>
|
||||
<div className="text-xs text-muted-foreground">Failed</div>
|
||||
<div className="text-xs text-muted-foreground">{t('failed')}</div>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
<Card className="p-4">
|
||||
<div className="flex items-center space-x-2">
|
||||
<BarChart3 className="h-4 w-4 text-purple-500" />
|
||||
<div>
|
||||
<div className="text-2xl font-bold">{stats.totalTokens.toLocaleString()}</div>
|
||||
<div className="text-xs text-muted-foreground">{t('totalTokens')}</div>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
<Card className="p-4">
|
||||
<div className="flex items-center space-x-2">
|
||||
<DollarSign className="h-4 w-4 text-green-600" />
|
||||
<div>
|
||||
<div className="text-2xl font-bold">{stats.totalCost.toFixed(4)}</div>
|
||||
<div className="text-xs text-muted-foreground">{t('totalCost')}</div>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
@ -378,7 +404,7 @@ export default function SimulatorPage() {
|
||||
{run.totalCost && (
|
||||
<span className="flex items-center">
|
||||
<DollarSign className="h-3 w-3 mr-1" />
|
||||
${run.totalCost.toFixed(4)}
|
||||
{run.totalCost.toFixed(4)}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user