Merge pull request #3187 from InspectorCaracal/fix-double-prefix Fix example messages being double-prefixed for group chats

5c1a9a300313f662f4a24a0a33e2078a5c4204dc

Cohee <18619528+Cohee1207@users.noreply.github.com>

Signed
1 files changed, +5 -4Ignore whitespace
public/scripts/instruct-mode.js+5 -4
@@ -431,7 +431,8 @@ export function formatInstructModeExamples(mesExamplesArray, name1, name2) {
431431 return mesExamplesArray.map(x => x.replace(/<START>\n/i, blockHeading));
432432 }
433433
434434 const includeNames = power_user.instruct.names_behavior === names_behavior_types.ALWAYS || (!!selected_group && power_user.instruct.names_behavior === names_behavior_types.FORCE);
435+ const includeGroupNames = selected_group && [names_behavior_types.ALWAYS, names_behavior_types.FORCE].includes(power_user.instruct.names_behavior);
435436
436437 let inputPrefix = power_user.instruct.input_sequence || '';
437438 let outputPrefix = power_user.instruct.output_sequence || '';
@@ -463,7 +464,7 @@ export function formatInstructModeExamples(mesExamplesArray, name1, name2) {
463464
464465 for (const item of mesExamplesArray) {
465466 const cleanedItem = item.replace(/<START>/i, '{Example Dialogue:}').replace(/\r/gm, '');
466467 const blockExamples = parseExampleIntoIndividual(cleanedItem, includeGroupNames);
467468
468469 if (blockExamples.length === 0) {
469470 continue;
@@ -474,8 +475,9 @@ export function formatInstructModeExamples(mesExamplesArray, name1, name2) {
474475 }
475476
476477 for (const example of blockExamples) {
478+ // If group names were already included, we don't want to add an additional prefix
477479 // If force group/persona names is set, we should override the include names for the user placeholder
478480 const includeThisName = (includeNames && !includeGroupNames) || (power_user.instruct.names_behavior === names_behavior_types.FORCE && example.name == 'example_user');
479481
480482 const prefix = example.name == 'example_user' ? inputPrefix : outputPrefix;
481483 const suffix = example.name == 'example_user' ? inputSuffix : outputSuffix;
@@ -489,7 +491,6 @@ export function formatInstructModeExamples(mesExamplesArray, name1, name2) {
489491 if (formattedExamples.length === 0) {
490492 return mesExamplesArray.map(x => x.replace(/<START>\n/i, blockHeading));
491493 }
492-
493494 return formattedExamples;
494495}
495496