Fix undefined array access for CFG prompt

This commit is contained in:
Cohee
2025-02-01 15:36:04 +02:00
parent 72e1dcb3f9
commit 3fe3430006

View File

@ -4467,6 +4467,9 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
// TODO: Make all extension prompts use an array/splice method
const lengthDiff = mesSend.length - cfgPrompt.depth;
const cfgDepth = lengthDiff >= 0 ? lengthDiff : 0;
if (!Array.isArray(finalMesSend[cfgDepth].extensionPrompts)) {
finalMesSend[cfgDepth].extensionPrompts = [];
}
finalMesSend[cfgDepth].extensionPrompts.push(`${cfgPrompt.value}\n`);
}
}