Add thinking time to gen timer tooltip
| @@ -2459,7 +2459,7 @@ export function addOneMessage(mes, { type = 'normal', insertAfter = null, scroll | |||
| 2459 | timestamp: timestamp, | 2459 | timestamp: timestamp, |
| 2460 | extra: mes.extra, | 2460 | extra: mes.extra, |
| 2461 | tokenCount: mes.extra?.token_count ?? 0, | 2461 | tokenCount: mes.extra?.token_count ?? 0, |
| 2462 | ...formatGenerationTimer(mes.gen_started, mes.gen_finished, mes.extra?.token_count), | 2462 | ...formatGenerationTimer(mes.gen_started, mes.gen_finished, mes.extra?.token_count, mes.extra?.reasoning_duration), |
| 2463 | }; | 2463 | }; |
| 2464 | 2464 | ||
| 2465 | const renderedMessage = getMessageFromTemplate(params); | 2465 | const renderedMessage = getMessageFromTemplate(params); |
| @@ -2579,13 +2579,14 @@ export function formatCharacterAvatar(characterAvatar) { | |||
| 2579 | * @param {Date} gen_started Date when generation was started | 2579 | * @param {Date} gen_started Date when generation was started |
| 2580 | * @param {Date} gen_finished Date when generation was finished | 2580 | * @param {Date} gen_finished Date when generation was finished |
| 2581 | * @param {number} tokenCount Number of tokens generated (0 if not available) | 2581 | * @param {number} tokenCount Number of tokens generated (0 if not available) |
| 2582 | * @param {number?} [reasoningDuration=null] Reasoning duration (null if no reasoning was done) | ||
| 2582 | * @returns {Object} Object containing the formatted timer value and title | 2583 | * @returns {Object} Object containing the formatted timer value and title |
| 2583 | * @example | 2584 | * @example |
| 2584 | * const { timerValue, timerTitle } = formatGenerationTimer(gen_started, gen_finished, tokenCount); | 2585 | * const { timerValue, timerTitle } = formatGenerationTimer(gen_started, gen_finished, tokenCount); |
| 2585 | * console.log(timerValue); // 1.2s | 2586 | * console.log(timerValue); // 1.2s |
| 2586 | * 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 | 2587 | * 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 |
| 2587 | */ | 2588 | */ |
| 2588 | function formatGenerationTimer(gen_started, gen_finished, tokenCount) { | 2589 | function formatGenerationTimer(gen_started, gen_finished, tokenCount, reasoningDuration = null) { |
| 2589 | if (!gen_started || !gen_finished) { | 2590 | if (!gen_started || !gen_finished) { |
| 2590 | return {}; | 2591 | return {}; |
| 2591 | } | 2592 | } |
| @@ -2599,6 +2600,7 @@ function formatGenerationTimer(gen_started, gen_finished, tokenCount) { | |||
| 2599 | `Generation queued: ${start.format(dateFormat)}`, | 2600 | `Generation queued: ${start.format(dateFormat)}`, |
| 2600 | `Reply received: ${finish.format(dateFormat)}`, | 2601 | `Reply received: ${finish.format(dateFormat)}`, |
| 2601 | `Time to generate: ${seconds} seconds`, | 2602 | `Time to generate: ${seconds} seconds`, |
| 2603 | reasoningDuration > 0 ? `Time to think: ${reasoningDuration / 1000} seconds` : '', | ||
| 2602 | tokenCount > 0 ? `Token rate: ${Number(tokenCount / seconds).toFixed(1)} t/s` : '', | 2604 | tokenCount > 0 ? `Token rate: ${Number(tokenCount / seconds).toFixed(1)} t/s` : '', |
| 2603 | ].join('\n'); | 2605 | ].join('\n'); |
| 2604 | 2606 | ||
| @@ -3310,7 +3312,7 @@ class StreamingProcessor { | |||
| 3310 | this.messageTextDom.innerHTML = formattedText; | 3312 | this.messageTextDom.innerHTML = formattedText; |
| 3311 | } | 3313 | } |
| 3312 | 3314 | ||
| 3313 | const timePassed = formatGenerationTimer(this.timeStarted, currentTime, currentTokenCount); | 3315 | const timePassed = formatGenerationTimer(this.timeStarted, currentTime, currentTokenCount, this.#reasoningDuration()); |
| 3314 | if (this.messageTimerDom instanceof HTMLElement) { | 3316 | if (this.messageTimerDom instanceof HTMLElement) { |
| 3315 | this.messageTimerDom.textContent = timePassed.timerValue; | 3317 | this.messageTimerDom.textContent = timePassed.timerValue; |
| 3316 | this.messageTimerDom.title = timePassed.timerTitle; | 3318 | this.messageTimerDom.title = timePassed.timerTitle; |