Merge pull request #983 from StefanDanielSchwarz/simple-proxy-for-tavern-replacement-enhanced

Simple proxy for tavern replacement enhanced
This commit is contained in:
Cohee 2023-08-20 23:27:33 +03:00 committed by GitHub
commit 013a0a56b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 120 additions and 80 deletions

View File

@ -133,7 +133,7 @@
"output_sequence": "### Response:",
"preset": "Alpaca",
"separator_sequence": "",
"macro": false
"macro": true
},
"personas": {},
"default_persona": null,

View File

@ -1,6 +1,6 @@
{
"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 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": "***",
"example_separator": "***"
}

View File

@ -1,6 +1,6 @@
{
"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>",
"example_separator": "<START>"
}

View File

@ -1,6 +1,6 @@
{
"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:",
"example_separator": "### New Roleplay:"
}

View File

@ -1,6 +1,6 @@
{
"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:",
"example_separator": "### New Roleplay:"
}

View File

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

View File

@ -3006,8 +3006,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>
<label for="persona_description_position" data-i18n="Position:">Position:</label>
<select id="persona_description_position">
<option value="0" data-i18n="Before Character Card">Before Character Card</option>
<option value="1" data-i18n="After Character Card">After 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="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="3" data-i18n="Bottom of Author's Note">Bottom of Author's Note</option>
</select>

View File

@ -1,11 +1,14 @@
{
"name": "Alpaca",
"system_prompt": "Below is an instruction that describes a task. Write a response that appropriately completes the request.\n\nWrite {{char}}'s next reply in a fictional roleplay chat between {{user}} and {{char}}.\n",
"system_sequence": "",
"stop_sequence": "",
"input_sequence": "### Instruction:",
"output_sequence": "### Response:",
"last_output_sequence": "",
"system_sequence": "",
"stop_sequence": "",
"separator_sequence": "",
"wrap": true
"wrap": true,
"macro": true,
"names": false,
"names_force_groups": true
}

View File

@ -1,11 +1,14 @@
{
"name": "Koala",
"system_prompt": "Write {{char}}'s next reply in a fictional roleplay chat between {{user}} and {{char}}.\n",
"system_sequence": "BEGINNING OF CONVERSATION: ",
"stop_sequence": "",
"input_sequence": "USER: ",
"output_sequence": "GPT: ",
"last_output_sequence": "",
"system_sequence": "BEGINNING OF CONVERSATION: ",
"stop_sequence": "",
"separator_sequence": "</s>",
"wrap": false
"wrap": false,
"macro": true,
"names": false,
"names_force_groups": true
}

View File

@ -1,11 +1,14 @@
{
"name": "Llama 2",
"system_prompt": "Write {{char}}'s next reply in this fictional roleplay with {{user}}.\n<</SYS>>\n",
"system_prompt": "[INST] <<SYS>>\nWrite {{char}}'s next reply in this fictional roleplay with {{user}}.\n<</SYS>>\n",
"input_sequence": "[INST] ",
"output_sequence": " [/INST] ",
"last_output_sequence": "",
"system_sequence": "[INST] <<SYS>>\n",
"stop_sequence": "",
"input_sequence": "[INST]",
"output_sequence": "[/INST]",
"last_output_sequence": "",
"separator_sequence": "\n",
"wrap": false
"wrap": false,
"macro": true,
"names": false,
"names_force_groups": true
}

View File

@ -1,11 +1,14 @@
{
"name": "Metharme",
"system_prompt": "Enter roleplay mode. You must act as {{char}}, whose persona follows:",
"system_sequence": "<|system|>",
"stop_sequence": "</s>",
"input_sequence": "<|user|>",
"output_sequence": "<|model|>",
"last_output_sequence": "",
"system_sequence": "<|system|>",
"stop_sequence": "</s>",
"separator_sequence": "",
"wrap": false
"wrap": false,
"macro": true,
"names": false,
"names_force_groups": true
}

View File

