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
This commit is contained in:
Cohee
2025-03-18 23:12:49 +02:00
committed by GitHub
parent c1697dc3b3
commit 7d034cba11

View File

@ -435,16 +435,18 @@ export function getGroupCharacterCards(groupId, characterId) {
* @param {string} value Value to replace
* @param {string} fieldName Name of the field
* @param {string} characterName Name of the character
* @param {boolean} trim Whether to trim the value
* @returns {string} Replaced text
* */
function customBaseChatReplace(value, fieldName, characterName) {
function customBaseChatReplace(value, fieldName, characterName, trim) {
if (!value) {
return '';
}
// We should do the custom field name replacement first, and then run it through the normal macro engine with provided names
value = value.replace(/<FIELDNAME>/gi, fieldName);
return baseChatReplace(value.trim(), name1, characterName);
value = trim ? value.trim() : value;
return baseChatReplace(value, name1, characterName);
}
/**
@ -467,13 +469,12 @@ export function getGroupCharacterCards(groupId, characterId) {
}
// Prepare and replace prefixes
const prefix = customBaseChatReplace(group.generation_mode_join_prefix, fieldName, characterName);
const suffix = customBaseChatReplace(group.generation_mode_join_suffix, fieldName, characterName);
const separator = power_user.instruct.wrap ? '\n' : '';
const prefix = customBaseChatReplace(group.generation_mode_join_prefix, fieldName, characterName, false);
const suffix = customBaseChatReplace(group.generation_mode_join_suffix, fieldName, characterName, false);
// Also run the macro replacement on the actual content
value = customBaseChatReplace(value, fieldName, characterName);
value = customBaseChatReplace(value, fieldName, characterName, true);
return `${prefix ? prefix + separator : ''}${value}${suffix ? separator + suffix : ''}`;
return `${prefix}${value}${suffix}`;
}
const scenarioOverride = chat_metadata['scenario'];