Record token usage per turn and show daily, weekly and all-time totals by host
This commit is contained in:
@@ -134,6 +134,15 @@ if ($action === 'stats') {
|
||||
exit;
|
||||
}
|
||||
|
||||
// ── tokens ────────────────────────────────────────────────────────────────────
|
||||
// Separate from stats rather than folded into it. stats is polled every 30 seconds by every
|
||||
// open tab; this reads a file that grows without bound between prunes. The totals only move
|
||||
// when a turn completes, and the page knows exactly when that happened, so it asks then.
|
||||
if ($action === 'tokens') {
|
||||
echo json_encode(['ok' => true, 'tokens' => vv_ai_token_stats()]);
|
||||
exit;
|
||||
}
|
||||
|
||||
// ── poll ──────────────────────────────────────────────────────────────────────
|
||||
if ($action === 'poll') {
|
||||
$token = trim($_GET['token'] ?? '');
|
||||
|
||||
Reference in New Issue
Block a user