Add toggle for names as stop strings

Closes #2556
This commit is contained in:
Cohee 2024-07-28 22:22:36 +03:00
parent cacd570af3
commit 82a633da57
3 changed files with 27 additions and 17 deletions

View File

@ -3069,7 +3069,11 @@
</div> </div>
<label class="checkbox_label" title="Add Chat Start and Example Separator to a list of stopping strings." data-i18n="[title]Add Chat Start and Example Separator to a list of stopping strings."> <label class="checkbox_label" title="Add Chat Start and Example Separator to a list of stopping strings." data-i18n="[title]Add Chat Start and Example Separator to a list of stopping strings.">
<input id="context_use_stop_strings" type="checkbox" /> <input id="context_use_stop_strings" type="checkbox" />
<small data-i18n="Use as Stop Strings">Use as Stop Strings</small> <small data-i18n="Separators as Stop Strings">Separators as Stop Strings</small>
</label>
<label class="checkbox_label" title="Add Character and User names to a list of stopping strings." data-i18n="[title]Add Character and User names to a list of stopping strings.">
<input id="context_names_as_stop_strings" type="checkbox" />
<small data-i18n="Names as Stop Strings">Names as Stop Strings</small>
</label> </label>
<label class="checkbox_label" title="Includes Post-History Instructions at the end of the prompt, if defined in the character card AND ''Prefer Char. Instructions'' is enabled.&#10;THIS IS NOT RECOMMENDED FOR TEXT COMPLETION MODELS, CAN LEAD TO BAD OUTPUT." data-i18n="[title]context_allow_post_history_instructions"> <label class="checkbox_label" title="Includes Post-History Instructions at the end of the prompt, if defined in the character card AND ''Prefer Char. Instructions'' is enabled.&#10;THIS IS NOT RECOMMENDED FOR TEXT COMPLETION MODELS, CAN LEAD TO BAD OUTPUT." data-i18n="[title]context_allow_post_history_instructions">
<input id="context_allow_jailbreak" type="checkbox" /> <input id="context_allow_jailbreak" type="checkbox" />

View File

@ -2470,9 +2470,12 @@ export function substituteParams(content, _name1, _name2, _original, _group, _re
* @returns {string[]} Array of stopping strings * @returns {string[]} Array of stopping strings
*/ */
export function getStoppingStrings(isImpersonate, isContinue) { export function getStoppingStrings(isImpersonate, isContinue) {
const result = [];
if (power_user.context.names_as_stop_strings) {
const charString = `\n${name2}:`; const charString = `\n${name2}:`;
const userString = `\n${name1}:`; const userString = `\n${name1}:`;
const result = isImpersonate ? [charString] : [userString]; result.push(isImpersonate ? charString : userString);
result.push(userString); result.push(userString);
@ -2492,6 +2495,7 @@ export function getStoppingStrings(isImpersonate, isContinue) {
result.push(...names); result.push(...names);
} }
} }
}
result.push(...getInstructStoppingSequences()); result.push(...getInstructStoppingSequences());
result.push(...getCustomStoppingStrings()); result.push(...getCustomStoppingStrings());

View File

@ -242,6 +242,7 @@ let power_user = {
example_separator: defaultExampleSeparator, example_separator: defaultExampleSeparator,
use_stop_strings: true, use_stop_strings: true,
allow_jailbreak: false, allow_jailbreak: false,
names_as_stop_strings: true,
}, },
personas: {}, personas: {},
@ -347,6 +348,7 @@ const contextControls = [
{ id: 'context_chat_start', property: 'chat_start', isCheckbox: false, isGlobalSetting: false }, { id: 'context_chat_start', property: 'chat_start', isCheckbox: false, isGlobalSetting: false },
{ id: 'context_use_stop_strings', property: 'use_stop_strings', isCheckbox: true, isGlobalSetting: false, defaultValue: false }, { id: 'context_use_stop_strings', property: 'use_stop_strings', isCheckbox: true, isGlobalSetting: false, defaultValue: false },
{ id: 'context_allow_jailbreak', property: 'allow_jailbreak', isCheckbox: true, isGlobalSetting: false, defaultValue: false }, { id: 'context_allow_jailbreak', property: 'allow_jailbreak', isCheckbox: true, isGlobalSetting: false, defaultValue: false },
{ id: 'context_names_as_stop_strings', property: 'names_as_stop_strings', isCheckbox: true, isGlobalSetting: false, defaultValue: true },
// Existing power user settings // Existing power user settings
{ id: 'always-force-name2-checkbox', property: 'always_force_name2', isCheckbox: true, isGlobalSetting: true, defaultValue: true }, { id: 'always-force-name2-checkbox', property: 'always_force_name2', isCheckbox: true, isGlobalSetting: true, defaultValue: true },