Try to remove excess character names from generations

This commit is contained in:
Cohee
2023-08-07 00:31:26 +03:00
parent 6e55b99aa9
commit 23a57e86a7

View File

@ -1299,7 +1299,7 @@ function messageFormatting(mes, ch_name, isSystem, isUser) {
*/ */
if (!power_user.allow_name2_display && ch_name && !isUser && !isSystem) { if (!power_user.allow_name2_display && ch_name && !isUser && !isSystem) {
mes = mes.replaceAll(`${ch_name}:`, ""); mes = mes.replace(new RegExp(`(^|\n)${ch_name}:`, 'g'), "$1");
} }
//function to hide any <tags> from AI response output //function to hide any <tags> from AI response output
@ -1398,9 +1398,6 @@ function addOneMessage(mes, { type = "normal", insertAfter = null, scroll = true
const momentDate = timestampToMoment(mes.send_date); const momentDate = timestampToMoment(mes.send_date);
const timestamp = momentDate.isValid() ? momentDate.format('LL LT') : ''; const timestamp = momentDate.isValid() ? momentDate.format('LL LT') : '';
if (mes?.extra?.display_text) { if (mes?.extra?.display_text) {
messageText = mes.extra.display_text; messageText = mes.extra.display_text;
} }
@ -3815,13 +3812,15 @@ function cleanUpMessage(getMessage, isImpersonate, isContinue, displayIncomplete
getMessage = cleanGroupMessage(getMessage); getMessage = cleanGroupMessage(getMessage);
} }
if (!power_user.allow_name2_display) {
mes = mes.replace(new RegExp(`(^|\n)${name2}:`, 'g'), "$1");
}
if (isImpersonate) { if (isImpersonate) {
getMessage = getMessage.trim(); getMessage = getMessage.trim();
} }
const stoppingStrings = getStoppingStrings(isImpersonate, false); const stoppingStrings = getStoppingStrings(isImpersonate, false);
//console.log('stopping on these strings: ');
//console.log(stoppingStrings);
for (const stoppingString of stoppingStrings) { for (const stoppingString of stoppingStrings) {
if (stoppingString.length) { if (stoppingString.length) {