From 12a36341f8c7ff1f38610ef09028a1d30256ecae Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Sat, 30 Mar 2024 11:50:20 +0200 Subject: [PATCH] Fix newline trimming for the last message --- public/script.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/public/script.js b/public/script.js index 04fb0238d..7d1f85bdb 100644 --- a/public/script.js +++ b/public/script.js @@ -3505,15 +3505,18 @@ async function Generate(type, { automatic_trigger, force_name2, quiet_prompt, qu console.debug('generating prompt'); chatString = ''; arrMes = arrMes.reverse(); - arrMes.forEach(function (item, i, arr) {// For added anchors and others + arrMes.forEach(function (item, i, arr) { // OAI doesn't need all of this if (main_api === 'openai') { return; } - // Cohee: I'm not even sure what this is for anymore + // Cohee: This removes a newline from the end of the last message in the context + // Last prompt line will add a newline if it's not a continuation if (i === arrMes.length - 1 && type !== 'continue') { - item = item.replace(/\n?$/, ''); + if (!isInstruct || power_user.instruct.wrap) { + item = item.replace(/\n?$/, ''); + } } mesSend[mesSend.length] = { message: item, extensionPrompts: [] };