Remove forced newline separator from group join wrappers (#3722) * Remove forced newline separator from group join wrappers * Remove unnecessary ternary * Do not trim field wrappers
Signed| @@ -435,16 +435,18 @@ export function getGroupCharacterCards(groupId, characterId) { | |||
| 435 | * @param {string} value Value to replace | 435 | * @param {string} value Value to replace |
| 436 | * @param {string} fieldName Name of the field | 436 | * @param {string} fieldName Name of the field |
| 437 | * @param {string} characterName Name of the character | 437 | * @param {string} characterName Name of the character |
| 438 | * @param {boolean} trim Whether to trim the value | ||
| 438 | * @returns {string} Replaced text | 439 | * @returns {string} Replaced text |
| 439 | * */ | 440 | * */ |
| 440 | function customBaseChatReplace(value, fieldName, characterName) { | 441 | function customBaseChatReplace(value, fieldName, characterName, trim) { |
| 441 | if (!value) { | 442 | if (!value) { |
| 442 | return ''; | 443 | return ''; |
| 443 | } | 444 | } |
| 444 | 445 | ||
| 445 | // We should do the custom field name replacement first, and then run it through the normal macro engine with provided names | 446 | // We should do the custom field name replacement first, and then run it through the normal macro engine with provided names |
| 446 | value = value.replace(/<FIELDNAME>/gi, fieldName); | 447 | value = value.replace(/<FIELDNAME>/gi, fieldName); |
| 447 | return baseChatReplace(value.trim(), name1, characterName); | 448 | value = trim ? value.trim() : value; |
| 449 | return baseChatReplace(value, name1, characterName); | ||
| 448 | } | 450 | } |
| 449 | 451 | ||
| 450 | /** | 452 | /** |
| @@ -467,13 +469,12 @@ export function getGroupCharacterCards(groupId, characterId) { | |||
| 467 | } | 469 | } |
| 468 | 470 | ||
| 469 | // Prepare and replace prefixes | 471 | // Prepare and replace prefixes |
| 470 | const prefix = customBaseChatReplace(group.generation_mode_join_prefix, fieldName, characterName); | 472 | const prefix = customBaseChatReplace(group.generation_mode_join_prefix, fieldName, characterName, false); |
| 471 | const suffix = customBaseChatReplace(group.generation_mode_join_suffix, fieldName, characterName); | 473 | const suffix = customBaseChatReplace(group.generation_mode_join_suffix, fieldName, characterName, false); |
| 472 | const separator = power_user.instruct.wrap ? '\n' : ''; | ||
| 473 | // Also run the macro replacement on the actual content | 474 | // Also run the macro replacement on the actual content |
| 474 | value = customBaseChatReplace(value, fieldName, characterName); | 475 | value = customBaseChatReplace(value, fieldName, characterName, true); |
| 475 | 476 | ||
| 476 | return `${prefix ? prefix + separator : ''}${value}${suffix ? separator + suffix : ''}`; | 477 | return `${prefix}${value}${suffix}`; |
| 477 | } | 478 | } |
| 478 | 479 | ||
| 479 | const scenarioOverride = chat_metadata['scenario']; | 480 | const scenarioOverride = chat_metadata['scenario']; |