From 2d5b871f2a8a397ffbce0f02835759c0aa2f6552 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Fri, 29 Mar 2024 15:01:08 +0200 Subject: [PATCH] Fix array access --- public/script.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/public/script.js b/public/script.js index c2096a108..04fb0238d 100644 --- a/public/script.js +++ b/public/script.js @@ -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 for (const index of injectedIndices) { const item = chat2[index]; + + if (typeof item !== 'string') { + continue; + } + tokenCount += getTokenCount(item.replace(/\r/gm, '')); chatString = item + chatString; if (tokenCount < this_max_context) { @@ -3414,6 +3419,11 @@ async function Generate(type, { automatic_trigger, force_name2, quiet_prompt, qu } const item = chat2[i]; + + if (typeof item !== 'string') { + continue; + } + tokenCount += getTokenCount(item.replace(/\r/gm, '')); chatString = item + chatString; if (tokenCount < this_max_context) {