Fixes to group join examples parsing

This commit is contained in:
Cohee
2024-12-15 18:09:17 +02:00
parent e49301308c
commit 2d66b7204a
2 changed files with 23 additions and 6 deletions

View File

@ -423,14 +423,20 @@ export function getGroupCharacterCards(groupId, characterId) {
* @param {string} value Value to replace
* @param {string} characterName Name of the character
* @param {string} fieldName Name of the field
* @param {function(string): string} [preprocess] Preprocess function
* @returns {string} Prepared text
* */
function replaceAndPrepareForJoin(value, characterName, fieldName) {
function replaceAndPrepareForJoin(value, characterName, fieldName, preprocess = null) {
value = value.trim();
if (!value) {
return '';
}
// Run preprocess function
if (typeof preprocess === 'function') {
value = preprocess(value);
}
// Prepare and replace prefixes
const prefix = customBaseChatReplace(group.generation_mode_join_prefix, fieldName, characterName);
const suffix = customBaseChatReplace(group.generation_mode_join_suffix, fieldName, characterName);
@ -465,7 +471,7 @@ export function getGroupCharacterCards(groupId, characterId) {
descriptions.push(replaceAndPrepareForJoin(character.description, character.name, 'Description'));
personalities.push(replaceAndPrepareForJoin(character.personality, character.name, 'Personality'));
scenarios.push(replaceAndPrepareForJoin(character.scenario, character.name, 'Scenario'));
mesExamplesArray.push(replaceAndPrepareForJoin(character.mes_example, character.name, 'Example Messages'));
mesExamplesArray.push(replaceAndPrepareForJoin(character.mes_example, character.name, 'Example Messages', (x) => !x.startsWith('<START>') ? `<START>\n${x}` : x));
}
const description = descriptions.filter(x => x.length).join('\n');