Respect # limit for ephemeral stop strings

This commit is contained in:
Cohee 2023-11-24 00:54:23 +02:00
parent 863554fea6
commit c4e1fff1bc
2 changed files with 9 additions and 7 deletions

View File

@ -2421,11 +2421,6 @@ export function getCustomStoppingStrings(limit = undefined) {
strings = strings.map(x => substituteParams(x));
}
// Apply the limit. If limit is 0, return all strings.
if (limit > 0) {
strings = strings.slice(0, limit);
}
return strings;
} catch (error) {
// If there's an error, return an empty array
@ -2436,7 +2431,14 @@ export function getCustomStoppingStrings(limit = undefined) {
const permanent = getPermanent();
const ephemeral = EPHEMERAL_STOPPING_STRINGS;
return [...permanent, ...ephemeral];
const strings = [...permanent, ...ephemeral];
// Apply the limit. If limit is 0, return all strings.
if (limit > 0) {
return strings.slice(0, limit);
}
return strings;
}
$(document).ready(() => {

View File

@ -161,7 +161,7 @@ parser.addCommand('peek', peekCallback, [], '<span class="monospace">(message in
parser.addCommand('delswipe', deleteSwipeCallback, ['swipedel'], '<span class="monospace">(optional 1-based id)</span> deletes a swipe from the last chat message. If swipe id not provided - deletes the current swipe.', true, true);
parser.addCommand('echo', echoCallback, [], '<span class="monospace">(text)</span> echoes the text to toast message. Useful for pipes debugging.', true, true);
parser.addCommand('gen', generateCallback, [], '<span class="monospace">(prompt)</span> generates text using the provided prompt and passes it to the next command through the pipe.', true, true);
parser.addCommand('genraw', generateRawCallback, [], '<span class="monospace">(prompt)</span> generates text using the provided prompt and passes it to the next command through the pipe. Does not include chat history or character card. Use instruct=off to skip instruct formatting, e.g. <tt>/genraw instruct=off Why is the sky blue?</tt>. Use stop=... with a JSON-serializer array to add one-time custom stop strings, e.g. <tt>/genraw stop=["\\n"] Say hi</tt>', true, true);
parser.addCommand('genraw', generateRawCallback, [], '<span class="monospace">(prompt)</span> generates text using the provided prompt and passes it to the next command through the pipe. Does not include chat history or character card. Use instruct=off to skip instruct formatting, e.g. <tt>/genraw instruct=off Why is the sky blue?</tt>. Use stop=... with a JSON-serialized array to add one-time custom stop strings, e.g. <tt>/genraw stop=["\\n"] Say hi</tt>', true, true);
parser.addCommand('addswipe', addSwipeCallback, ['swipeadd'], '<span class="monospace">(text)</span> adds a swipe to the last chat message.', true, true);
parser.addCommand('abort', abortCallback, [], ' aborts the slash command batch execution', true, true);
registerVariableCommands();