Refactor reasoning placeholder clean-up

This commit is contained in:
Cohee
2025-01-27 21:56:15 +02:00
parent a5a8f6057b
commit 8b5e0df2d7
2 changed files with 14 additions and 10 deletions

View File

@@ -3194,10 +3194,6 @@ class StreamingProcessor {
this.#checkDomElements(messageId);
this.#updateMessageBlockVisibility();
const currentTime = new Date();
// Don't waste time calculating token count for streaming
const tokenCountText = (this.reasoning || '') + processedText;
const currentTokenCount = isFinal && power_user.message_token_count_enabled ? getTokenCount(tokenCountText, 0) : 0;
const timePassed = formatGenerationTimer(this.timeStarted, currentTime, currentTokenCount);
chat[messageId]['mes'] = processedText;
chat[messageId]['gen_started'] = this.timeStarted;
chat[messageId]['gen_finished'] = currentTime;
@@ -3214,6 +3210,10 @@ class StreamingProcessor {
}
}
// Don't waste time calculating token count for streaming
const tokenCountText = (this.reasoning || '') + processedText;
const currentTokenCount = isFinal && power_user.message_token_count_enabled ? getTokenCount(tokenCountText, 0) : 0;
if (currentTokenCount) {
chat[messageId]['extra']['token_count'] = currentTokenCount;
if (this.messageTokenCounterDom instanceof HTMLElement) {
@@ -3236,10 +3236,13 @@ class StreamingProcessor {
if (this.messageTextDom instanceof HTMLElement) {
this.messageTextDom.innerHTML = formattedText;
}
const timePassed = formatGenerationTimer(this.timeStarted, currentTime, currentTokenCount);
if (this.messageTimerDom instanceof HTMLElement) {
this.messageTimerDom.textContent = timePassed.timerValue;
this.messageTimerDom.title = timePassed.timerTitle;
}
this.setFirstSwipe(messageId);
}