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

@ -1,6 +1,6 @@
{ {
"name": "Default", "name": "Default",
"story_string": "{{#if description}}{{description}}\n{{/if}}{{#if personality}}{{char}}'s personality: {{personality}}\n{{/if}}{{#if scenario}}Scenario: {{scenario}}{{/if}}", "story_string": "{{#if system}}{{system}}\n{{/if}}{{#if persona}}{{persona}}\n{{/if}}{{#if description}}{{description}}\n{{/if}}{{#if personality}}{{char}}'s personality: {{personality}}\n{{/if}}{{#if scenario}}Scenario: {{scenario}}\n{{/if}}",
"chat_start": "***", "chat_start": "***",
"example_separator": "***" "example_separator": "***"
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "Pygmalion", "name": "Pygmalion",
"story_string": "{{#if description}}{{{char}}}'s Persona: {{description}}{{/if}}\n{{#if personality}}Personality: {{personality}}{{/if}}\n{{#if scenario}}Scenario: {{scenario}}{{/if}}", "story_string": "{{#if system}}{{system}}\n{{/if}}{{#if description}}{{{char}}}'s Persona: {{description}}\n{{/if}}{{#if personality}}Personality: {{personality}}\n{{/if}}{{#if scenario}}Scenario: {{scenario}}\n{{/if}}{{#if persona}}{{persona}}\n{{/if}}",
"chat_start": "<START>", "chat_start": "<START>",
"example_separator": "<START>" "example_separator": "<START>"
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "Roleplay", "name": "Roleplay",
"story_string": "### Input:\n{{#if description}}{{description}}\n{{/if}}{{#if personality}}{{char}}'s personality: {{personality}}\n{{/if}}{{#if scenario}}Scenario: {{scenario}}{{/if}}", "story_string": "{{#if system}}{{system}}\n{{/if}}### Input:\n{{#if description}}{{description}}\n{{/if}}{{#if personality}}{{char}}'s personality: {{personality}}\n{{/if}}{{#if scenario}}Scenario: {{scenario}}\n{{/if}}{{#if persona}}{{persona}}\n{{/if}}",
"chat_start": "### New Roleplay:", "chat_start": "### New Roleplay:",
"example_separator": "### New Roleplay:" "example_separator": "### New Roleplay:"
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "simple-proxy-for-tavern", "name": "simple-proxy-for-tavern",
"story_string": "### Input:\n{{#if description}}{{description}}\n{{/if}}{{#if personality}}{{char}}'s personality: {{personality}}\n{{/if}}{{#if scenario}}Scenario: {{scenario}}\n{{/if}}### Response:\n(OOC) Understood. I will take this info into account for the roleplay. (end OOC)", "story_string": "## {{char}}\n- You're \"{{char}}\" in this never-ending roleplay with \"{{user}}\".\n### Input:\n{{#if system}}{{system}}\n{{/if}}{{#if description}}{{description}}\n{{/if}}{{#if personality}}{{char}}'s personality: {{personality}}\n{{/if}}{{#if scenario}}Scenario: {{scenario}}\n{{/if}}{{#if persona}}{{persona}}\n{{/if}}### Response:\n(OOC) Understood. I will take this info into account for the roleplay. (end OOC)",
"chat_start": "### New Roleplay:", "chat_start": "### New Roleplay:",
"example_separator": "### New Roleplay:" "example_separator": "### New Roleplay:"
} }

View File

