Record token usage per turn and show daily, weekly and all-time totals by host
This commit is contained in:
@@ -363,6 +363,11 @@ if ($profile === 'code' && preg_match_all('/```(?:\w+)?\n(.*?)```/s', $answer, $
|
||||
|
||||
$evalCount = (int)($d['eval_count'] ?? 0);
|
||||
$evalNs = (int)($d['eval_duration'] ?? 0);
|
||||
$tokS = $evalNs > 0 ? round($evalCount / ($evalNs / 1e9), 1) : null;
|
||||
|
||||
// Accounting before the job file is written, so a turn is counted even if the tab has already
|
||||
// been closed and nobody ever reads the result. Best-effort by contract — it cannot throw.
|
||||
vv_ai_token_record($profile, 'webgui', (int)($d['prompt_eval_count'] ?? 0), $evalCount, $tokS);
|
||||
|
||||
jw($jobFile, [
|
||||
'status' => 'done',
|
||||
@@ -374,6 +379,6 @@ jw($jobFile, [
|
||||
'retrieve_ms' => (int)round($tRetrieve * 1000),
|
||||
'generate_ms' => (int)round((microtime(true) - $t1) * 1000),
|
||||
'tokens' => $evalCount,
|
||||
'tok_s' => $evalNs > 0 ? round($evalCount / ($evalNs / 1e9), 1) : null,
|
||||
'tok_s' => $tokS,
|
||||
],
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user