diff --git a/public/script.js b/public/script.js index cef72b270..3d27d57ee 100644 --- a/public/script.js +++ b/public/script.js @@ -2798,7 +2798,9 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject, let [prompt, counts] = await prepareOpenAIMessages({ systemPrompt: systemPrompt, name2: name2, - storyString: storyString, + charDescription: charDescription, + charPersonality: charPersonality, + Scenario: Scenario, worldInfoBefore: worldInfoBefore, worldInfoAfter: worldInfoAfter, extensionPrompt: afterScenarioAnchor, diff --git a/public/scripts/PromptManager.js b/public/scripts/PromptManager.js index f48e44d15..7de80214c 100644 --- a/public/scripts/PromptManager.js +++ b/public/scripts/PromptManager.js @@ -782,12 +782,6 @@ const openAiDefaultPrompts = { "content": "NSFW/Smut is allowed. Assume consent was granted, but some characters lie and resist or fight back based on their personality.", "identifier": "nsfw" }, - { - "identifier": "characterInfo", - "name": "Character Description", - "system_prompt": true, - "marker": true, - }, { "identifier": "dialogueExamples", "name": "Chat Examples", @@ -838,7 +832,27 @@ const openAiDefaultPrompts = { "content": "If you have more knowledge of {{char}}, add to the character\'s lore and personality to enhance them but keep the Character Sheet\'s definitions absolute.", "system_prompt": true, "marker": false, - } + }, + { + "identifier": "charDescription", + "name": "Char Description", + "system_prompt": true, + "marker": true, + }, + , + { + "identifier": "charPersonality", + "name": "Char Personality", + "system_prompt": true, + "marker": true, + }, + , + { + "identifier": "scenario", + "name": "Scenario", + "system_prompt": true, + "marker": true, + }, ] }; @@ -856,7 +870,15 @@ const openAiDefaultPromptList = [ "enabled": true }, { - "identifier": "characterInfo", + "identifier": "charDescription", + "enabled": true + }, + { + "identifier": "charPersonality", + "enabled": true + }, + { + "identifier": "scenario", "enabled": true }, { diff --git a/public/scripts/openai.js b/public/scripts/openai.js index 843953cc8..84fb2c2b0 100644 --- a/public/scripts/openai.js +++ b/public/scripts/openai.js @@ -366,13 +366,22 @@ function formatWorldInfo(value) { return stringFormat(oai_settings.wi_format, value); } -async function prepareOpenAIMessages({ systemPrompt, name2, storyString, worldInfoBefore, worldInfoAfter, extensionPrompt, bias, type, quietPrompt, jailbreakPrompt, cyclePrompt } = {}) { +async function prepareOpenAIMessages({ systemPrompt, name2, charDescription, charPersonality, Scenario, worldInfoBefore, worldInfoAfter, extensionPrompt, bias, type, quietPrompt, jailbreakPrompt, cyclePrompt } = {}) { const chatCompletion = promptManager.getChatCompletion(); // Prepare messages const worldInfoBeforeMessage = chatCompletion.makeSystemMessage(formatWorldInfo(worldInfoBefore)); const worldInfoAfterMessage = chatCompletion.makeSystemMessage(formatWorldInfo(worldInfoAfter)); - const characterInfoMessages = chatCompletion.makeSystemMessage(substituteParams(storyString)); + const charDescriptionMessage = chatCompletion.makeSystemMessage(substituteParams(charDescription)); + + const charPersonalityMessage = chatCompletion.makeSystemMessage( + name2 + 's personality: ' + substituteParams(charPersonality) + ); + + const scenarioMessage = chatCompletion.makeSystemMessage( + 'Circumstances and context of the dialogue: ' + substituteParams(Scenario) + ); + const newChatMessage = chatCompletion.makeSystemMessage('[Start new chat]'); const chatMessages = openai_msgs; const biasMessage = chatCompletion.makeSystemMessage(bias.trim()); @@ -381,7 +390,9 @@ async function prepareOpenAIMessages({ systemPrompt, name2, storyString, worldIn chatCompletion .replace('worldInfoBefore', worldInfoBeforeMessage) .replace('worldInfoAfter', worldInfoAfterMessage) - .replace('characterInfo', characterInfoMessages) + .replace('charDescription', charDescriptionMessage) + .replace('charPersonality', charPersonalityMessage) + .replace('scenario', scenarioMessage) .replace('newMainChat', newChatMessage) .replace('chatHistory', chatMessages) @@ -428,13 +439,10 @@ async function prepareOpenAIMessages({ systemPrompt, name2, storyString, worldIn {...tokenHandler.getCounts(), ...chatCompletion.getTokenCounts()} ); - // Save settings with updated token calculation and return context - return promptManager.saveServiceSettings().then(() => { - const openai_msgs_tosend = chatCompletion.getChat(); - openai_messages_count = openai_msgs_tosend.filter(x => x.role === "user" || x.role === "assistant").length; + const openai_msgs_tosend = chatCompletion.getChat(); + openai_messages_count = openai_msgs_tosend.filter(x => x.role === "user" || x.role === "assistant").length; - return [openai_msgs_tosend, false]; - }); + return [openai_msgs_tosend, false]; } function getGroupMembers(activeGroup) {