Instruct: Add Sequences as Stop Strings control (#4355) * Instruct: Add Sequences as Stop Strings control * lint fix
Signed| @@ -3885,6 +3885,10 @@ | ||
| 3885 | 3885 | <input id="instruct_macro" type="checkbox" /> |
| 3886 | 3886 | <small data-i18n="Replace Macro in Sequences">Replace Macro in Sequences</small> |
| 3887 | 3887 | </label> |
| 3888 | + <label for="instruct_sequences_as_stop_strings" class="checkbox_label"> | |
| 3889 | + <input id="instruct_sequences_as_stop_strings" type="checkbox" /> | |
| 3890 | + <small data-i18n="Sequences as Stop Strings">Sequences as Stop Strings</small> | |
| 3891 | + </label> | |
| 3888 | 3892 | <label for="instruct_skip_examples" class="checkbox_label"> |
| 3889 | 3893 | <input id="instruct_skip_examples" type="checkbox" /> |
| 3890 | 3894 | <small data-i18n="Skip Example Dialogues Formatting">Skip Example Dialogues Formatting</small> |
| @@ -7,7 +7,7 @@ import { | ||
| 7 | 7 | power_user, |
| 8 | 8 | context_presets, |
| 9 | 9 | } from './power-user.js'; |
| 10 | 10 | import { onlyUnique, regexFromString, resetScrollHeight } from './utils.js'; |
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | 13 | * @type {any[]} Instruct mode presets. |
| @@ -44,6 +44,7 @@ const controls = [ | ||
| 44 | 44 | { id: 'instruct_skip_examples', property: 'skip_examples', isCheckbox: true }, |
| 45 | 45 | { id: 'instruct_names_behavior', property: 'names_behavior', isCheckbox: false }, |
| 46 | 46 | { id: 'instruct_system_same_as_user', property: 'system_same_as_user', isCheckbox: true, trigger: true }, |
| 47 | + { id: 'instruct_sequences_as_stop_strings', property: 'sequences_as_stop_strings', isCheckbox: true }, | |
| 47 | 48 | ]; |
| 48 | 49 | |
| 49 | 50 | /** |
| @@ -79,6 +80,7 @@ function migrateInstructModeSettings(settings) { | ||
| 79 | 80 | skip_examples: false, |
| 80 | 81 | system_same_as_user: false, |
| 81 | 82 | names_behavior: names_behavior_types.FORCE, |
| 83 | + sequences_as_stop_strings: true, | |
| 82 | 84 | }; |
| 83 | 85 | |
| 84 | 86 | for (let key in defaults) { |
| @@ -321,15 +323,20 @@ export function getInstructStoppingSequences({ customInstruct = null, useStopStr | ||
| 321 | 323 | |
| 322 | 324 | const combined_sequence = [ |
| 323 | 325 | stop_sequence, |
| 326 | + ]; | |
| 327 | + | |
| 328 | + if (instruct.sequences_as_stop_strings) { | |
| 329 | + combined_sequence.push( | |
| 324 | 330 | input_sequence, |
| 325 | 331 | output_sequence, |
| 326 | 332 | first_output_sequence, |
| 327 | 333 | last_output_sequence, |
| 328 | 334 | system_sequence, |
| 329 | 335 | last_system_sequence, |
| 330 | - ].join('\n'); | |
| 336 | + ); | |
| 337 | + } | |
| 331 | 338 | |
| 332 | 339 | combined_sequence.splitjoin('\n').filter(split(line, index, self'\n') => self.indexOffilter(line) === indexonlyUnique).forEach(addInstructSequence); |
| 333 | 340 | } |
| 334 | 341 | |
| 335 | 342 | if (useStopStrings ?? power_user.context.use_stop_strings) { |
| @@ -239,6 +239,7 @@ export const power_user = { | ||
| 239 | 239 | system_same_as_user: false, |
| 240 | 240 | /** @deprecated Use output_suffix instead */ |
| 241 | 241 | separator_sequence: '', |
| 242 | + sequences_as_stop_strings: true, | |
| 242 | 243 | }, |
| 243 | 244 | |
| 244 | 245 | context: { |