Added Persona Description and System Prompt to Story String

This commit is contained in:
Stefan Daniel Schwarz
2023-08-20 16:08:54 +02:00
parent 7528a3828a
commit 2fb86c8ebd
9 changed files with 30 additions and 43 deletions

View File

@ -66,7 +66,6 @@ import {
pygmalion_options,
tokenizers,
formatInstructModeChat,
formatInstructStoryString,
formatInstructModePrompt,
persona_description_positions,
loadMovingUIState,
@ -2069,9 +2068,8 @@ function getPersonaDescription(storyString) {
switch (power_user.persona_description_position) {
case persona_description_positions.BEFORE_CHAR:
return `${substituteParams(power_user.persona_description)}\n${storyString}`;
case persona_description_positions.AFTER_CHAR:
return `${storyString}${substituteParams(power_user.persona_description)}\n`;
return storyString;
default:
if (shouldWIAddPrompt) {
const originalAN = extension_prompts[NOTE_MODULE_NAME].value
@ -2527,9 +2525,11 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
const scenarioText = chat_metadata['scenario'] || characters[this_chid].scenario;
let charDescription = baseChatReplace(characters[this_chid].description.trim(), name1, name2);
let charPersonality = baseChatReplace(characters[this_chid].personality.trim(), name1, name2);
let personaDescription = baseChatReplace(power_user.persona_description.trim(), name1, name2);
let Scenario = baseChatReplace(scenarioText.trim(), name1, name2);
let mesExamples = baseChatReplace(characters[this_chid].mes_example.trim(), name1, name2);
let systemPrompt = power_user.prefer_character_prompt ? baseChatReplace(characters[this_chid].data?.system_prompt?.trim(), name1, name2) : '';
systemPrompt = power_user.prefer_character_prompt && systemPrompt ? systemPrompt : baseChatReplace(power_user.instruct.system_prompt, name1, name2);
let jailbreakPrompt = power_user.prefer_character_jailbreak ? baseChatReplace(characters[this_chid].data?.post_history_instructions?.trim(), name1, name2) : '';
// Parse example messages
@ -2570,7 +2570,9 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
const storyStringParams = {
description: charDescription,
personality: charPersonality,
persona: personaDescription,
scenario: Scenario,
system: isInstruct ? systemPrompt : '',
char: name2,
user: name1,
};
@ -2639,11 +2641,6 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
storyString = worldInfoBefore + storyString + worldInfoAfter;
}
// Format the instruction string
if (isInstruct) {
storyString = formatInstructStoryString(storyString, systemPrompt);
}
if (main_api === 'openai') {
message_already_generated = ''; // OpenAI doesn't have multigen
setOpenAIMessages(coreChat);
@ -8003,7 +8000,7 @@ $(document).ready(function () {
const enabled = $("#use-mancer-api-checkbox").prop("checked");
$("#mancer_api_subpanel").toggle(enabled);
$("#tgwebui_api_subpanel").toggle(!enabled);
api_use_mancer_webui = enabled;
saveSettingsDebounced();
getStatus();