mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Add support for authors note and summary extensions
This commit is contained in:
@ -2796,14 +2796,13 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
|
||||
}
|
||||
else if (main_api == 'openai') {
|
||||
let [prompt, counts] = await prepareOpenAIMessages({
|
||||
systemPrompt: systemPrompt,
|
||||
name2: name2,
|
||||
charDescription: charDescription,
|
||||
charPersonality: charPersonality,
|
||||
Scenario: Scenario,
|
||||
worldInfoBefore: worldInfoBefore,
|
||||
worldInfoAfter: worldInfoAfter,
|
||||
extensionPrompt: afterScenarioAnchor,
|
||||
extensionPrompts: extension_prompts,
|
||||
bias: promptBias,
|
||||
type: type,
|
||||
quietPrompt: quiet_prompt,
|
||||
|
@ -289,8 +289,6 @@ function setupOpenAIPromptManager(openAiSettings) {
|
||||
|
||||
promptManager.init(configuration, openAiSettings);
|
||||
promptManager.render();
|
||||
|
||||
|
||||
}
|
||||
|
||||
function generateOpenAIPromptCache() {
|
||||
@ -366,7 +364,7 @@ function formatWorldInfo(value) {
|
||||
return stringFormat(oai_settings.wi_format, value);
|
||||
}
|
||||
|
||||
async function prepareOpenAIMessages({ systemPrompt, name2, charDescription, charPersonality, Scenario, worldInfoBefore, worldInfoAfter, extensionPrompt, bias, type, quietPrompt, jailbreakPrompt, cyclePrompt } = {}) {
|
||||
async function prepareOpenAIMessages({ name2, charDescription, charPersonality, Scenario, worldInfoBefore, worldInfoAfter, bias, type, quietPrompt, extensionPrompts, cyclePrompt } = {}) {
|
||||
const chatCompletion = promptManager.getChatCompletion();
|
||||
|
||||
// Prepare messages
|
||||
@ -412,7 +410,16 @@ async function prepareOpenAIMessages({ systemPrompt, name2, charDescription, cha
|
||||
}
|
||||
|
||||
// Handle extension prompt
|
||||
if (extensionPrompt) chatCompletion.insertAfter('worldInfoAfter', 'extensionPrompt', chatCompletion.makeSystemMessage(substituteParams(extensionPrompt)));
|
||||
if (0 < extensionPrompts.length) {
|
||||
const summary = extensionPrompts['1_memory'];
|
||||
if (summary) chatCompletion.insertAfter('scenario', 'extensionSummary', chatCompletion.makeSystemMessage(substituteParams(summary)));
|
||||
|
||||
const authorsNote = extensionPrompts['2_floating_prompt'];
|
||||
if (authorsNote && (extension_prompt_types.AFTER_SCENARIO === authorsNote.position))
|
||||
chatCompletion.insertAfter('scenario', 'extensionAuthorsNote', chatCompletion.makeSystemMessage(substituteParams(authorsNote)));
|
||||
else
|
||||
chatCompletion.insertAfter('chatHistory', 'extensionAuthorsNote', chatCompletion.makeSystemMessage(substituteParams(authorsNote)));
|
||||
}
|
||||
|
||||
// Handle bias settings
|
||||
if (bias && bias.trim().length) chatCompletion.add(biasMessage);
|
||||
|
Reference in New Issue
Block a user