Changed param order, saved a tree
| @@ -2477,7 +2477,7 @@ export function addOneMessage(mes, { type = 'normal', insertAfter = null, scroll | ||
| 2477 | 2477 | timestamp: timestamp, |
| 2478 | 2478 | extra: mes.extra, |
| 2479 | 2479 | tokenCount: mes.extra?.token_count ?? 0, |
| 2480 | 2480 | ...formatGenerationTimer(mes.gen_started, mes.gen_finished, mes.extra?.token_count, mes.extra?.time_to_first_tokenreasoning_duration, mes.extra?.reasoning_durationtime_to_first_token), |
| 2481 | 2481 | }; |
| 2482 | 2482 | |
| 2483 | 2483 | const renderedMessage = getMessageFromTemplate(params); |
| @@ -2597,15 +2597,15 @@ export function formatCharacterAvatar(characterAvatar) { | ||
| 2597 | 2597 | * @param {Date} gen_started Date when generation was started |
| 2598 | 2598 | * @param {Date} gen_finished Date when generation was finished |
| 2599 | 2599 | * @param {number} tokenCount Number of tokens generated (0 if not available) |
| 2600 | - * @param {number | null} timeToFirstToken Time to first token | |
| 2601 | 2600 | * @param {number?} [reasoningDuration=null] Reasoning duration (null if no reasoning was done) |
| 2601 | + * @param {number?} [timeToFirstToken=null] Time to first token | |
| 2602 | 2602 | * @returns {Object} Object containing the formatted timer value and title |
| 2603 | 2603 | * @example |
| 2604 | 2604 | * const { timerValue, timerTitle } = formatGenerationTimer(gen_started, gen_finished, tokenCount); |
| 2605 | 2605 | * console.log(timerValue); // 1.2s |
| 2606 | 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/s |
| 2607 | 2607 | */ |
| 2608 | 2608 | function formatGenerationTimer(gen_started, gen_finished, tokenCount, timeToFirstTokenreasoningDuration = null, reasoningDurationtimeToFirstToken = null) { |
| 2609 | 2609 | if (!gen_started || !gen_finished) { |
| 2610 | 2610 | return {}; |
| 2611 | 2611 | } |
| @@ -3160,9 +3160,7 @@ class StreamingProcessor { | ||
| 3160 | 3160 | this.abortController = new AbortController(); |
| 3161 | 3161 | this.firstMessageText = '...'; |
| 3162 | 3162 | this.timeStarted = timeStarted; |
| 3163 | - /** | |
| 3163 | + /** @type {number?} */ | |
| 3164 | - * @type {number?} | |
| 3165 | - */ | |
| 3166 | 3164 | this.timeToFirstToken = null; |
| 3167 | 3165 | this.createdAt = new Date(); |
| 3168 | 3166 | this.continueMessage = type === 'continue' ? continueMessage : ''; |
| @@ -3295,7 +3293,7 @@ class StreamingProcessor { | ||
| 3295 | 3293 | this.messageTextDom.innerHTML = formattedText; |
| 3296 | 3294 | } |
| 3297 | 3295 | |
| 3298 | 3296 | const timePassed = formatGenerationTimer(this.timeStarted, currentTime, currentTokenCount, this.timeToFirstToken, this.reasoningHandler.getDuration(), this.timeToFirstToken); |
| 3299 | 3297 | if (this.messageTimerDom instanceof HTMLElement) { |
| 3300 | 3298 | this.messageTimerDom.textContent = timePassed.timerValue; |
| 3301 | 3299 | this.messageTimerDom.title = timePassed.timerTitle; |