Add thinking time to gen timer tooltip

8b4414b799b602c9c66d84d7f3a409a74936ae3b

Wolfsblvt <wolfsblvt@gmail.com>

1 files changed, +5 -3Ignore whitespace
public/script.js+5 -3
@@ -2459,7 +2459,7 @@ export function addOneMessage(mes, { type = 'normal', insertAfter = null, scroll
24592459 timestamp: timestamp,
24602460 extra: mes.extra,
24612461 tokenCount: mes.extra?.token_count ?? 0,
24622462 ...formatGenerationTimer(mes.gen_started, mes.gen_finished, mes.extra?.token_count, mes.extra?.reasoning_duration),
24632463 };
24642464
24652465 const renderedMessage = getMessageFromTemplate(params);
@@ -2579,13 +2579,14 @@ export function formatCharacterAvatar(characterAvatar) {
25792579 * @param {Date} gen_started Date when generation was started
25802580 * @param {Date} gen_finished Date when generation was finished
25812581 * @param {number} tokenCount Number of tokens generated (0 if not available)
2582+ * @param {number?} [reasoningDuration=null] Reasoning duration (null if no reasoning was done)
25822583 * @returns {Object} Object containing the formatted timer value and title
25832584 * @example
25842585 * const { timerValue, timerTitle } = formatGenerationTimer(gen_started, gen_finished, tokenCount);
25852586 * console.log(timerValue); // 1.2s
25862587 * 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
25872588 */
25882589function formatGenerationTimer(gen_started, gen_finished, tokenCount, reasoningDuration = null) {
25892590 if (!gen_started || !gen_finished) {
25902591 return {};
25912592 }
@@ -2599,6 +2600,7 @@ function formatGenerationTimer(gen_started, gen_finished, tokenCount) {
25992600 `Generation queued: ${start.format(dateFormat)}`,
26002601 `Reply received: ${finish.format(dateFormat)}`,
26012602 `Time to generate: ${seconds} seconds`,
2603+ reasoningDuration > 0 ? `Time to think: ${reasoningDuration / 1000} seconds` : '',
26022604 tokenCount > 0 ? `Token rate: ${Number(tokenCount / seconds).toFixed(1)} t/s` : '',
26032605 ].join('\n');
26042606
@@ -3310,7 +3312,7 @@ class StreamingProcessor {
33103312 this.messageTextDom.innerHTML = formattedText;
33113313 }
33123314
33133315 const timePassed = formatGenerationTimer(this.timeStarted, currentTime, currentTokenCount, this.#reasoningDuration());
33143316 if (this.messageTimerDom instanceof HTMLElement) {
33153317 this.messageTimerDom.textContent = timePassed.timerValue;
33163318 this.messageTimerDom.title = timePassed.timerTitle;