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