Merge pull request #3187 from InspectorCaracal/fix-double-prefix Fix example messages being double-prefixed for group chats
Signed| @@ -431,7 +431,8 @@ export function formatInstructModeExamples(mesExamplesArray, name1, name2) { | ||
| 431 | 431 | return mesExamplesArray.map(x => x.replace(/<START>\n/i, blockHeading)); |
| 432 | 432 | } |
| 433 | 433 | |
| 434 | 434 | 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); | |
| 435 | 436 | |
| 436 | 437 | let inputPrefix = power_user.instruct.input_sequence || ''; |
| 437 | 438 | let outputPrefix = power_user.instruct.output_sequence || ''; |
| @@ -463,7 +464,7 @@ export function formatInstructModeExamples(mesExamplesArray, name1, name2) { | ||
| 463 | 464 | |
| 464 | 465 | for (const item of mesExamplesArray) { |
| 465 | 466 | const cleanedItem = item.replace(/<START>/i, '{Example Dialogue:}').replace(/\r/gm, ''); |
| 466 | 467 | const blockExamples = parseExampleIntoIndividual(cleanedItem, includeGroupNames); |
| 467 | 468 | |
| 468 | 469 | if (blockExamples.length === 0) { |
| 469 | 470 | continue; |
| @@ -474,8 +475,9 @@ export function formatInstructModeExamples(mesExamplesArray, name1, name2) { | ||
| 474 | 475 | } |
| 475 | 476 | |
| 476 | 477 | for (const example of blockExamples) { |
| 478 | + // If group names were already included, we don't want to add an additional prefix | |
| 477 | 479 | // If force group/persona names is set, we should override the include names for the user placeholder |
| 478 | 480 | const includeThisName = (includeNames && !includeGroupNames) || (power_user.instruct.names_behavior === names_behavior_types.FORCE && example.name == 'example_user'); |
| 479 | 481 | |
| 480 | 482 | const prefix = example.name == 'example_user' ? inputPrefix : outputPrefix; |
| 481 | 483 | const suffix = example.name == 'example_user' ? inputSuffix : outputSuffix; |
| @@ -489,7 +491,6 @@ export function formatInstructModeExamples(mesExamplesArray, name1, name2) { | ||
| 489 | 491 | if (formattedExamples.length === 0) { |
| 490 | 492 | return mesExamplesArray.map(x => x.replace(/<START>\n/i, blockHeading)); |
| 491 | 493 | } |
| 492 | - | |
| 493 | 494 | return formattedExamples; |
| 494 | 495 | } |
| 495 | 496 | |