Fix injection order (again)

This commit is contained in:
Cohee
2023-10-11 22:56:17 +03:00
parent e2f0162e5a
commit 84098ae933

View File

@ -456,7 +456,9 @@ function formatWorldInfo(value) {
* @param {Prompt[]} prompts - Array containing injection prompts.
*/
function populationInjectionPrompts(prompts) {
for (let i = MAX_INJECTION_DEPTH; i >= 0; i--) {
let totalInsertedMessages = 0;
for (let i = 0; i <= MAX_INJECTION_DEPTH; i++) {
// Get prompts for current depth
const depthPrompts = prompts.filter(prompt => prompt.injection_depth === i && prompt.content);
@ -478,7 +480,9 @@ function populationInjectionPrompts(prompts) {
}
if (roleMessages.length) {
openai_msgs.splice(i, 0, ...roleMessages);
const injectIdx = i + totalInsertedMessages;
openai_msgs.splice(injectIdx, 0, ...roleMessages);
totalInsertedMessages += roleMessages.length;
}
}