Make context stop strings togglable

This commit is contained in:
Cohee 2023-12-01 23:06:37 +02:00
parent 9ad42025e5
commit a2f293b6af
3 changed files with 17 additions and 5 deletions

View File

@ -2178,6 +2178,10 @@
</div> </div>
</div> </div>
</div> </div>
<label class="checkbox_label" title="Add Chat Start and Example Separator to a list of stopping strings.">
<input id="context_use_stop_strings" type="checkbox" />
<small data-i18n="Use as Stop Strings">Use as Stop Strings</small>
</label>
</div> </div>
<div data-newbie-hidden class="inline-drawer wide100p flexFlowColumn margin-bot-10px" style="display:none;"> <div data-newbie-hidden class="inline-drawer wide100p flexFlowColumn margin-bot-10px" style="display:none;">

View File

@ -214,12 +214,14 @@ export function getInstructStoppingSequences() {
combined_sequence.split('\n').filter((line, index, self) => self.indexOf(line) === index).forEach(addInstructSequence); combined_sequence.split('\n').filter((line, index, self) => self.indexOf(line) === index).forEach(addInstructSequence);
} }
if (power_user.context.chat_start) { if (power_user.context.use_stop_strings) {
result.push(`\n${substituteParams(power_user.context.chat_start)}`); if (power_user.context.chat_start) {
} result.push(`\n${substituteParams(power_user.context.chat_start)}`);
}
if (power_user.context.example_separator) { if (power_user.context.example_separator) {
result.push(`\n${substituteParams(power_user.context.example_separator)}`); result.push(`\n${substituteParams(power_user.context.example_separator)}`);
}
} }
return result; return result;

View File

@ -206,6 +206,7 @@ let power_user = {
story_string: defaultStoryString, story_string: defaultStoryString,
chat_start: defaultChatStart, chat_start: defaultChatStart,
example_separator: defaultExampleSeparator, example_separator: defaultExampleSeparator,
use_stop_strings: true,
}, },
personas: {}, personas: {},
@ -271,6 +272,7 @@ const contextControls = [
{ id: "context_story_string", property: "story_string", isCheckbox: false, isGlobalSetting: false }, { id: "context_story_string", property: "story_string", isCheckbox: false, isGlobalSetting: false },
{ id: "context_example_separator", property: "example_separator", isCheckbox: false, isGlobalSetting: false }, { id: "context_example_separator", property: "example_separator", isCheckbox: false, isGlobalSetting: false },
{ 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: 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 },
@ -1595,6 +1597,10 @@ function loadContextSettings() {
return; return;
} }
if (control.defaultValue !== undefined && power_user.context[control.property] === undefined) {
power_user.context[control.property] = control.defaultValue;
}
if (control.isCheckbox) { if (control.isCheckbox) {
$element.prop('checked', power_user.context[control.property]); $element.prop('checked', power_user.context[control.property]);
} else { } else {