Fix array access

This commit is contained in:
Cohee 2024-03-29 15:01:08 +02:00
parent 3c733b3243
commit 2d5b871f2a
1 changed files with 10 additions and 0 deletions

View File

@ -3389,6 +3389,11 @@ async function Generate(type, { automatic_trigger, force_name2, quiet_prompt, qu
// If it doesn't fit - user shot himself in the foot // If it doesn't fit - user shot himself in the foot
for (const index of injectedIndices) { for (const index of injectedIndices) {
const item = chat2[index]; const item = chat2[index];
if (typeof item !== 'string') {
continue;
}
tokenCount += getTokenCount(item.replace(/\r/gm, '')); tokenCount += getTokenCount(item.replace(/\r/gm, ''));
chatString = item + chatString; chatString = item + chatString;
if (tokenCount < this_max_context) { if (tokenCount < this_max_context) {
@ -3414,6 +3419,11 @@ async function Generate(type, { automatic_trigger, force_name2, quiet_prompt, qu
} }
const item = chat2[i]; const item = chat2[i];
if (typeof item !== 'string') {
continue;
}
tokenCount += getTokenCount(item.replace(/\r/gm, '')); tokenCount += getTokenCount(item.replace(/\r/gm, ''));
chatString = item + chatString; chatString = item + chatString;
if (tokenCount < this_max_context) { if (tokenCount < this_max_context) {