@ -363,8 +363,8 @@
"Not Connected": "未连接", "Not Connected": "未连接",
"Persona Management": "用户角色设置", "Persona Management": "用户角色设置",
"Persona Description": "用户角色描述", "Persona Description": "用户角色描述",
"Before Character Card": "角色卡之前", "In Story String / Chat Completion: Before Character Card": "在故事串中 / Chat Completion: 角色卡之前",
"After Character Card": "角色卡之后", "In Story String / Chat Completion: After Character Card": "在故事串中 / Chat Completion: 角色卡之后",
"Top of Author's Note": "作者注释之前", "Top of Author's Note": "作者注释之前",
"Bottom of Author's Note": "作者注释之后", "Bottom of Author's Note": "作者注释之后",
"How do I use this?": "用户角色设置说明", "How do I use this?": "用户角色设置说明",
@ -915,8 +915,8 @@
"Not Connected": "NEEDS TRANSLATION", "Not Connected": "NEEDS TRANSLATION",
"Persona Management": "NEEDS TRANSLATION", "Persona Management": "NEEDS TRANSLATION",
"Persona Description": "NEEDS TRANSLATION", "Persona Description": "NEEDS TRANSLATION",
"Before Character Card": "NEEDS TRANSLATION", "In Story String / Chat Completion: Before Character Card": "NEEDS TRANSLATION",
"After Character Card": "NEEDS TRANSLATION", "In Story String / Chat Completion: After Character Card": "NEEDS TRANSLATION",
"Top of Author's Note": "NEEDS TRANSLATION", "Top of Author's Note": "NEEDS TRANSLATION",
"Bottom of Author's Note": "NEEDS TRANSLATION", "Bottom of Author's Note": "NEEDS TRANSLATION",
"How do I use this?": "NEEDS TRANSLATION", "How do I use this?": "NEEDS TRANSLATION",
@ -1472,8 +1472,8 @@
"Not Connected": "접속되지 않음", "Not Connected": "접속되지 않음",
"Persona Management": "주인공 관리", "Persona Management": "주인공 관리",
"Persona Description": "주인공 묘사", "Persona Description": "주인공 묘사",
"Before Character Card": "캐릭터 카드 앞에", "In Story String / Chat Completion: Before Character Card": "스토리 문자열에서 / 문장완성: 캐릭터 카드 앞에",
"After Character Card": "캐릭터 카드 다음에", "In Story String / Chat Completion: After Character Card": "스토리 문자열에서 / 문장완성: 캐릭터 카드 다음에",
"Top of Author's Note": "글쓴이 쪽지 위에", "Top of Author's Note": "글쓴이 쪽지 위에",
"Bottom of Author's Note": "글쓴이 쪽지 밑에", "Bottom of Author's Note": "글쓴이 쪽지 밑에",
"How do I use this?": "이건 어떻게 써먹나요?", "How do I use this?": "이건 어떻게 써먹나요?",
@ -2029,8 +2029,8 @@
"Not Connected": "Не подключено", "Not Connected": "Не подключено",
"Persona Management": "Управление Персоной", "Persona Management": "Управление Персоной",
"Persona Description": "Описание Персоны", "Persona Description": "Описание Персоны",
"Before Character Card": "Перед Карточкой Персонажа", "In Story String / Chat Completion: Before Character Card": "В строке истории / Дополнение диалога: Перед Карточкой Персонажа",
"After Character Card": "После Карточки Персонажа", "In Story String / Chat Completion: After Character Card": "В строке истории / Дополнение диалога: После Карточки Персонажа",
"Top of Author's Note": "Перед Авторскими Заметками", "Top of Author's Note": "Перед Авторскими Заметками",
"Bottom of Author's Note": "После Авторских Заметок", "Bottom of Author's Note": "После Авторских Заметок",
"How do I use this?": "Как мне это использовать?", "How do I use this?": "Как мне это использовать?",

View File

@ -2994,8 +2994,8 @@
<textarea id="persona_description" name="persona_description" placeholder="Example:&#10;[{{user}} is a 28-year-old Romanian cat girl.]" class="text_pole textarea_compact" maxlength="5000" value="" autocomplete="off" rows="4"></textarea> <textarea id="persona_description" name="persona_description" placeholder="Example:&#10;[{{user}} is a 28-year-old Romanian cat girl.]" class="text_pole textarea_compact" maxlength="5000" value="" autocomplete="off" rows="4"></textarea>
<label for="persona_description_position" data-i18n="Position:">Position:</label> <label for="persona_description_position" data-i18n="Position:">Position:</label>
<select id="persona_description_position"> <select id="persona_description_position">
<option value="0" data-i18n="Before Character Card">Before Character Card</option> <option value="0" data-i18n="In Story String / Chat Completion: Before Character Card">In Story String / Chat Completion: Before Character Card</option>
<option value="1" data-i18n="After Character Card">After Character Card</option> <option value="1" data-i18n="In Story String / Chat Completion: After Character Card">In Story String / Chat Completion: After Character Card</option>
<option value="2" data-i18n="Top of Author's Note">Top of Author's Note</option> <option value="2" data-i18n="Top of Author's Note">Top of Author's Note</option>
<option value="3" data-i18n="Bottom of Author's Note">Bottom of Author's Note</option> <option value="3" data-i18n="Bottom of Author's Note">Bottom of Author's Note</option>
</select> </select>

View File

