mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
fix function and call it in correct place?
This commit is contained in:
@ -1662,10 +1662,6 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
|
||||
is_send_press = true;
|
||||
textareaText = $("#send_textarea").val();
|
||||
$("#send_textarea").val('').trigger('input');
|
||||
|
||||
if (power_user.trim_sentences) {
|
||||
textareaText = end_trim_to_sentence(textareaText, power_user.include_newline);
|
||||
}
|
||||
} else {
|
||||
textareaText = "";
|
||||
if (chat.length && chat[chat.length - 1]['is_user']) {
|
||||
@ -2956,6 +2952,10 @@ function extractMessageFromData(data) {
|
||||
}
|
||||
|
||||
function cleanUpMessage(getMessage, isImpersonate) {
|
||||
if (power_user.trim_sentences) {
|
||||
getMessage = end_trim_to_sentence(getMessage, power_user.include_newline);
|
||||
}
|
||||
|
||||
if (power_user.collapse_newlines) {
|
||||
getMessage = collapseNewlines(getMessage);
|
||||
}
|
||||
|
@ -193,7 +193,9 @@ export function sortByCssOrder(a, b) {
|
||||
export function end_trim_to_sentence(input, include_newline = false) {
|
||||
// inspired from https://github.com/kaihordewebui/kaihordewebui.github.io/blob/06b95e6b7720eb85177fbaf1a7f52955d7cdbc02/index.html#L4853-L4867
|
||||
|
||||
console.log(input, include_newline);
|
||||
const punctuation = new Set(['.', '!', '?']); // extend this as you see fit
|
||||
let last = -1;
|
||||
|
||||
for (let i = input.length - 1; i >= 0; i--) {
|
||||
const char = input[i];
|
||||
@ -207,11 +209,11 @@ export function end_trim_to_sentence(input, include_newline = false) {
|
||||
last = i;
|
||||
break;
|
||||
}
|
||||
|
||||
if (last === -1) {
|
||||
return input.trimEnd();
|
||||
}
|
||||
|
||||
return input.substring(0, last + 1).trimEnd();
|
||||
}
|
||||
|
||||
if (last === -1) {
|
||||
return input.trimEnd();
|
||||
}
|
||||
|
||||
return input.substring(0, last + 1).trimEnd();
|
||||
}
|
||||
|
Reference in New Issue
Block a user