Always add impersonate prompt last

This commit is contained in:
maver 2023-08-05 18:48:02 +02:00
parent dd89009ecd
commit a8ee723853

View File

@ -523,6 +523,7 @@ function populateChatCompletion (prompts, chatCompletion, {bias, quietPrompt, ty
// Character and world information
addToChatCompletion('worldInfoBefore');
addToChatCompletion('main');
addToChatCompletion('worldInfoAfter');
addToChatCompletion('charDescription');
addToChatCompletion('charPersonality');
@ -531,6 +532,9 @@ function populateChatCompletion (prompts, chatCompletion, {bias, quietPrompt, ty
// Collection of control prompts that will always be positioned last
const controlPrompts = new MessageCollection('controlPrompts');
const impersonateMessage = Message.fromPrompt(prompts.get('impersonate')) ?? null;
if (type === 'impersonate') controlPrompts.add(impersonateMessage)
// Add quiet prompt to control prompts
// This should always be last, even in control prompts. Add all further control prompts BEFORE this prompt
const quietPromptMessage = Message.fromPrompt(prompts.get('quietPrompt')) ?? null;
@ -538,10 +542,6 @@ function populateChatCompletion (prompts, chatCompletion, {bias, quietPrompt, ty
chatCompletion.reserveBudget(controlPrompts);
// Add main prompt
if (type === "impersonate") addToChatCompletion('impersonate', 'main');
else addToChatCompletion('main');
// Add ordered system and user prompts
const systemPrompts = ['nsfw', 'jailbreak'];
const userPrompts = prompts.collection