From 25b337f1249bf2691630f9b58e9193f41a6f281e Mon Sep 17 00:00:00 2001 From: Halsey1006 Date: Sat, 19 Aug 2023 23:11:53 -0700 Subject: [PATCH] Update nai-settings.js Does not add curly braces if Novel AI instruct format is already present in the supplied prompt. --- public/scripts/nai-settings.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/public/scripts/nai-settings.js b/public/scripts/nai-settings.js index 0dff75b3c..a3208162b 100644 --- a/public/scripts/nai-settings.js +++ b/public/scripts/nai-settings.js @@ -578,7 +578,7 @@ function calculateLogitBias() { } /** - * Transforms instruction into compatible format for Novel AI. + * Transforms instruction into compatible format for Novel AI if Novel AI instruct format not already detected. * 1. Instruction must begin and end with curly braces followed and preceded by a space. * 2. Instruction must not contain square brackets as it serves different purpose in NAI. * @param {string} prompt Original instruction prompt @@ -586,7 +586,10 @@ function calculateLogitBias() { */ export function adjustNovelInstructionPrompt(prompt) { const stripedPrompt = prompt.replace(/[\[\]]/g, '').trim(); - return `{ ${stripedPrompt} }`; + if (!stripedPrompt.includes('{ ')) { + return `{ ${stripedPrompt} }`; + } + return stripedPrompt; } export async function generateNovelWithStreaming(generate_data, signal) {