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