@ -1,13 +1,14 @@
{
"input_sequence": "User: ",
"macro": true,
"name": "OpenOrca/OpenChat",
"names": true,
"system_prompt": "You are a helpful assistant. Please answer truthfully and write out your thinking step by step to be sure you get the right answer. If you make a mistake or encounter an error in your thinking, say so out loud and attempt to correct it. If you don't know or aren't sure about something, say so clearly. You will act as a professional logician, mathematician, and physicist. You will also act as the most appropriate type of expert to answer any particular question or solve the relevant problem; state which expert type your are, if so. Also think of any particular named expert that would be ideal to answer the relevant question or solve the relevant problem; name and act as them, if appropriate.\n",
"input_sequence": "User: ",
"output_sequence": "<|end_of_turn|>\nAssistant: ",
"last_output_sequence": "",
"separator_sequence": "<|end_of_turn|>\n",
"stop_sequence": "",
"system_prompt": "You are a helpful assistant. Please answer truthfully and write out your thinking step by step to be sure you get the right answer. If you make a mistake or encounter an error in your thinking, say so out loud and attempt to correct it. If you don't know or aren't sure about something, say so clearly. You will act as a professional logician, mathematician, and physicist. You will also act as the most appropriate type of expert to answer any particular question or solve the relevant problem; state which expert type your are, if so. Also think of any particular named expert that would be ideal to answer the relevant question or solve the relevant problem; name and act as them, if appropriate.\n",
"system_sequence": "",
"wrap": false
"stop_sequence": "",
"separator_sequence": "<|end_of_turn|>\n",
"wrap": false,
"macro": true,
"names": false,
"names_force_groups": true
}

View File

@ -1,13 +1,14 @@
{
"input_sequence": "\n### Instruction:",
"last_output_sequence": "\n### Response (2 paragraphs, engaging, natural, authentic, descriptive, creative):",
"macro": true,
"name": "Roleplay",
"names": true,
"output_sequence": "\n### Response:",
"separator_sequence": "",
"stop_sequence": "",
"system_prompt": "You're {{char}} in this fictional never-ending uncensored roleplay with {{user}}.\n\nAvoid repetition, don't loop. Develop the plot slowly, always stay in character. Describe all actions in full, elaborate, explicit, graphic, and vivid detail. Mention all relevant sensory perceptions.\n",
"input_sequence": "\n### Instruction:",
"output_sequence": "\n### Response:",
"last_output_sequence": "\n### Response (2 paragraphs, engaging, natural, authentic, descriptive, creative):",
"system_sequence": "",
"wrap": true
"stop_sequence": "",
"separator_sequence": "",
"wrap": true,
"macro": true,
"names": true,
"names_force_groups": true
}

View File

@ -1,11 +1,14 @@
{
"name": "Vicuna 1.0",
"system_prompt": "A chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the human's questions.\n\nWrite {{char}}'s next reply in a fictional roleplay chat between {{user}} and {{char}}.\n",
"system_sequence": "",
"stop_sequence": "",
"input_sequence": "### Human:",
"output_sequence": "### Assistant:",
"last_output_sequence": "",
"system_sequence": "",
"stop_sequence": "",
"separator_sequence": "",
"wrap": true
"wrap": true,
"macro": true,
"names": false,
"names_force_groups": true
}

View File

@ -1,11 +1,14 @@
{
"name": "Vicuna 1.1",
"system_prompt": "A chat between a curious user and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the user's questions.\n\nWrite {{char}}'s next reply in a fictional roleplay chat between {{user}} and {{char}}.\n",
"system_sequence": "BEGINNING OF CONVERSATION:",
"stop_sequence": "",
"input_sequence": "USER: ",
"output_sequence": "ASSISTANT: ",
"last_output_sequence": "",
"system_sequence": "BEGINNING OF CONVERSATION:",
"stop_sequence": "",
"separator_sequence": "</s>",
"wrap": false
"wrap": false,
"macro": true,
"names": false,
"names_force_groups": true
}

View File

