Request approval for external paths and show token speed
This commit is contained in:
@@ -369,6 +369,28 @@ function appendMessageText(article, delta) {
|
||||
document.querySelector("#messages").scrollTop = document.querySelector("#messages").scrollHeight;
|
||||
}
|
||||
|
||||
function formatTokenSpeed(value) {
|
||||
const number = Number(value || 0);
|
||||
return number.toFixed(number >= 10 ? 1 : 2);
|
||||
}
|
||||
|
||||
function setGenerationStats(article, stats) {
|
||||
if (!article || !stats) return;
|
||||
const bubble = article.querySelector(".bubble");
|
||||
if (!bubble) return;
|
||||
let node = bubble.querySelector(".generation-stats");
|
||||
if (!node) {
|
||||
node = document.createElement("div");
|
||||
node.className = "generation-stats";
|
||||
bubble.append(node);
|
||||
}
|
||||
node.textContent = [
|
||||
`min ${formatTokenSpeed(stats.min_tokens_per_second)} tok/s`,
|
||||
`avg ${formatTokenSpeed(stats.avg_tokens_per_second)} tok/s`,
|
||||
`max ${formatTokenSpeed(stats.max_tokens_per_second)} tok/s`,
|
||||
].join(" · ");
|
||||
}
|
||||
|
||||
function appendInlineReasoning(article, delta) {
|
||||
const block = article?.querySelector(".message-reasoning");
|
||||
const body = block?.querySelector("pre");
|
||||
@@ -609,6 +631,7 @@ async function handleAssistantStreamEvent(pending, name, data, context) {
|
||||
setMessagePending(pending, data.final_response || "No final content returned.");
|
||||
}
|
||||
pending.querySelector(".message-meta span").textContent = data.status;
|
||||
setGenerationStats(pending, data.generation_stats);
|
||||
setStatus("#task-status", data.task_id, data.status === "completed" ? "ok" : "warn");
|
||||
finishInlineReasoning(pending, data.reasoning_content);
|
||||
await refreshEvents(data.task_id);
|
||||
|
||||
@@ -700,6 +700,13 @@ dd {
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.generation-stats {
|
||||
margin-top: 8px;
|
||||
color: var(--muted);
|
||||
font-size: 11px;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.debug-heading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
Reference in New Issue
Block a user