Changed param order, saved a tree
| @@ -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 | }; |
| 2482 | 2482 | ||
| 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 started | 2597 | * @param {Date} gen_started Date when generation was started |
| 2598 | * @param {Date} gen_finished Date when generation was finished | 2598 | * @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 title | 2602 | * @returns {Object} Object containing the formatted timer value and title |
| 2603 | * @example | 2603 | * @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.2s | 2605 | * 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/s | 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 | function formatGenerationTimer(gen_started, gen_finished, tokenCount, timeToFirstToken, reasoningDuration = null) { | 2608 | function 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 | } |
| 3297 | 3295 | ||
| 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; |