Update existing slash commands to findChar - Update /gen to utilize new char find functionality - Update /go to utilize new char find functionality - Update /delname to utilize new char find functionality - Change /send persona search to equalsIgnoreCaseAndAccents
| @@ -461,12 +461,14 @@ export function initDefaultSlashCommands() { | |||
| 461 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | 461 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 462 | name: 'go', | 462 | name: 'go', |
| 463 | callback: goToCharacterCallback, | 463 | callback: goToCharacterCallback, |
| 464 | returns: 'The character/group name', | ||
| 464 | unnamedArgumentList: [ | 465 | unnamedArgumentList: [ |
| 465 | SlashCommandArgument.fromProps({ | 466 | SlashCommandArgument.fromProps({ |
| 466 | description: 'name', | 467 | description: 'Character name - or unique character identifier (avatar key)', |
| 467 | typeList: [ARGUMENT_TYPE.STRING], | 468 | typeList: [ARGUMENT_TYPE.STRING], |
| 468 | isRequired: true, | 469 | isRequired: true, |
| 469 | enumProvider: commonEnumProviders.characters('all'), | 470 | enumProvider: commonEnumProviders.characters('all'), |
| 471 | forceEnum: true, | ||
| 470 | }), | 472 | }), |
| 471 | ], | 473 | ], |
| 472 | helpString: 'Opens up a chat with the character or group by its name', | 474 | helpString: 'Opens up a chat with the character or group by its name', |
| @@ -531,7 +533,7 @@ export function initDefaultSlashCommands() { | |||
| 531 | namedArgumentList: [], | 533 | namedArgumentList: [], |
| 532 | unnamedArgumentList: [ | 534 | unnamedArgumentList: [ |
| 533 | SlashCommandArgument.fromProps({ | 535 | SlashCommandArgument.fromProps({ |
| 534 | description: 'name', | 536 | description: 'Character name - or unique character identifier (avatar key)', |
| 535 | typeList: [ARGUMENT_TYPE.STRING], | 537 | typeList: [ARGUMENT_TYPE.STRING], |
| 536 | isRequired: true, | 538 | isRequired: true, |
| 537 | enumProvider: commonEnumProviders.characters('character'), | 539 | enumProvider: commonEnumProviders.characters('character'), |
| @@ -936,7 +938,7 @@ export function initDefaultSlashCommands() { | |||
| 936 | ), | 938 | ), |
| 937 | SlashCommandNamedArgument.fromProps({ | 939 | SlashCommandNamedArgument.fromProps({ |
| 938 | name: 'name', | 940 | name: 'name', |
| 939 | description: 'in-prompt name for instruct mode', | 941 | description: 'in-prompt character name for instruct mode (or unique character identifier (avatar key), which will be used as name)', |
| 940 | typeList: [ARGUMENT_TYPE.STRING], | 942 | typeList: [ARGUMENT_TYPE.STRING], |
| 941 | defaultValue: 'System', | 943 | defaultValue: 'System', |
| 942 | enumProvider: () => [...commonEnumProviders.characters('character')(), new SlashCommandEnumValue('System', null, enumTypes.enum, enumIcons.assistant)], | 944 | enumProvider: () => [...commonEnumProviders.characters('character')(), new SlashCommandEnumValue('System', null, enumTypes.enum, enumIcons.assistant)], |
| @@ -2373,7 +2375,8 @@ async function generateCallback(args, value) { | |||
| 2373 | 2375 | ||
| 2374 | setEphemeralStopStrings(resolveVariable(args?.stop)); | 2376 | setEphemeralStopStrings(resolveVariable(args?.stop)); |
| 2375 | const name = args?.name; | 2377 | const name = args?.name; |
| 2376 | const result = await generateQuietPrompt(value, quietToLoud, false, '', name, length); | 2378 | const char = findChar({ name: name }); |
| 2379 | const result = await generateQuietPrompt(value, quietToLoud, false, '', char?.name ?? name, length); | ||
| 2377 | return result; | 2380 | return result; |
| 2378 | } catch (err) { | 2381 | } catch (err) { |
| 2379 | console.error('Error on /gen generation', err); | 2382 | console.error('Error on /gen generation', err); |
| @@ -2895,7 +2898,7 @@ function findPersonaByName(name) { | |||
| 2895 | } | 2898 | } |
| 2896 | 2899 | ||
| 2897 | for (const persona of Object.entries(power_user.personas)) { | 2900 | for (const persona of Object.entries(power_user.personas)) { |
| 2898 | if (persona[1].toLowerCase() === name.toLowerCase()) { | 2901 | if (equalsIgnoreCaseAndAccents(persona[1], name)) { |
| 2899 | return persona[0]; | 2902 | return persona[0]; |
| 2900 | } | 2903 | } |
| 2901 | } | 2904 | } |
| @@ -2938,7 +2941,9 @@ async function deleteMessagesByNameCallback(_, name) { | |||
| 2938 | return; | 2941 | return; |
| 2939 | } | 2942 | } |
| 2940 | 2943 | ||
| 2941 | name = name.trim(); | 2944 | // Search for a matching character to get the real name, or take the name provided |
| 2945 | const character = findChar({ name: name }); | ||
| 2946 | name = character?.name || name; | ||
| 2942 | 2947 | ||
| 2943 | const messagesToDelete = []; | 2948 | const messagesToDelete = []; |
| 2944 | chat.forEach((value) => { | 2949 | chat.forEach((value) => { |
| @@ -2996,31 +3001,28 @@ async function goToCharacterCallback(_, name) { | |||
| 2996 | return; | 3001 | return; |
| 2997 | } | 3002 | } |
| 2998 | 3003 | ||
| 2999 | name = name.trim(); | 3004 | const character = findChar({ name: name }); |
| 3000 | const characterIndex = findCharacterIndex(name); | 3005 | if (character) { |
| 3001 | 3006 | const chid = getCharIndex(character); | |
| 3002 | if (characterIndex !== -1) { | 3007 | await openChat(new String(chid)); |
| 3003 | await openChat(new String(characterIndex)); | 3008 | setActiveCharacter(character.avatar); |
| 3004 | setActiveCharacter(characters[characterIndex]?.avatar); | ||
| 3005 | setActiveGroup(null); | 3009 | setActiveGroup(null); |
| 3006 | return characters[characterIndex]?.name; | 3010 | return character.name; |
| 3007 | } else { | 3011 | } |
| 3008 | const group = groups.find(it => it.name.toLowerCase() == name.toLowerCase()); | 3012 | const group = groups.find(it => equalsIgnoreCaseAndAccents(it.name, name)); |
| 3009 | if (group) { | 3013 | if (group) { |
| 3010 | await openGroupById(group.id); | 3014 | await openGroupById(group.id); |
| 3011 | setActiveCharacter(null); | 3015 | setActiveCharacter(null); |
| 3012 | setActiveGroup(group.id); | 3016 | setActiveGroup(group.id); |
| 3013 | return group.name; | 3017 | return group.name; |
| 3014 | } else { | 3018 | } |
| 3015 | console.warn(`No matches found for name "${name}"`); | 3019 | console.warn(`No matches found for name "${name}"`); |
| 3016 | return ''; | 3020 | return ''; |
| 3017 | } | 3021 | } |
| 3018 | } | ||
| 3019 | } | ||
| 3020 | 3022 | ||
| 3021 | async function openChat(id) { | 3023 | async function openChat(chid) { |
| 3022 | resetSelectedGroup(); | 3024 | resetSelectedGroup(); |
| 3023 | setCharacterId(id); | 3025 | setCharacterId(chid); |
| 3024 | await delay(1); | 3026 | await delay(1); |
| 3025 | await reloadCurrentChat(); | 3027 | await reloadCurrentChat(); |
| 3026 | } | 3028 | } |