mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Fix injection order (again)
This commit is contained in:
@ -456,12 +456,14 @@ function formatWorldInfo(value) {
|
|||||||
* @param {Prompt[]} prompts - Array containing injection prompts.
|
* @param {Prompt[]} prompts - Array containing injection prompts.
|
||||||
*/
|
*/
|
||||||
function populationInjectionPrompts(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
|
// Get prompts for current depth
|
||||||
const depthPrompts = prompts.filter(prompt => prompt.injection_depth === i && prompt.content);
|
const depthPrompts = prompts.filter(prompt => prompt.injection_depth === i && prompt.content);
|
||||||
|
|
||||||
// Order of priority (most important go lower)
|
// Order of priority (most important go lower)
|
||||||
const roles = [ 'system', 'user', 'assistant'];
|
const roles = ['system', 'user', 'assistant'];
|
||||||
const roleMessages = [];
|
const roleMessages = [];
|
||||||
|
|
||||||
for (const role of roles) {
|
for (const role of roles) {
|
||||||
@ -478,7 +480,9 @@ function populationInjectionPrompts(prompts) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (roleMessages.length) {
|
if (roleMessages.length) {
|
||||||
openai_msgs.splice(i, 0, ...roleMessages);
|
const injectIdx = i + totalInsertedMessages;
|
||||||
|
openai_msgs.splice(injectIdx, 0, ...roleMessages);
|
||||||
|
totalInsertedMessages += roleMessages.length;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user