mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-02-26 08:58:09 +01:00
toggle to skip WI&AN insertion in Summary's prompt
This commit is contained in:
parent
7be3718a36
commit
6b5aa9d06e
@ -1906,15 +1906,18 @@ function getStoppingStrings(isImpersonate) {
|
||||
/**
|
||||
* Background generation based on the provided prompt.
|
||||
* @param {string} quiet_prompt Instruction prompt for the AI
|
||||
* @param {boolean} quietToLoud Whether a message should be sent in a foreground (loud) or background (quiet) mode
|
||||
* @param {boolean} quietToLoud Whether the message should be sent in a foreground (loud) or background (quiet) mode
|
||||
* @param {boolean} skipWIAN whether to skip addition of World Info and Author's Note into the prompt
|
||||
* @returns
|
||||
*/
|
||||
export async function generateQuietPrompt(quiet_prompt, quietToLoud) {
|
||||
export async function generateQuietPrompt(quiet_prompt, quietToLoud, skipWIAN) {
|
||||
console.log('got into genQuietPrompt')
|
||||
const skipWIANvalue = skipWIAN
|
||||
return await new Promise(
|
||||
async function promptPromise(resolve, reject) {
|
||||
if (quietToLoud === true) {
|
||||
try {
|
||||
await Generate('quiet', { resolve, reject, quiet_prompt, quietToLoud: true, force_name2: true, });
|
||||
await Generate('quiet', { resolve, reject, quiet_prompt, quietToLoud: true, skipWIAN: skipWIAN, force_name2: true, });
|
||||
}
|
||||
catch {
|
||||
reject();
|
||||
@ -1922,7 +1925,8 @@ export async function generateQuietPrompt(quiet_prompt, quietToLoud) {
|
||||
}
|
||||
else {
|
||||
try {
|
||||
await Generate('quiet', { resolve, reject, quiet_prompt, quietToLoud: false, force_name2: true, });
|
||||
console.log('going to generate non-QuietToLoud')
|
||||
await Generate('quiet', { resolve, reject, quiet_prompt, quietToLoud: false, skipWIAN: skipWIAN, force_name2: true, });
|
||||
}
|
||||
catch {
|
||||
reject();
|
||||
@ -2346,8 +2350,8 @@ class StreamingProcessor {
|
||||
}
|
||||
}
|
||||
|
||||
async function Generate(type, { automatic_trigger, force_name2, resolve, reject, quiet_prompt, quietToLoud, force_chid, signal } = {}, dryRun = false) {
|
||||
//console.log('Generate entered');
|
||||
async function Generate(type, { automatic_trigger, force_name2, resolve, reject, quiet_prompt, quietToLoud, skipWIAN, force_chid, signal } = {}, dryRun = false) {
|
||||
console.log('Generate entered');
|
||||
setGenerationProgress(0);
|
||||
generation_started = new Date();
|
||||
|
||||
@ -2623,14 +2627,20 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
|
||||
// Set non-WI AN
|
||||
setFloatingPrompt();
|
||||
// Add WI to prompt (and also inject WI to AN value via hijack)
|
||||
|
||||
let { worldInfoString, worldInfoBefore, worldInfoAfter, worldInfoDepth } = await getWorldInfoPrompt(chat2, this_max_context);
|
||||
|
||||
// Add all depth WI entries to prompt
|
||||
if (Array.isArray(worldInfoDepth)) {
|
||||
worldInfoDepth.forEach((e) => {
|
||||
const joinedEntries = e.entries.join("\n");
|
||||
setExtensionPrompt(`customDepthWI-${e.depth}`, joinedEntries, extension_prompt_types.IN_CHAT, e.depth)
|
||||
});
|
||||
if (skipWIAN !== true) {
|
||||
console.log('skipWIAN not active, adding WIAN')
|
||||
// Add all depth WI entries to prompt
|
||||
if (Array.isArray(worldInfoDepth)) {
|
||||
worldInfoDepth.forEach((e) => {
|
||||
const joinedEntries = e.entries.join("\n");
|
||||
setExtensionPrompt(`customDepthWI-${e.depth}`, joinedEntries, extension_prompt_types.IN_CHAT, e.depth)
|
||||
});
|
||||
}
|
||||
} else {
|
||||
console.log('skipping WIAN')
|
||||
}
|
||||
|
||||
// Add persona description to prompt
|
||||
@ -2967,7 +2977,7 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
|
||||
|
||||
// TODO: Move zero-depth anchor append to work like CFG and bias appends
|
||||
if (zeroDepthAnchor?.length && !isContinue) {
|
||||
console.log(/\s/.test(finalMesSend[finalMesSend.length - 1].message.slice(-1)))
|
||||
console.debug(/\s/.test(finalMesSend[finalMesSend.length - 1].message.slice(-1)))
|
||||
finalMesSend[finalMesSend.length - 1].message +=
|
||||
/\s/.test(finalMesSend[finalMesSend.length - 1].message.slice(-1))
|
||||
? zeroDepthAnchor
|
||||
@ -3268,7 +3278,7 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
|
||||
// regenerate with character speech reenforced
|
||||
// to make sure we leave on swipe type while also adding the name2 appendage
|
||||
setTimeout(() => {
|
||||
Generate(type, { automatic_trigger, force_name2: true, resolve, reject, quiet_prompt, force_chid });
|
||||
Generate(type, { automatic_trigger, force_name2: true, resolve, reject, quiet_prompt, skipWIAN, force_chid });
|
||||
}, generate_loop_counter * 1000);
|
||||
}
|
||||
|
||||
|
@ -63,6 +63,7 @@ const defaultSettings = {
|
||||
maxLengthPenalty: 4,
|
||||
lengthPenaltyStep: 0.1,
|
||||
memoryFrozen: false,
|
||||
SkipWIAN: false,
|
||||
source: summary_sources.extras,
|
||||
prompt: defaultPrompt,
|
||||
template: defaultTemplate,
|
||||
@ -100,6 +101,7 @@ function loadSettings() {
|
||||
$('#memory_temperature').val(extension_settings.memory.temperature).trigger('input');
|
||||
$('#memory_length_penalty').val(extension_settings.memory.lengthPenalty).trigger('input');
|
||||
$('#memory_frozen').prop('checked', extension_settings.memory.memoryFrozen).trigger('input');
|
||||
$('#memory_skipWIAN').prop('checked', extension_settings.memory.SkipWIAN).trigger('input');
|
||||
$('#memory_prompt').val(extension_settings.memory.prompt).trigger('input');
|
||||
$('#memory_prompt_words').val(extension_settings.memory.promptWords).trigger('input');
|
||||
$('#memory_prompt_interval').val(extension_settings.memory.promptInterval).trigger('input');
|
||||
@ -170,6 +172,12 @@ function onMemoryFrozenInput() {
|
||||
saveSettingsDebounced();
|
||||
}
|
||||
|
||||
function onMemorySkipWIANInput() {
|
||||
const value = Boolean($(this).prop('checked'));
|
||||
extension_settings.memory.SkipWIAN = value;
|
||||
saveSettingsDebounced();
|
||||
}
|
||||
|
||||
function onMemoryPromptWordsInput() {
|
||||
const value = $(this).val();
|
||||
extension_settings.memory.promptWords = Number(value);
|
||||
@ -311,13 +319,15 @@ async function onChatEvent() {
|
||||
async function forceSummarizeChat() {
|
||||
const context = getContext();
|
||||
|
||||
const skipWIAN = extension_settings.memory.SkipWIAN
|
||||
console.log(`Skipping WIAN? ${skipWIAN}`)
|
||||
if (!context.chatId) {
|
||||
toastr.warning('No chat selected');
|
||||
return;
|
||||
}
|
||||
|
||||
toastr.info('Summarizing chat...', 'Please wait');
|
||||
const value = await summarizeChatMain(context, true);
|
||||
const value = await summarizeChatMain(context, true, skipWIAN);
|
||||
|
||||
if (!value) {
|
||||
toastr.warning('Failed to summarize chat');
|
||||
@ -326,19 +336,21 @@ async function forceSummarizeChat() {
|
||||
}
|
||||
|
||||
async function summarizeChat(context) {
|
||||
const skipWIAN = extension_settings.memory.SkipWIAN
|
||||
switch (extension_settings.memory.source) {
|
||||
case summary_sources.extras:
|
||||
await summarizeChatExtras(context);
|
||||
break;
|
||||
case summary_sources.main:
|
||||
await summarizeChatMain(context, false);
|
||||
await summarizeChatMain(context, false, skipWIAN);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
async function summarizeChatMain(context, force) {
|
||||
async function summarizeChatMain(context, force, skipWIAN) {
|
||||
|
||||
if (extension_settings.memory.promptInterval === 0 && !force) {
|
||||
console.debug('Prompt interval is set to 0, skipping summarization');
|
||||
return;
|
||||
@ -397,8 +409,8 @@ async function summarizeChatMain(context, force) {
|
||||
console.debug('Summarization prompt is empty. Skipping summarization.');
|
||||
return;
|
||||
}
|
||||
|
||||
const summary = await generateQuietPrompt(prompt, false);
|
||||
console.log('sending summary prompt')
|
||||
const summary = await generateQuietPrompt(prompt, false, skipWIAN);
|
||||
const newContext = getContext();
|
||||
|
||||
// something changed during summarization request
|
||||
@ -606,6 +618,7 @@ function setupListeners() {
|
||||
$('#memory_temperature').off('click').on('input', onMemoryTemperatureInput);
|
||||
$('#memory_length_penalty').off('click').on('input', onMemoryLengthPenaltyInput);
|
||||
$('#memory_frozen').off('click').on('input', onMemoryFrozenInput);
|
||||
$('#memory_skipWIAN').off('click').on('input', onMemorySkipWIANInput);
|
||||
$('#summary_source').off('click').on('change', onSummarySourceChange);
|
||||
$('#memory_prompt_words').off('click').on('input', onMemoryPromptWordsInput);
|
||||
$('#memory_prompt_interval').off('click').on('input', onMemoryPromptIntervalInput);
|
||||
@ -648,10 +661,11 @@ jQuery(function () {
|
||||
<textarea id="memory_contents" class="text_pole textarea_compact" rows="6" placeholder="Summary will be generated here..."></textarea>
|
||||
<div class="memory_contents_controls">
|
||||
<div id="memory_force_summarize" class="menu_button menu_button_icon">
|
||||
<i class="fa-solid fa-database"></i>
|
||||
<span>Summarize now</span>
|
||||
</div>
|
||||
<i class="fa-solid fa-database"></i>
|
||||
<span>Summarize now</span>
|
||||
</div>
|
||||
<label for="memory_frozen"><input id="memory_frozen" type="checkbox" />Pause</label>
|
||||
<label for="memory_skipWIAN"><input id="memory_skipWIAN" type="checkbox" />No WI/AN</label>
|
||||
</div>
|
||||
<div class="memory_contents_controls">
|
||||
<div id="summarySettingsBlockToggle" class="menu_button">Settings</div>
|
||||
|
@ -8,7 +8,8 @@
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
label[for="memory_frozen"] {
|
||||
label[for="memory_frozen"],
|
||||
label[for="memory_skipWIAN"] {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin: 0 !important;
|
||||
@ -23,4 +24,4 @@ label[for="memory_frozen"] input {
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user