Prevent prompt manager initialization more than once

This commit is contained in:
maver 2023-07-16 20:06:58 +02:00
parent 67ef713826
commit 19ee831d82
1 changed files with 4 additions and 6 deletions

View File

@ -294,18 +294,17 @@ function setOpenAIMessageExamples(mesExamplesArray) {
} }
function setupOpenAIPromptManager(openAiSettings) { function setupOpenAIPromptManager(openAiSettings) {
// Do not set up prompt manager more than once
if (promptManager) return true;
promptManager = new PromptManager(); promptManager = new PromptManager();
const configuration = { const configuration = {
prefix: 'completion_', prefix: 'completion_',
containerIdentifier: 'completion_prompt_manager', containerIdentifier: 'completion_prompt_manager',
listIdentifier: 'completion_prompt_manager_list', listIdentifier: 'completion_prompt_manager_list',
toggleDisabled: ['main'], toggleDisabled: ['main'],
draggable: true, draggable: true,
defaultPrompts: {
main: default_main_prompt,
nsfw: default_nsfw_prompt,
jailbreak: default_jailbreak_prompt
}
}; };
promptManager.saveServiceSettings = () => { 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. * 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. * Handles prompts, prepares chat history, manages token budget, and processes various user settings.
* *
* @async
* @param {Object} options - The options for the function. * @param {Object} options - The options for the function.
* @param {string} options.name2 - The second name to be used in the messages. * @param {string} options.name2 - The second name to be used in the messages.
* @param {string} options.charDescription - Description of the character. * @param {string} options.charDescription - Description of the character.