Added group wrapper events
| @@ -495,6 +495,8 @@ export const event_types = { | |||
| 495 | GENERATE_AFTER_COMBINE_PROMPTS: 'generate_after_combine_prompts', | 495 | GENERATE_AFTER_COMBINE_PROMPTS: 'generate_after_combine_prompts', |
| 496 | GENERATE_AFTER_DATA: 'generate_after_data', | 496 | GENERATE_AFTER_DATA: 'generate_after_data', |
| 497 | GROUP_MEMBER_DRAFTED: 'group_member_drafted', | 497 | GROUP_MEMBER_DRAFTED: 'group_member_drafted', |
| 498 | GROUP_WRAPPER_STARTED: 'group_wrapper_started', | ||
| 499 | GROUP_WRAPPER_FINISHED: 'group_wrapper_finished', | ||
| 498 | WORLD_INFO_ACTIVATED: 'world_info_activated', | 500 | WORLD_INFO_ACTIVATED: 'world_info_activated', |
| 499 | TEXT_COMPLETION_SETTINGS_READY: 'text_completion_settings_ready', | 501 | TEXT_COMPLETION_SETTINGS_READY: 'text_completion_settings_ready', |
| 500 | CHAT_COMPLETION_SETTINGS_READY: 'chat_completion_settings_ready', | 502 | CHAT_COMPLETION_SETTINGS_READY: 'chat_completion_settings_ready', |
| @@ -3098,6 +3100,9 @@ export function baseChatReplace(value, name1, name2) { | |||
| 3098 | 3100 | ||
| 3099 | /** | 3101 | /** |
| 3100 | * Returns the character card fields for the current character. | 3102 | * Returns the character card fields for the current character. |
| 3103 | * @param {object} [options] | ||
| 3104 | * @param {number} [options.chid] Optional character index | ||
| 3105 | * | ||
| 3101 | * @typedef {object} CharacterCardFields | 3106 | * @typedef {object} CharacterCardFields |
| 3102 | * @property {string} system System prompt | 3107 | * @property {string} system System prompt |
| 3103 | * @property {string} mesExamples Message examples | 3108 | * @property {string} mesExamples Message examples |
| @@ -3110,7 +3115,9 @@ export function baseChatReplace(value, name1, name2) { | |||
| 3110 | * @property {string} charDepthPrompt Character depth note | 3115 | * @property {string} charDepthPrompt Character depth note |
| 3111 | * @returns {CharacterCardFields} Character card fields | 3116 | * @returns {CharacterCardFields} Character card fields |
| 3112 | */ | 3117 | */ |
| 3113 | export function getCharacterCardFields() { | 3118 | export function getCharacterCardFields({ chid = null } = {}) { |
| 3119 | const currentChid = chid ?? this_chid; | ||
| 3120 | |||
| 3114 | const result = { | 3121 | const result = { |
| 3115 | system: '', | 3122 | system: '', |
| 3116 | mesExamples: '', | 3123 | mesExamples: '', |
| @@ -3124,7 +3131,7 @@ export function getCharacterCardFields() { | |||
| 3124 | }; | 3131 | }; |
| 3125 | result.persona = baseChatReplace(power_user.persona_description?.trim(), name1, name2); | 3132 | result.persona = baseChatReplace(power_user.persona_description?.trim(), name1, name2); |
| 3126 | 3133 | ||
| 3127 | const character = characters[this_chid]; | 3134 | const character = characters[currentChid]; |
| 3128 | 3135 | ||
| 3129 | if (!character) { | 3136 | if (!character) { |
| 3130 | return result; | 3137 | return result; |
| @@ -3141,7 +3148,7 @@ export function getCharacterCardFields() { | |||
| 3141 | result.charDepthPrompt = baseChatReplace(character.data?.extensions?.depth_prompt?.prompt?.trim(), name1, name2); | 3148 | result.charDepthPrompt = baseChatReplace(character.data?.extensions?.depth_prompt?.prompt?.trim(), name1, name2); |
| 3142 | 3149 | ||
| 3143 | if (selected_group) { | 3150 | if (selected_group) { |
| 3144 | const groupCards = getGroupCharacterCards(selected_group, Number(this_chid)); | 3151 | const groupCards = getGroupCharacterCards(selected_group, Number(currentChid)); |
| 3145 | 3152 | ||
| 3146 | if (groupCards) { | 3153 | if (groupCards) { |
| 3147 | result.description = groupCards.description; | 3154 | result.description = groupCards.description; |
| @@ -904,6 +904,7 @@ async function generateGroupWrapper(by_auto_mode, type = null, params = {}) { | |||
| 904 | groupChatQueueOrder.set(characters[activatedMembers[i]].avatar, i + 1); | 904 | groupChatQueueOrder.set(characters[activatedMembers[i]].avatar, i + 1); |
| 905 | } | 905 | } |
| 906 | } | 906 | } |
| 907 | await eventSource.emit(event_types.GROUP_WRAPPER_STARTED, { selected_group, type }); | ||
| 907 | // now the real generation begins: cycle through every activated character | 908 | // now the real generation begins: cycle through every activated character |
| 908 | for (const chId of activatedMembers) { | 909 | for (const chId of activatedMembers) { |
| 909 | throwIfAborted(); | 910 | throwIfAborted(); |
| @@ -942,6 +943,7 @@ async function generateGroupWrapper(by_auto_mode, type = null, params = {}) { | |||
| 942 | setCharacterName(''); | 943 | setCharacterName(''); |
| 943 | activateSendButtons(); | 944 | activateSendButtons(); |
| 944 | showSwipeButtons(); | 945 | showSwipeButtons(); |
| 946 | await eventSource.emit(event_types.GROUP_WRAPPER_FINISHED, { selected_group, type }); | ||
| 945 | } | 947 | } |
| 946 | 948 | ||
| 947 | return Promise.resolve(textResult); | 949 | return Promise.resolve(textResult); |