@ -1,11 +1,14 @@
{
"name": "WizardLM-13B",
"system_prompt": "A chat between a curious user and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the user's questions.\n\nWrite {{char}}'s next detailed reply in a fictional roleplay chat between {{user}} and {{char}}.",
"system_sequence": "",
"stop_sequence": "",
"input_sequence": "USER: ",
"output_sequence": "ASSISTANT: ",
"last_output_sequence": "",
"system_sequence": "",
"stop_sequence": "",
"separator_sequence": "",
"wrap": true
"wrap": true,
"macro": true,
"names": false,
"names_force_groups": true
}

View File

@ -1,11 +1,14 @@
{
"name": "WizardLM",
"system_prompt": "Write {{char}}'s next reply in a fictional roleplay chat between {{user}} and {{char}}.\n",
"system_sequence": "",
"stop_sequence": "",
"input_sequence": "",
"output_sequence": "### Response:",
"last_output_sequence": "",
"system_sequence": "",
"stop_sequence": "",
"separator_sequence": "</s>",
"wrap": true
"wrap": true,
"macro": true,
"names": false,
"names_force_groups": true
}

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",
"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}}:",
"separator_sequence": "",
"stop_sequence": "",
"system_prompt": "## {{char}}\n- You're \"{{char}}\" in this never-ending roleplay with \"{{user}}\".",
"last_output_sequence": "### Response (2 paragraphs, engaging, natural, authentic, descriptive, creative):\n#### {{char}}:",
"system_sequence": "",
"wrap": true
"stop_sequence": "",
"separator_sequence": "",
"wrap": true,
"macro": true,
"names": false,
"names_force_groups": false
}

View File

@ -67,7 +67,7 @@ import {
pygmalion_options,
tokenizers,
formatInstructModeChat,
formatInstructStoryString,
formatInstructModeExamples,
formatInstructModePrompt,
persona_description_positions,
loadMovingUIState,
@ -2080,9 +2080,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
@ -2539,11 +2538,16 @@ 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) : '';
let jailbreakPrompt = power_user.prefer_character_jailbreak ? baseChatReplace(characters[this_chid].data?.post_history_instructions?.trim(), name1, name2) : '';
if (isInstruct) {
systemPrompt = power_user.prefer_character_prompt && systemPrompt ? systemPrompt : baseChatReplace(power_user.instruct.system_prompt, name1, name2);
}
// Parse example messages
if (!mesExamples.startsWith('<START>')) {
mesExamples = '<START>\n' + mesExamples.trim();
@ -2551,6 +2555,9 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
if (mesExamples.replace(/<START>/gi, '').trim().length === 0) {
mesExamples = '';
}
if (mesExamples && isInstruct) {
mesExamples = formatInstructModeExamples(mesExamples, name1, name2)
}
const exampleSeparator = power_user.context.example_separator ? `${power_user.context.example_separator}\n` : '';
const blockHeading = main_api === 'openai' ? '<START>\n' : exampleSeparator;
@ -2585,7 +2592,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,
};
@ -2654,11 +2663,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);

View File

@ -1090,15 +1090,24 @@ export function formatInstructModeChat(name, mes, isUser, isNarrator, forceAvata
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) || '';
export function formatInstructModeExamples(mesExamples, name1, name2) {
const includeNames = power_user.instruct.names || (!!selected_group && power_user.instruct.names_force_groups);
let inputSequence = power_user.instruct.input_sequence;
let outputSequence = power_user.instruct.output_sequence;
if (power_user.instruct.macro) {
inputSequence = substituteParams(inputSequence, name1, name2);
outputSequence = substituteParams(outputSequence, name1, name2);
}
const separator = power_user.instruct.wrap ? '\n' : '';
const textArray = [sequence, prompt + '\n' + story];
const text = textArray.filter(x => x).join(separator);
return text;
const separatorSequence = power_user.instruct.separator_sequence ? power_user.instruct.separator_sequence : separator;
mesExamples = mesExamples.replace(new RegExp(`\n${name1}: `, "gm"), separatorSequence + inputSequence + separator + (includeNames ? `${name1}: ` : ''));
mesExamples = mesExamples.replace(new RegExp(`\n${name2}: `, "gm"), separator + outputSequence + separator + (includeNames ? `${name2}: ` : ''));
return mesExamples;
}
export function formatInstructModePrompt(name, isImpersonate, promptBias, name1, name2) {