@ -1,13 +1,14 @@
{ {
"input_sequence": "### Instruction:\n#### {{user}}:",
"last_output_sequence": "### Response (2 paragraphs, engaging, natural, authentic, descriptive, creative):\n#### {{char}}:",
"macro": true,
"name": "simple-proxy-for-tavern", "name": "simple-proxy-for-tavern",
"names": false, "system_prompt": "[System note: Write one reply only. Do not decide what {{user}} says or does. Write at least one paragraph, up to four. Be descriptive and immersive, providing vivid details about {{char}}'s actions, emotions, and the environment. Write with a high degree of complexity and burstiness. Do not repeat this message.]",
"input_sequence": "### Instruction:\n#### {{user}}:",
"output_sequence": "### Response:\n#### {{char}}:", "output_sequence": "### Response:\n#### {{char}}:",
"separator_sequence": "", "last_output_sequence": "### Response (2 paragraphs, engaging, natural, authentic, descriptive, creative):\n#### {{char}}:",
"stop_sequence": "",
"system_prompt": "## {{char}}\n- You're \"{{char}}\" in this never-ending roleplay with \"{{user}}\".",
"system_sequence": "", "system_sequence": "",
"wrap": true "stop_sequence": "",
"separator_sequence": "",
"wrap": true,
"macro": true,
"names": false,
"names_force_groups": false
} }

View File

@ -66,7 +66,6 @@ import {
pygmalion_options, pygmalion_options,
tokenizers, tokenizers,
formatInstructModeChat, formatInstructModeChat,
formatInstructStoryString,
formatInstructModePrompt, formatInstructModePrompt,
persona_description_positions, persona_description_positions,
loadMovingUIState, loadMovingUIState,
@ -2069,9 +2068,8 @@ function getPersonaDescription(storyString) {
switch (power_user.persona_description_position) { switch (power_user.persona_description_position) {
case persona_description_positions.BEFORE_CHAR: case persona_description_positions.BEFORE_CHAR:
return `${substituteParams(power_user.persona_description)}\n${storyString}`;
case persona_description_positions.AFTER_CHAR: case persona_description_positions.AFTER_CHAR:
return `${storyString}${substituteParams(power_user.persona_description)}\n`; return storyString;
default: default:
if (shouldWIAddPrompt) { if (shouldWIAddPrompt) {
const originalAN = extension_prompts[NOTE_MODULE_NAME].value 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; const scenarioText = chat_metadata['scenario'] || characters[this_chid].scenario;
let charDescription = baseChatReplace(characters[this_chid].description.trim(), name1, name2); let charDescription = baseChatReplace(characters[this_chid].description.trim(), name1, name2);
let charPersonality = baseChatReplace(characters[this_chid].personality.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 Scenario = baseChatReplace(scenarioText.trim(), name1, name2);
let mesExamples = baseChatReplace(characters[this_chid].mes_example.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) : ''; 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) : ''; let jailbreakPrompt = power_user.prefer_character_jailbreak ? baseChatReplace(characters[this_chid].data?.post_history_instructions?.trim(), name1, name2) : '';
// Parse example messages // Parse example messages
@ -2570,7 +2570,9 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
const storyStringParams = { const storyStringParams = {
description: charDescription, description: charDescription,
personality: charPersonality, personality: charPersonality,
persona: personaDescription,
scenario: Scenario, scenario: Scenario,
system: isInstruct ? systemPrompt : '',
char: name2, char: name2,
user: name1, user: name1,
}; };
@ -2639,11 +2641,6 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
storyString = worldInfoBefore + storyString + worldInfoAfter; storyString = worldInfoBefore + storyString + worldInfoAfter;
} }
// Format the instruction string
if (isInstruct) {
storyString = formatInstructStoryString(storyString, systemPrompt);
}
if (main_api === 'openai') { if (main_api === 'openai') {
message_already_generated = ''; // OpenAI doesn't have multigen message_already_generated = ''; // OpenAI doesn't have multigen
setOpenAIMessages(coreChat); setOpenAIMessages(coreChat);

View File

@ -1088,17 +1088,6 @@ export function formatInstructModeChat(name, mes, isUser, isNarrator, forceAvata
return text; return text;
} }
export function formatInstructStoryString(story, systemPrompt) {
// If the character has a custom system prompt AND user has it preferred, use that instead of the default
systemPrompt = power_user.prefer_character_prompt && systemPrompt ? systemPrompt : power_user.instruct.system_prompt;
const sequence = power_user.instruct.system_sequence || '';
const prompt = substituteParams(systemPrompt, name1, name2, power_user.instruct.system_prompt) || '';
const separator = power_user.instruct.wrap ? '\n' : '';
const textArray = [sequence, prompt + '\n' + story];
const text = textArray.filter(x => x).join(separator);
return text;
}
export function formatInstructModePrompt(name, isImpersonate, promptBias, name1, name2) { export function formatInstructModePrompt(name, isImpersonate, promptBias, name1, name2) {
const includeNames = power_user.instruct.names || (!!selected_group && power_user.instruct.names_force_groups); const includeNames = power_user.instruct.names || (!!selected_group && power_user.instruct.names_force_groups);
const getOutputSequence = () => power_user.instruct.last_output_sequence || power_user.instruct.output_sequence; const getOutputSequence = () => power_user.instruct.last_output_sequence || power_user.instruct.output_sequence;