mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Added group wrapper events
This commit is contained in:
@@ -495,6 +495,8 @@ export const event_types = {
|
|||||||
GENERATE_AFTER_COMBINE_PROMPTS: 'generate_after_combine_prompts',
|
GENERATE_AFTER_COMBINE_PROMPTS: 'generate_after_combine_prompts',
|
||||||
GENERATE_AFTER_DATA: 'generate_after_data',
|
GENERATE_AFTER_DATA: 'generate_after_data',
|
||||||
GROUP_MEMBER_DRAFTED: 'group_member_drafted',
|
GROUP_MEMBER_DRAFTED: 'group_member_drafted',
|
||||||
|
GROUP_WRAPPER_STARTED: 'group_wrapper_started',
|
||||||
|
GROUP_WRAPPER_FINISHED: 'group_wrapper_finished',
|
||||||
WORLD_INFO_ACTIVATED: 'world_info_activated',
|
WORLD_INFO_ACTIVATED: 'world_info_activated',
|
||||||
TEXT_COMPLETION_SETTINGS_READY: 'text_completion_settings_ready',
|
TEXT_COMPLETION_SETTINGS_READY: 'text_completion_settings_ready',
|
||||||
CHAT_COMPLETION_SETTINGS_READY: 'chat_completion_settings_ready',
|
CHAT_COMPLETION_SETTINGS_READY: 'chat_completion_settings_ready',
|
||||||
@@ -3098,6 +3100,9 @@ export function baseChatReplace(value, name1, name2) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the character card fields for the current character.
|
* Returns the character card fields for the current character.
|
||||||
|
* @param {object} [options]
|
||||||
|
* @param {number} [options.chid] Optional character index
|
||||||
|
*
|
||||||
* @typedef {object} CharacterCardFields
|
* @typedef {object} CharacterCardFields
|
||||||
* @property {string} system System prompt
|
* @property {string} system System prompt
|
||||||
* @property {string} mesExamples Message examples
|
* @property {string} mesExamples Message examples
|
||||||
@@ -3110,7 +3115,9 @@ export function baseChatReplace(value, name1, name2) {
|
|||||||
* @property {string} charDepthPrompt Character depth note
|
* @property {string} charDepthPrompt Character depth note
|
||||||
* @returns {CharacterCardFields} Character card fields
|
* @returns {CharacterCardFields} Character card fields
|
||||||
*/
|
*/
|
||||||
export function getCharacterCardFields() {
|
export function getCharacterCardFields({ chid = null } = {}) {
|
||||||
|
const currentChid = chid ?? this_chid;
|
||||||
|
|
||||||
const result = {
|
const result = {
|
||||||
system: '',
|
system: '',
|
||||||
mesExamples: '',
|
mesExamples: '',
|
||||||
@@ -3124,7 +3131,7 @@ export function getCharacterCardFields() {
|
|||||||
};
|
};
|
||||||
result.persona = baseChatReplace(power_user.persona_description?.trim(), name1, name2);
|
result.persona = baseChatReplace(power_user.persona_description?.trim(), name1, name2);
|
||||||
|
|
||||||
const character = characters[this_chid];
|
const character = characters[currentChid];
|
||||||
|
|
||||||
if (!character) {
|
if (!character) {
|
||||||
return result;
|
return result;
|
||||||
@@ -3141,7 +3148,7 @@ export function getCharacterCardFields() {
|
|||||||
result.charDepthPrompt = baseChatReplace(character.data?.extensions?.depth_prompt?.prompt?.trim(), name1, name2);
|
result.charDepthPrompt = baseChatReplace(character.data?.extensions?.depth_prompt?.prompt?.trim(), name1, name2);
|
||||||
|
|
||||||
if (selected_group) {
|
if (selected_group) {
|
||||||
const groupCards = getGroupCharacterCards(selected_group, Number(this_chid));
|
const groupCards = getGroupCharacterCards(selected_group, Number(currentChid));
|
||||||
|
|
||||||
if (groupCards) {
|
if (groupCards) {
|
||||||
result.description = groupCards.description;
|
result.description = groupCards.description;
|
||||||
|
@@ -904,6 +904,7 @@ async function generateGroupWrapper(by_auto_mode, type = null, params = {}) {
|
|||||||
groupChatQueueOrder.set(characters[activatedMembers[i]].avatar, i + 1);
|
groupChatQueueOrder.set(characters[activatedMembers[i]].avatar, i + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
await eventSource.emit(event_types.GROUP_WRAPPER_STARTED, { selected_group, type });
|
||||||
// now the real generation begins: cycle through every activated character
|
// now the real generation begins: cycle through every activated character
|
||||||
for (const chId of activatedMembers) {
|
for (const chId of activatedMembers) {
|
||||||
throwIfAborted();
|
throwIfAborted();
|
||||||
@@ -942,6 +943,7 @@ async function generateGroupWrapper(by_auto_mode, type = null, params = {}) {
|
|||||||
setCharacterName('');
|
setCharacterName('');
|
||||||
activateSendButtons();
|
activateSendButtons();
|
||||||
showSwipeButtons();
|
showSwipeButtons();
|
||||||
|
await eventSource.emit(event_types.GROUP_WRAPPER_FINISHED, { selected_group, type });
|
||||||
}
|
}
|
||||||
|
|
||||||
return Promise.resolve(textResult);
|
return Promise.resolve(textResult);
|
||||||
|
Reference in New Issue
Block a user