Allow disabling system marker prompts

This commit is contained in:
Cohee
2023-11-14 22:27:07 +02:00
parent 4277aac974
commit 314aca3f2c
2 changed files with 13 additions and 1 deletions

View File

@ -721,6 +721,12 @@ PromptManagerModule.prototype.getTokenHandler = function () {
return this.tokenHandler; return this.tokenHandler;
} }
PromptManagerModule.prototype.isPromptDisabledForActiveCharacter = function (identifier) {
const promptOrderEntry = this.getPromptOrderEntry(this.activeCharacter, identifier);
if (promptOrderEntry) return !promptOrderEntry.enabled;
return false;
}
/** /**
* Add a prompt to the current character's prompt list. * Add a prompt to the current character's prompt list.
* @param {object} prompt - The prompt to be added. * @param {object} prompt - The prompt to be added.
@ -859,7 +865,8 @@ PromptManagerModule.prototype.isPromptEditAllowed = function (prompt) {
* @returns {boolean} True if the prompt can be deleted, false otherwise. * @returns {boolean} True if the prompt can be deleted, false otherwise.
*/ */
PromptManagerModule.prototype.isPromptToggleAllowed = function (prompt) { PromptManagerModule.prototype.isPromptToggleAllowed = function (prompt) {
return prompt.marker ? false : !this.configuration.toggleDisabled.includes(prompt.identifier); const forceTogglePrompts = ['charDescription', 'charPersonality', 'scenario', 'personaDescription', 'worldInfoBefore', 'worldInfoAfter'];
return prompt.marker && !forceTogglePrompts.includes(prompt.identifier) ? false : !this.configuration.toggleDisabled.includes(prompt.identifier);
} }
/** /**

View File

@ -750,6 +750,11 @@ async function populateChatCompletion(prompts, chatCompletion, { bias, quietProm
// We need the prompts array to determine a position for the source. // We need the prompts array to determine a position for the source.
if (false === prompts.has(source)) return; if (false === prompts.has(source)) return;
if (promptManager.isPromptDisabledForActiveCharacter(source)) {
promptManager.log(`Skipping prompt ${source} because it is disabled`);
return;
}
const prompt = prompts.get(source); const prompt = prompts.get(source);
const index = target ? prompts.index(target) : prompts.index(source); const index = target ? prompts.index(target) : prompts.index(source);
const collection = new MessageCollection(source); const collection = new MessageCollection(source);