mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
#321 Predict trailing asterisk during streaming
This commit is contained in:
@ -107,7 +107,7 @@ import {
|
||||
setPoeOnlineStatus,
|
||||
} from "./scripts/poe.js";
|
||||
|
||||
import { debounce, delay, restoreCaretPosition, saveCaretPosition, end_trim_to_sentence } from "./scripts/utils.js";
|
||||
import { debounce, delay, restoreCaretPosition, saveCaretPosition, end_trim_to_sentence, countOccurrences, isOdd } from "./scripts/utils.js";
|
||||
import { extension_settings, loadExtensionSettings } from "./scripts/extensions.js";
|
||||
import { executeSlashCommands, getSlashCommandsHelp, registerSlashCommand } from "./scripts/slash-commands.js";
|
||||
import {
|
||||
@ -1516,6 +1516,12 @@ class StreamingProcessor {
|
||||
let isName = result.this_mes_is_name;
|
||||
processedText = result.getMessage;
|
||||
|
||||
// Predict unbalanced asterisks during streaming
|
||||
if (!isFinal && isOdd(countOccurrences(processedText, '*'))) {
|
||||
// Add asterisk at the end to balance it
|
||||
processedText = processedText.trimEnd() + '*';
|
||||
}
|
||||
|
||||
if (isImpersonate) {
|
||||
$('#send_textarea').val(processedText).trigger('input');
|
||||
}
|
||||
|
Reference in New Issue
Block a user