Add debug stats
This commit is contained in:
@@ -1519,10 +1519,11 @@ class Odidere {
|
||||
// Stash assistant messages with tool_calls until their results arrive.
|
||||
let pendingTools = null;
|
||||
let streamingMessage = null;
|
||||
|
||||
const streamingMeta = () => {
|
||||
const streamingMeta = (usage, timings) => {
|
||||
const meta = {};
|
||||
if (voice) meta.voice = voice;
|
||||
if (usage) meta.usage = usage;
|
||||
if (timings) meta.timings = timings;
|
||||
return meta;
|
||||
};
|
||||
|
||||
@@ -1593,7 +1594,7 @@ class Odidere {
|
||||
role: 'assistant',
|
||||
content: [{ type: ContentTypeText, text: '' }],
|
||||
};
|
||||
const meta = streamingMeta();
|
||||
const meta = streamingMeta(event.usage, event.timings);
|
||||
const appended = this.#appendHistory([message], meta);
|
||||
const $el = this.#renderStreamingAssistantMessage(
|
||||
appended[0],
|
||||
@@ -1626,7 +1627,7 @@ class Odidere {
|
||||
if (eventType === StreamEventDone) {
|
||||
if (message.role !== 'assistant') continue;
|
||||
|
||||
const meta = streamingMeta();
|
||||
const meta = streamingMeta(event.usage, event.timings);
|
||||
let finalMessage = message;
|
||||
let $streaming = null;
|
||||
if (streamingMessage) {
|
||||
@@ -2351,6 +2352,49 @@ class Odidere {
|
||||
// Populate debug panel.
|
||||
const $dl = $msg.querySelector('.message__debug-list');
|
||||
if (meta?.voice) this.#appendDebugRow($dl, 'Voice', meta.voice);
|
||||
if (meta?.usage) {
|
||||
const u = meta.usage;
|
||||
this.#appendDebugRow($dl, 'Prompt tokens', String(u.prompt_tokens));
|
||||
this.#appendDebugRow(
|
||||
$dl,
|
||||
'Completion tokens',
|
||||
String(u.completion_tokens),
|
||||
);
|
||||
this.#appendDebugRow($dl, 'Total tokens', String(u.total_tokens));
|
||||
if (u.completion_tokens_details?.reasoning_tokens > 0)
|
||||
this.#appendDebugRow(
|
||||
$dl,
|
||||
'Reasoning tokens',
|
||||
String(u.completion_tokens_details.reasoning_tokens),
|
||||
);
|
||||
if (u.prompt_tokens_details?.cached_tokens > 0)
|
||||
this.#appendDebugRow(
|
||||
$dl,
|
||||
'Cached tokens',
|
||||
String(u.prompt_tokens_details.cached_tokens),
|
||||
);
|
||||
}
|
||||
if (meta?.timings) {
|
||||
const t = meta.timings;
|
||||
if (t.prompt_ms > 0)
|
||||
this.#appendDebugRow(
|
||||
$dl,
|
||||
'Prompt eval',
|
||||
t.prompt_ms.toFixed(1) +
|
||||
' ms (' +
|
||||
t.prompt_per_second.toFixed(0) +
|
||||
' tok/s)',
|
||||
);
|
||||
if (t.predicted_ms > 0)
|
||||
this.#appendDebugRow(
|
||||
$dl,
|
||||
'Predicted eval',
|
||||
t.predicted_ms.toFixed(1) +
|
||||
' ms (' +
|
||||
t.predicted_per_second.toFixed(0) +
|
||||
' tok/s)',
|
||||
);
|
||||
}
|
||||
if ($dl.children.length === 0) this.#appendDebugRow($dl, 'No data', '');
|
||||
|
||||
// Bind action buttons.
|
||||
@@ -2450,6 +2494,49 @@ class Odidere {
|
||||
// Populate debug panel.
|
||||
const $dl = $msg.querySelector('.message__debug-list');
|
||||
if (meta?.voice) this.#appendDebugRow($dl, 'Voice', meta.voice);
|
||||
if (meta?.usage) {
|
||||
const u = meta.usage;
|
||||
this.#appendDebugRow($dl, 'Prompt tokens', String(u.prompt_tokens));
|
||||
this.#appendDebugRow(
|
||||
$dl,
|
||||
'Completion tokens',
|
||||
String(u.completion_tokens),
|
||||
);
|
||||
this.#appendDebugRow($dl, 'Total tokens', String(u.total_tokens));
|
||||
if (u.completion_tokens_details?.reasoning_tokens > 0)
|
||||
this.#appendDebugRow(
|
||||
$dl,
|
||||
'Reasoning tokens',
|
||||
String(u.completion_tokens_details.reasoning_tokens),
|
||||
);
|
||||
if (u.prompt_tokens_details?.cached_tokens > 0)
|
||||
this.#appendDebugRow(
|
||||
$dl,
|
||||
'Cached tokens',
|
||||
String(u.prompt_tokens_details.cached_tokens),
|
||||
);
|
||||
}
|
||||
if (meta?.timings) {
|
||||
const t = meta.timings;
|
||||
if (t.prompt_ms > 0)
|
||||
this.#appendDebugRow(
|
||||
$dl,
|
||||
'Prompt eval',
|
||||
t.prompt_ms.toFixed(1) +
|
||||
' ms (' +
|
||||
t.prompt_per_second.toFixed(0) +
|
||||
' tok/s)',
|
||||
);
|
||||
if (t.predicted_ms > 0)
|
||||
this.#appendDebugRow(
|
||||
$dl,
|
||||
'Predicted eval',
|
||||
t.predicted_ms.toFixed(1) +
|
||||
' ms (' +
|
||||
t.predicted_per_second.toFixed(0) +
|
||||
' tok/s)',
|
||||
);
|
||||
}
|
||||
if ($dl.children.length === 0) this.#appendDebugRow($dl, 'No data', '');
|
||||
|
||||
// Bind action buttons.
|
||||
|
||||
Reference in New Issue
Block a user