mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Add command and profile for custom stop strings
This commit is contained in:
@ -30,6 +30,7 @@ const CC_COMMANDS = [
|
|||||||
'api-url',
|
'api-url',
|
||||||
'model',
|
'model',
|
||||||
'proxy',
|
'proxy',
|
||||||
|
'stop-strings',
|
||||||
];
|
];
|
||||||
|
|
||||||
const TC_COMMANDS = [
|
const TC_COMMANDS = [
|
||||||
@ -43,6 +44,7 @@ const TC_COMMANDS = [
|
|||||||
'context',
|
'context',
|
||||||
'instruct-state',
|
'instruct-state',
|
||||||
'tokenizer',
|
'tokenizer',
|
||||||
|
'stop-strings',
|
||||||
];
|
];
|
||||||
|
|
||||||
const FANCY_NAMES = {
|
const FANCY_NAMES = {
|
||||||
@ -57,6 +59,7 @@ const FANCY_NAMES = {
|
|||||||
'instruct': 'Instruct Template',
|
'instruct': 'Instruct Template',
|
||||||
'context': 'Context Template',
|
'context': 'Context Template',
|
||||||
'tokenizer': 'Tokenizer',
|
'tokenizer': 'Tokenizer',
|
||||||
|
'stop-strings': 'Custom Stopping Strings',
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -138,6 +141,7 @@ const profilesProvider = () => [
|
|||||||
* @property {string} [context] Context Template
|
* @property {string} [context] Context Template
|
||||||
* @property {string} [instruct-state] Instruct Mode
|
* @property {string} [instruct-state] Instruct Mode
|
||||||
* @property {string} [tokenizer] Tokenizer
|
* @property {string} [tokenizer] Tokenizer
|
||||||
|
* @property {string} [stop-strings] Custom Stopping Strings
|
||||||
* @property {string[]} [exclude] Commands to exclude
|
* @property {string[]} [exclude] Commands to exclude
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -4072,4 +4072,34 @@ $(document).ready(() => {
|
|||||||
],
|
],
|
||||||
helpString: 'activates a movingUI preset by name',
|
helpString: 'activates a movingUI preset by name',
|
||||||
}));
|
}));
|
||||||
|
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
|
||||||
|
name: 'stop-strings',
|
||||||
|
aliases: ['stopping-strings'],
|
||||||
|
helpString: 'Sets a list of custom stopping strings. Gets the list if no value is provided.',
|
||||||
|
returns: ARGUMENT_TYPE.LIST,
|
||||||
|
unnamedArgumentList: [
|
||||||
|
SlashCommandArgument.fromProps({
|
||||||
|
description: 'list of strings',
|
||||||
|
typeList: [ARGUMENT_TYPE.LIST],
|
||||||
|
acceptsMultiple: false,
|
||||||
|
isRequired: false,
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
callback: (_, value) => {
|
||||||
|
if (String(value ?? '').trim()) {
|
||||||
|
const parsedValue = ((x) => { try { return JSON.parse(x.toString()); } catch { return null; } })(value);
|
||||||
|
if (!parsedValue || !Array.isArray(parsedValue)) {
|
||||||
|
throw new Error('Invalid list format. The value must be a JSON-serialized array of strings.');
|
||||||
|
}
|
||||||
|
parsedValue.forEach((item, index) => {
|
||||||
|
parsedValue[index] = String(item);
|
||||||
|
});
|
||||||
|
power_user.custom_stopping_strings = JSON.stringify(parsedValue);
|
||||||
|
$('#custom_stopping_strings').val(power_user.custom_stopping_strings);
|
||||||
|
saveSettingsDebounced();
|
||||||
|
}
|
||||||
|
|
||||||
|
return power_user.custom_stopping_strings;
|
||||||
|
},
|
||||||
|
}));
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user