Changed param order, saved a tree

fb5f3e0f97602682c4aec498a318b4c589f30a5f

bmen25124 <bmen25124@gmail.com>

1 files changed, +5 -7Showing whitespace changes
public/script.js+5 -7
@@ -2477,7 +2477,7 @@ export function addOneMessage(mes, { type = 'normal', insertAfter = null, scroll
2477 timestamp: timestamp,2477 timestamp: timestamp,
2478 extra: mes.extra,2478 extra: mes.extra,
2479 tokenCount: mes.extra?.token_count ?? 0,2479 tokenCount: mes.extra?.token_count ?? 0,
2480 ...formatGenerationTimer(mes.gen_started, mes.gen_finished, mes.extra?.token_count, mes.extra?.time_to_first_token, mes.extra?.reasoning_duration),2480 ...formatGenerationTimer(mes.gen_started, mes.gen_finished, mes.extra?.token_count, mes.extra?.reasoning_duration, mes.extra?.time_to_first_token),
2481 };2481 };
24822482
2483 const renderedMessage = getMessageFromTemplate(params);2483 const renderedMessage = getMessageFromTemplate(params);
@@ -2597,15 +2597,15 @@ export function formatCharacterAvatar(characterAvatar) {
2597 * @param {Date} gen_started Date when generation was started2597 * @param {Date} gen_started Date when generation was started
2598 * @param {Date} gen_finished Date when generation was finished2598 * @param {Date} gen_finished Date when generation was finished
2599 * @param {number} tokenCount Number of tokens generated (0 if not available)2599 * @param {number} tokenCount Number of tokens generated (0 if not available)
2600 * @param {number | null} timeToFirstToken Time to first token
2601 * @param {number?} [reasoningDuration=null] Reasoning duration (null if no reasoning was done)2600 * @param {number?} [reasoningDuration=null] Reasoning duration (null if no reasoning was done)
2601 * @param {number?} [timeToFirstToken=null] Time to first token
2602 * @returns {Object} Object containing the formatted timer value and title2602 * @returns {Object} Object containing the formatted timer value and title
2603 * @example2603 * @example
2604 * const { timerValue, timerTitle } = formatGenerationTimer(gen_started, gen_finished, tokenCount);2604 * const { timerValue, timerTitle } = formatGenerationTimer(gen_started, gen_finished, tokenCount);
2605 * console.log(timerValue); // 1.2s2605 * console.log(timerValue); // 1.2s
2606 * console.log(timerTitle); // Generation queued: 12:34:56 7 Jan 2021\nReply received: 12:34:57 7 Jan 2021\nTime to generate: 1.2 seconds\nToken rate: 5 t/s2606 * console.log(timerTitle); // Generation queued: 12:34:56 7 Jan 2021\nReply received: 12:34:57 7 Jan 2021\nTime to generate: 1.2 seconds\nToken rate: 5 t/s
2607 */2607 */
2608function formatGenerationTimer(gen_started, gen_finished, tokenCount, timeToFirstToken, reasoningDuration = null) {2608function formatGenerationTimer(gen_started, gen_finished, tokenCount, reasoningDuration = null, timeToFirstToken = null) {
2609 if (!gen_started || !gen_finished) {2609 if (!gen_started || !gen_finished) {
2610 return {};2610 return {};
2611 }2611 }
@@ -3160,9 +3160,7 @@ class StreamingProcessor {
3160 this.abortController = new AbortController();3160 this.abortController = new AbortController();
3161 this.firstMessageText = '...';3161 this.firstMessageText = '...';
3162 this.timeStarted = timeStarted;3162 this.timeStarted = timeStarted;
3163 /**3163 /** @type {number?} */
3164 * @type {number?}
3165 */
3166 this.timeToFirstToken = null;3164 this.timeToFirstToken = null;
3167 this.createdAt = new Date();3165 this.createdAt = new Date();
3168 this.continueMessage = type === 'continue' ? continueMessage : '';3166 this.continueMessage = type === 'continue' ? continueMessage : '';
@@ -3295,7 +3293,7 @@ class StreamingProcessor {
3295 this.messageTextDom.innerHTML = formattedText;3293 this.messageTextDom.innerHTML = formattedText;
3296 }3294 }
32973295
3298 const timePassed = formatGenerationTimer(this.timeStarted, currentTime, currentTokenCount, this.timeToFirstToken, this.reasoningHandler.getDuration());3296 const timePassed = formatGenerationTimer(this.timeStarted, currentTime, currentTokenCount, this.reasoningHandler.getDuration(), this.timeToFirstToken);
3299 if (this.messageTimerDom instanceof HTMLElement) {3297 if (this.messageTimerDom instanceof HTMLElement) {
3300 this.messageTimerDom.textContent = timePassed.timerValue;3298 this.messageTimerDom.textContent = timePassed.timerValue;
3301 this.messageTimerDom.title = timePassed.timerTitle;3299 this.messageTimerDom.title = timePassed.timerTitle;