Meta-Bar: Token-Anzeige auch bei abgebrochenem Stream; Cache-Tokens anzeigen
This commit is contained in:
1 parent
b84dff6d8c
commit
6b707d7d74
3 files changed
+25
-17
No files matched your search
+20
-5
@@ -1,3 +1,15 @@
|
||||
// ── Helpers ──
|
||||
|
||||
function buildMetaString(d) {
|
||||
let meta = `Model: ${d.model || '?'} | In: ${d.inputTokens || 0} | Out: ${d.outputTokens || 0}`;
|
||||
if (d.cacheCreationTokens > 0) meta += ` | Cache-Write: ${d.cacheCreationTokens}`;
|
||||
if (d.cacheReadTokens > 0) meta += ` | Cache-Read: ${d.cacheReadTokens}`;
|
||||
if ((d.iterations || 0) > 1) meta += ` | Iterations: ${d.iterations}`;
|
||||
if (d.durationMs) meta += ` | ${(d.durationMs / 1000).toFixed(1)}s`;
|
||||
if (d.stopReason && d.stopReason !== 'end_turn' && d.stopReason !== 'tool_use') meta += ` | Stop: ${d.stopReason}`;
|
||||
return meta;
|
||||
}
|
||||
|
||||
// ── Chat State ──
|
||||
|
||||
const messages = [];
|
||||
@@ -135,11 +147,14 @@ async function sendMessage() {
|
||||
if (data.stopReason === 'max_tokens') {
|
||||
addWarningBubble('⚠️ Antwort wurde abgeschnitten (max_tokens erreicht). Bitte frage nach dem Rest.', true);
|
||||
}
|
||||
let meta = `Model: ${data.model || '?'} | In: ${data.inputTokens || 0} | Out: ${data.outputTokens || 0}`;
|
||||
if (data.iterations > 1) meta += ` | Iterations: ${data.iterations}`;
|
||||
if (data.durationMs) meta += ` | ${(data.durationMs / 1000).toFixed(1)}s`;
|
||||
if (data.stopReason && data.stopReason !== 'end_turn' && data.stopReason !== 'tool_use') meta += ` | Stop: ${data.stopReason}`;
|
||||
setMeta(meta);
|
||||
if (data.model) {
|
||||
setMeta(buildMetaString(data));
|
||||
} else if (data.chainId) {
|
||||
// Leeres done (z.B. nach error/max_iterations) – Chain-Daten nachladen
|
||||
apiGetChain(data.chainId).then(chain => {
|
||||
if (chain) setMeta(buildMetaString(chain));
|
||||
}).catch(() => {});
|
||||
}
|
||||
break;
|
||||
}
|
||||
eventType = null;
|
||||
|
||||
@@ -25,15 +25,8 @@ function startStreamingPoll(sessionId, sendBtn, chainId) {
|
||||
const cid = _recoveryChainId || status.chainId;
|
||||
if (cid) {
|
||||
const chain = await apiGetChain(cid);
|
||||
if (chain) {
|
||||
let meta = `Model: ${chain.model || '?'} | In: ${chain.inputTokens || 0} | Out: ${chain.outputTokens || 0}`;
|
||||
if (chain.iterations > 1) meta += ` | Iterations: ${chain.iterations}`;
|
||||
if (chain.durationMs) meta += ` | ${(chain.durationMs / 1000).toFixed(1)}s`;
|
||||
if (chain.stopReason && chain.stopReason !== 'end_turn' && chain.stopReason !== 'tool_use') meta += ` | Stop: ${chain.stopReason}`;
|
||||
setMeta(meta);
|
||||
} else {
|
||||
setMeta('Bereit');
|
||||
}
|
||||
if (chain) setMeta(buildMetaString(chain));
|
||||
else setMeta('Bereit');
|
||||
} else {
|
||||
setMeta('Bereit');
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user