From 19ee831d82de38e5abcb979b2b7c42e220f9d2fe Mon Sep 17 00:00:00 2001 From: maver Date: Sun, 16 Jul 2023 20:06:58 +0200 Subject: [PATCH] Prevent prompt manager initialization more than once --- public/scripts/openai.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/public/scripts/openai.js b/public/scripts/openai.js index 8a64cb25b..915d88073 100644 --- a/public/scripts/openai.js +++ b/public/scripts/openai.js @@ -294,18 +294,17 @@ function setOpenAIMessageExamples(mesExamplesArray) { } function setupOpenAIPromptManager(openAiSettings) { + // Do not set up prompt manager more than once + if (promptManager) return true; + promptManager = new PromptManager(); + const configuration = { prefix: 'completion_', containerIdentifier: 'completion_prompt_manager', listIdentifier: 'completion_prompt_manager_list', toggleDisabled: ['main'], draggable: true, - defaultPrompts: { - main: default_main_prompt, - nsfw: default_nsfw_prompt, - jailbreak: default_jailbreak_prompt - } }; promptManager.saveServiceSettings = () => { @@ -612,7 +611,6 @@ function populateChatCompletion (prompts, chatCompletion, {bias, quietPrompt, ty * Take a configuration object and prepares messages for a chat with OpenAI's chat completion API. * Handles prompts, prepares chat history, manages token budget, and processes various user settings. * - * @async * @param {Object} options - The options for the function. * @param {string} options.name2 - The second name to be used in the messages. * @param {string} options.charDescription - Description of the character.