mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Do not generate group responses on dry run
This commit is contained in:
@ -2309,9 +2309,28 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
|
|||||||
reject = () => { };
|
reject = () => { };
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selected_group && !is_group_generating) {
|
if (selected_group && !is_group_generating && !dryRun) {
|
||||||
generateGroupWrapper(false, type, { resolve, reject, quiet_prompt, force_chid, signal: abortController.signal });
|
generateGroupWrapper(false, type, { resolve, reject, quiet_prompt, force_chid, signal: abortController.signal });
|
||||||
return;
|
return;
|
||||||
|
} else if (selected_group && !is_group_generating && dryRun) {
|
||||||
|
const characterIndexMap = new Map(characters.map((char, index) => [char.avatar, index]));
|
||||||
|
const group = groups.find((x) => x.id === selected_group);
|
||||||
|
|
||||||
|
const enabledMembers = group.members.reduce((acc, member) => {
|
||||||
|
if (!group.disabled_members.includes(member) && !acc.includes(member)) {
|
||||||
|
acc.push(member);
|
||||||
|
}
|
||||||
|
return acc;
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const memberIds = enabledMembers
|
||||||
|
.map((member) => characterIndexMap.get(member))
|
||||||
|
.filter((index) => index !== undefined);
|
||||||
|
|
||||||
|
if (memberIds.length > 0) {
|
||||||
|
setCharacterId(memberIds[0]);
|
||||||
|
setCharacterName('');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (true === dryRun ||
|
if (true === dryRun ||
|
||||||
|
@ -139,7 +139,7 @@ class PromptCollection {
|
|||||||
/**
|
/**
|
||||||
* Retrieves the index of a Prompt instance in the collection by its identifier.
|
* Retrieves the index of a Prompt instance in the collection by its identifier.
|
||||||
*
|
*
|
||||||
* @param {string} identifier - The identifier of the Prompt instance to find.
|
* @param {null} identifier - The identifier of the Prompt instance to find.
|
||||||
* @returns {number} The index of the Prompt instance in the collection, or -1 if not found.
|
* @returns {number} The index of the Prompt instance in the collection, or -1 if not found.
|
||||||
*/
|
*/
|
||||||
index(identifier) {
|
index(identifier) {
|
||||||
@ -1589,12 +1589,7 @@ const openAiDefaultPromptList = [
|
|||||||
|
|
||||||
const defaultPromptManagerSettings = {
|
const defaultPromptManagerSettings = {
|
||||||
prompt_manager_settings: {
|
prompt_manager_settings: {
|
||||||
showAdvancedSettings: false,
|
showAdvancedSettings: false
|
||||||
utilityPrompts: {
|
|
||||||
newChat: '[Start a new Chat]',
|
|
||||||
newGroupChat: '[Start a new group chat. Group members: {{names}}]',
|
|
||||||
newExampleChat: '[Start a new Chat]',
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -635,7 +635,7 @@ function prepareOpenAIMessages({
|
|||||||
extensionPrompts,
|
extensionPrompts,
|
||||||
cyclePrompt
|
cyclePrompt
|
||||||
} = {}, dryRun) {
|
} = {}, dryRun) {
|
||||||
// When there is no character selected, there is no way to accurately calculate tokens
|
// Without a character selected, there is no way to accurately calculate tokens
|
||||||
if (!promptManager.activeCharacter && dryRun) return [null, false];
|
if (!promptManager.activeCharacter && dryRun) return [null, false];
|
||||||
|
|
||||||
const prompts = promptManager.getPromptCollection();
|
const prompts = promptManager.getPromptCollection();
|
||||||
@ -723,7 +723,7 @@ function prepareOpenAIMessages({
|
|||||||
promptManager.populateTokenHandler(messages);
|
promptManager.populateTokenHandler(messages);
|
||||||
promptManager.setMessages(messages);
|
promptManager.setMessages(messages);
|
||||||
|
|
||||||
// All information are up-to-date, render without dry-run.
|
// All information are up-to-date, render.
|
||||||
if (false === dryRun) promptManager.render(false);
|
if (false === dryRun) promptManager.render(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user