mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-03-10 17:10:14 +01:00
Let prompt manager handle character and scenario prompts
This commit is contained in:
parent
29bc3c854f
commit
eb315993b4
@ -2798,7 +2798,9 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
|
|||||||
let [prompt, counts] = await prepareOpenAIMessages({
|
let [prompt, counts] = await prepareOpenAIMessages({
|
||||||
systemPrompt: systemPrompt,
|
systemPrompt: systemPrompt,
|
||||||
name2: name2,
|
name2: name2,
|
||||||
storyString: storyString,
|
charDescription: charDescription,
|
||||||
|
charPersonality: charPersonality,
|
||||||
|
Scenario: Scenario,
|
||||||
worldInfoBefore: worldInfoBefore,
|
worldInfoBefore: worldInfoBefore,
|
||||||
worldInfoAfter: worldInfoAfter,
|
worldInfoAfter: worldInfoAfter,
|
||||||
extensionPrompt: afterScenarioAnchor,
|
extensionPrompt: afterScenarioAnchor,
|
||||||
|
@ -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.",
|
"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": "nsfw"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"identifier": "characterInfo",
|
|
||||||
"name": "Character Description",
|
|
||||||
"system_prompt": true,
|
|
||||||
"marker": true,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"identifier": "dialogueExamples",
|
"identifier": "dialogueExamples",
|
||||||
"name": "Chat Examples",
|
"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.",
|
"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,
|
"system_prompt": true,
|
||||||
"marker": false,
|
"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
|
"enabled": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"identifier": "characterInfo",
|
"identifier": "charDescription",
|
||||||
|
"enabled": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"identifier": "charPersonality",
|
||||||
|
"enabled": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"identifier": "scenario",
|
||||||
"enabled": true
|
"enabled": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -366,13 +366,22 @@ function formatWorldInfo(value) {
|
|||||||
return stringFormat(oai_settings.wi_format, 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();
|
const chatCompletion = promptManager.getChatCompletion();
|
||||||
|
|
||||||
// Prepare messages
|
// Prepare messages
|
||||||
const worldInfoBeforeMessage = chatCompletion.makeSystemMessage(formatWorldInfo(worldInfoBefore));
|
const worldInfoBeforeMessage = chatCompletion.makeSystemMessage(formatWorldInfo(worldInfoBefore));
|
||||||
const worldInfoAfterMessage = chatCompletion.makeSystemMessage(formatWorldInfo(worldInfoAfter));
|
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 newChatMessage = chatCompletion.makeSystemMessage('[Start new chat]');
|
||||||
const chatMessages = openai_msgs;
|
const chatMessages = openai_msgs;
|
||||||
const biasMessage = chatCompletion.makeSystemMessage(bias.trim());
|
const biasMessage = chatCompletion.makeSystemMessage(bias.trim());
|
||||||
@ -381,7 +390,9 @@ async function prepareOpenAIMessages({ systemPrompt, name2, storyString, worldIn
|
|||||||
chatCompletion
|
chatCompletion
|
||||||
.replace('worldInfoBefore', worldInfoBeforeMessage)
|
.replace('worldInfoBefore', worldInfoBeforeMessage)
|
||||||
.replace('worldInfoAfter', worldInfoAfterMessage)
|
.replace('worldInfoAfter', worldInfoAfterMessage)
|
||||||
.replace('characterInfo', characterInfoMessages)
|
.replace('charDescription', charDescriptionMessage)
|
||||||
|
.replace('charPersonality', charPersonalityMessage)
|
||||||
|
.replace('scenario', scenarioMessage)
|
||||||
.replace('newMainChat', newChatMessage)
|
.replace('newMainChat', newChatMessage)
|
||||||
.replace('chatHistory', chatMessages)
|
.replace('chatHistory', chatMessages)
|
||||||
|
|
||||||
@ -428,13 +439,10 @@ async function prepareOpenAIMessages({ systemPrompt, name2, storyString, worldIn
|
|||||||
{...tokenHandler.getCounts(), ...chatCompletion.getTokenCounts()}
|
{...tokenHandler.getCounts(), ...chatCompletion.getTokenCounts()}
|
||||||
);
|
);
|
||||||
|
|
||||||
// Save settings with updated token calculation and return context
|
|
||||||
return promptManager.saveServiceSettings().then(() => {
|
|
||||||
const openai_msgs_tosend = chatCompletion.getChat();
|
const openai_msgs_tosend = chatCompletion.getChat();
|
||||||
openai_messages_count = openai_msgs_tosend.filter(x => x.role === "user" || x.role === "assistant").length;
|
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) {
|
function getGroupMembers(activeGroup) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user