Added group wrapper events

6a4b8c38708911766507630eb473e49505a35168

bmen25124 <bmen25124@gmail.com>

2 files changed, +12 -3Ignore whitespace
public/script.js+10 -3
@@ -495,6 +495,8 @@ export const event_types = {
495495 GENERATE_AFTER_COMBINE_PROMPTS: 'generate_after_combine_prompts',
496496 GENERATE_AFTER_DATA: 'generate_after_data',
497497 GROUP_MEMBER_DRAFTED: 'group_member_drafted',
498+ GROUP_WRAPPER_STARTED: 'group_wrapper_started',
499+ GROUP_WRAPPER_FINISHED: 'group_wrapper_finished',
498500 WORLD_INFO_ACTIVATED: 'world_info_activated',
499501 TEXT_COMPLETION_SETTINGS_READY: 'text_completion_settings_ready',
500502 CHAT_COMPLETION_SETTINGS_READY: 'chat_completion_settings_ready',
@@ -3098,6 +3100,9 @@ export function baseChatReplace(value, name1, name2) {
30983100
30993101/**
31003102 * Returns the character card fields for the current character.
3103+ * @param {object} [options]
3104+ * @param {number} [options.chid] Optional character index
3105+ *
31013106 * @typedef {object} CharacterCardFields
31023107 * @property {string} system System prompt
31033108 * @property {string} mesExamples Message examples
@@ -3110,7 +3115,9 @@ export function baseChatReplace(value, name1, name2) {
31103115 * @property {string} charDepthPrompt Character depth note
31113116 * @returns {CharacterCardFields} Character card fields
31123117 */
31133118export function getCharacterCardFields({ chid = null } = {}) {
3119+ const currentChid = chid ?? this_chid;
3120+
31143121 const result = {
31153122 system: '',
31163123 mesExamples: '',
@@ -3124,7 +3131,7 @@ export function getCharacterCardFields() {
31243131 };
31253132 result.persona = baseChatReplace(power_user.persona_description?.trim(), name1, name2);
31263133
31273134 const character = characters[this_chidcurrentChid];
31283135
31293136 if (!character) {
31303137 return result;
@@ -3141,7 +3148,7 @@ export function getCharacterCardFields() {
31413148 result.charDepthPrompt = baseChatReplace(character.data?.extensions?.depth_prompt?.prompt?.trim(), name1, name2);
31423149
31433150 if (selected_group) {
31443151 const groupCards = getGroupCharacterCards(selected_group, Number(this_chidcurrentChid));
31453152
31463153 if (groupCards) {
31473154 result.description = groupCards.description;
public/scripts/group-chats.js+2 -0
@@ -904,6 +904,7 @@ async function generateGroupWrapper(by_auto_mode, type = null, params = {}) {
904904 groupChatQueueOrder.set(characters[activatedMembers[i]].avatar, i + 1);
905905 }
906906 }
907+ await eventSource.emit(event_types.GROUP_WRAPPER_STARTED, { selected_group, type });
907908 // now the real generation begins: cycle through every activated character
908909 for (const chId of activatedMembers) {
909910 throwIfAborted();
@@ -942,6 +943,7 @@ async function generateGroupWrapper(by_auto_mode, type = null, params = {}) {
942943 setCharacterName('');
943944 activateSendButtons();
944945 showSwipeButtons();
946+ await eventSource.emit(event_types.GROUP_WRAPPER_FINISHED, { selected_group, type });
945947 }
946948
947949 return Promise.resolve(textResult);