mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Merge pull request #3634 from SillyTavern/continue-from-reasoning
Fix auto-parsing of continue from reasoning
This commit is contained in:
@@ -3204,13 +3204,21 @@ class StreamingProcessor {
|
||||
this.promptReasoning = promptReasoning;
|
||||
}
|
||||
|
||||
#checkDomElements(messageId) {
|
||||
/**
|
||||
* Initializes DOM elements for the current message.
|
||||
* @param {number} messageId Current message ID
|
||||
* @param {boolean?} continueOnReasoning If continuing on reasoning
|
||||
*/
|
||||
async #checkDomElements(messageId, continueOnReasoning = null) {
|
||||
if (this.messageDom === null || this.messageTextDom === null) {
|
||||
this.messageDom = document.querySelector(`#chat .mes[mesid="${messageId}"]`);
|
||||
this.messageTextDom = this.messageDom?.querySelector('.mes_text');
|
||||
this.messageTimerDom = this.messageDom?.querySelector('.mes_timer');
|
||||
this.messageTokenCounterDom = this.messageDom?.querySelector('.tokenCounterDisplay');
|
||||
}
|
||||
if (continueOnReasoning) {
|
||||
await this.reasoningHandler.process(messageId, false, this.promptReasoning);
|
||||
}
|
||||
this.reasoningHandler.updateDom(messageId);
|
||||
}
|
||||
|
||||
@@ -3230,7 +3238,8 @@ class StreamingProcessor {
|
||||
}
|
||||
|
||||
async onStartStreaming(text) {
|
||||
if (this.type === 'continue' && this.promptReasoning.prefixReasoning) {
|
||||
const continueOnReasoning = !!(this.type === 'continue' && this.promptReasoning.prefixReasoning);
|
||||
if (continueOnReasoning) {
|
||||
this.reasoningHandler.initContinue(this.promptReasoning);
|
||||
}
|
||||
|
||||
@@ -3242,7 +3251,7 @@ class StreamingProcessor {
|
||||
} else {
|
||||
await saveReply(this.type, text, true, '', [], '');
|
||||
messageId = chat.length - 1;
|
||||
this.#checkDomElements(messageId);
|
||||
await this.#checkDomElements(messageId, continueOnReasoning);
|
||||
this.markUIGenStarted();
|
||||
}
|
||||
hideSwipeButtons();
|
||||
@@ -3275,7 +3284,7 @@ class StreamingProcessor {
|
||||
this.sendTextarea.dispatchEvent(new Event('input', { bubbles: true }));
|
||||
} else {
|
||||
const mesChanged = chat[messageId]['mes'] !== processedText;
|
||||
this.#checkDomElements(messageId);
|
||||
await this.#checkDomElements(messageId);
|
||||
this.#updateMessageBlockVisibility();
|
||||
const currentTime = new Date();
|
||||
chat[messageId]['mes'] = processedText;
|
||||
@@ -3287,7 +3296,7 @@ class StreamingProcessor {
|
||||
chat[messageId]['extra']['time_to_first_token'] = this.timeToFirstToken;
|
||||
|
||||
// Update reasoning
|
||||
await this.reasoningHandler.process(messageId, mesChanged);
|
||||
await this.reasoningHandler.process(messageId, mesChanged, this.promptReasoning);
|
||||
processedText = chat[messageId]['mes'];
|
||||
|
||||
// Token count update.
|
||||
@@ -5957,7 +5966,7 @@ export function cleanUpMessage(getMessage, isImpersonate, isContinue, displayInc
|
||||
getMessage = trimToEndSentence(getMessage);
|
||||
}
|
||||
|
||||
if (power_user.trim_spaces) {
|
||||
if (power_user.trim_spaces && !PromptReasoning.getLatestPrefix()) {
|
||||
getMessage = getMessage.trim();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user