',
+ ),
+ ],
+ unnamedArgumentList: [
+ new SlashCommandArgument(
+ 'new char name', [ARGUMENT_TYPE.STRING], true,
+ ),
+ ],
+ helpString: 'Renames the current character.',
+ }));
+ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
+ name: 'sysgen',
+ callback: generateSystemMessage,
+ unnamedArgumentList: [
+ new SlashCommandArgument(
+ 'prompt', [ARGUMENT_TYPE.STRING], true,
+ ),
+ ],
+ helpString: 'Generates a system message using a specified prompt.',
+ }));
+ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
+ name: 'ask',
+ callback: askCharacter,
+ namedArgumentList: [
+ SlashCommandNamedArgument.fromProps({
+ name: 'name',
+ description: 'character name',
+ typeList: [ARGUMENT_TYPE.STRING],
+ isRequired: true,
+ enumProvider: commonEnumProviders.characters('character'),
+ }),
+ ],
+ unnamedArgumentList: [
+ new SlashCommandArgument(
+ 'prompt', [ARGUMENT_TYPE.STRING], true, false,
+ ),
+ ],
+ helpString: 'Asks a specified character card a prompt. Character name must be provided in a named argument.',
+ }));
+ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
+ name: 'delname',
+ callback: deleteMessagesByNameCallback,
+ namedArgumentList: [],
+ unnamedArgumentList: [
+ SlashCommandArgument.fromProps({
+ description: 'name',
+ typeList: [ARGUMENT_TYPE.STRING],
+ isRequired: true,
+ enumProvider: commonEnumProviders.characters('character'),
+ }),
+ ],
+ aliases: ['cancel'],
+ helpString: `
Deletes all messages attributed to a specified name.
@@ -444,41 +444,41 @@ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
`,
-}));
-SlashCommandParser.addCommandObject(SlashCommand.fromProps({
- name: 'send',
- callback: sendUserMessageCallback,
- namedArgumentList: [
- new SlashCommandNamedArgument(
- 'compact',
- 'whether to use a compact layout',
- [ARGUMENT_TYPE.BOOLEAN],
- false,
- false,
- 'false',
- ),
- SlashCommandNamedArgument.fromProps({
- name: 'at',
- description: 'position to insert the message',
- typeList: [ARGUMENT_TYPE.NUMBER],
- enumProvider: commonEnumProviders.messages({ allowIdAfter: true }),
- }),
- SlashCommandNamedArgument.fromProps({
- name: 'name',
- description: 'display name',
- typeList: [ARGUMENT_TYPE.STRING],
- defaultValue: '{{user}}',
- enumProvider: commonEnumProviders.characters('character'),
- }),
- ],
- unnamedArgumentList: [
- new SlashCommandArgument(
- 'text',
- [ARGUMENT_TYPE.STRING],
- true,
- ),
- ],
- helpString: `
+ }));
+ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
+ name: 'send',
+ callback: sendUserMessageCallback,
+ namedArgumentList: [
+ new SlashCommandNamedArgument(
+ 'compact',
+ 'whether to use a compact layout',
+ [ARGUMENT_TYPE.BOOLEAN],
+ false,
+ false,
+ 'false',
+ ),
+ SlashCommandNamedArgument.fromProps({
+ name: 'at',
+ description: 'position to insert the message (index-based, corresponding to message id). If not set, the message will be inserted at the end of the chat.\nNegative values are accepted and will work similarly to how \'depth\' usually works. For example, -1 will insert the message right before the last message in chat.',
+ typeList: [ARGUMENT_TYPE.NUMBER],
+ enumProvider: commonEnumProviders.messages({ allowIdAfter: true }),
+ }),
+ SlashCommandNamedArgument.fromProps({
+ name: 'name',
+ description: 'display name',
+ typeList: [ARGUMENT_TYPE.STRING],
+ defaultValue: '{{user}}',
+ enumProvider: commonEnumProviders.characters('character'),
+ }),
+ ],
+ unnamedArgumentList: [
+ new SlashCommandArgument(
+ 'text',
+ [ARGUMENT_TYPE.STRING],
+ true,
+ ),
+ ],
+ helpString: `
Adds a user message to the chat log without triggering a generation.
@@ -500,29 +500,29 @@ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
`,
-}));
-SlashCommandParser.addCommandObject(SlashCommand.fromProps({
- name: 'trigger',
- callback: triggerGenerationCallback,
- namedArgumentList: [
- new SlashCommandNamedArgument(
- 'await',
- 'Whether to await for the triggered generation before continuing',
- [ARGUMENT_TYPE.BOOLEAN],
- false,
- false,
- 'false',
- ),
- ],
- unnamedArgumentList: [
- SlashCommandArgument.fromProps({
- description: 'group member index (starts with 0) or name',
- typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.STRING],
- isRequired: false,
- enumProvider: commonEnumProviders.groupMembers(),
- }),
- ],
- helpString: `
+ }));
+ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
+ name: 'trigger',
+ callback: triggerGenerationCallback,
+ namedArgumentList: [
+ new SlashCommandNamedArgument(
+ 'await',
+ 'Whether to await for the triggered generation before continuing',
+ [ARGUMENT_TYPE.BOOLEAN],
+ false,
+ false,
+ 'false',
+ ),
+ ],
+ unnamedArgumentList: [
+ SlashCommandArgument.fromProps({
+ description: 'group member index (starts with 0) or name',
+ typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.STRING],
+ isRequired: false,
+ enumProvider: commonEnumProviders.groupMembers(),
+ }),
+ ],
+ helpString: `
Triggers a message generation. If in group, can trigger a message for the specified group member index or name.
@@ -530,74 +530,74 @@ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
If await=true named argument is passed, the command will await for the triggered generation before continuing.
`,
-}));
-SlashCommandParser.addCommandObject(SlashCommand.fromProps({
- name: 'hide',
- callback: hideMessageCallback,
- unnamedArgumentList: [
- SlashCommandArgument.fromProps({
- description: 'message index (starts with 0) or range',
- typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.RANGE],
- isRequired: true,
- enumProvider: commonEnumProviders.messages(),
- }),
- ],
- helpString: 'Hides a chat message from the prompt.',
-}));
-SlashCommandParser.addCommandObject(SlashCommand.fromProps({
- name: 'unhide',
- callback: unhideMessageCallback,
- unnamedArgumentList: [
- SlashCommandArgument.fromProps({
- description: 'message index (starts with 0) or range',
- typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.RANGE],
- isRequired: true,
- enumProvider: commonEnumProviders.messages(),
- }),
- ],
- helpString: 'Unhides a message from the prompt.',
-}));
-SlashCommandParser.addCommandObject(SlashCommand.fromProps({
- name: 'member-disable',
- callback: disableGroupMemberCallback,
- aliases: ['disable', 'disablemember', 'memberdisable'],
- unnamedArgumentList: [
- SlashCommandArgument.fromProps({
- description: 'member index (starts with 0) or name',
- typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.STRING],
- isRequired: true,
- enumProvider: commonEnumProviders.groupMembers(),
- }),
- ],
- helpString: 'Disables a group member from being drafted for replies.',
-}));
-SlashCommandParser.addCommandObject(SlashCommand.fromProps({
- name: 'member-enable',
- aliases: ['enable', 'enablemember', 'memberenable'],
- callback: enableGroupMemberCallback,
- unnamedArgumentList: [
- SlashCommandArgument.fromProps({
- description: 'member index (starts with 0) or name',
- typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.STRING],
- isRequired: true,
- enumProvider: commonEnumProviders.groupMembers(),
- }),
- ],
- helpString: 'Enables a group member to be drafted for replies.',
-}));
-SlashCommandParser.addCommandObject(SlashCommand.fromProps({
- name: 'member-add',
- callback: addGroupMemberCallback,
- aliases: ['addmember', 'memberadd'],
- unnamedArgumentList: [
- SlashCommandArgument.fromProps({
- description: 'character name',
- typeList: [ARGUMENT_TYPE.STRING],
- isRequired: true,
- enumProvider: () => selected_group ? commonEnumProviders.characters('character')() : [],
- }),
- ],
- helpString: `
+ }));
+ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
+ name: 'hide',
+ callback: hideMessageCallback,
+ unnamedArgumentList: [
+ SlashCommandArgument.fromProps({
+ description: 'message index (starts with 0) or range',
+ typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.RANGE],
+ isRequired: true,
+ enumProvider: commonEnumProviders.messages(),
+ }),
+ ],
+ helpString: 'Hides a chat message from the prompt.',
+ }));
+ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
+ name: 'unhide',
+ callback: unhideMessageCallback,
+ unnamedArgumentList: [
+ SlashCommandArgument.fromProps({
+ description: 'message index (starts with 0) or range',
+ typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.RANGE],
+ isRequired: true,
+ enumProvider: commonEnumProviders.messages(),
+ }),
+ ],
+ helpString: 'Unhides a message from the prompt.',
+ }));
+ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
+ name: 'member-disable',
+ callback: disableGroupMemberCallback,
+ aliases: ['disable', 'disablemember', 'memberdisable'],
+ unnamedArgumentList: [
+ SlashCommandArgument.fromProps({
+ description: 'member index (starts with 0) or name',
+ typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.STRING],
+ isRequired: true,
+ enumProvider: commonEnumProviders.groupMembers(),
+ }),
+ ],
+ helpString: 'Disables a group member from being drafted for replies.',
+ }));
+ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
+ name: 'member-enable',
+ aliases: ['enable', 'enablemember', 'memberenable'],
+ callback: enableGroupMemberCallback,
+ unnamedArgumentList: [
+ SlashCommandArgument.fromProps({
+ description: 'member index (starts with 0) or name',
+ typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.STRING],
+ isRequired: true,
+ enumProvider: commonEnumProviders.groupMembers(),
+ }),
+ ],
+ helpString: 'Enables a group member to be drafted for replies.',
+ }));
+ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
+ name: 'member-add',
+ callback: addGroupMemberCallback,
+ aliases: ['addmember', 'memberadd'],
+ unnamedArgumentList: [
+ SlashCommandArgument.fromProps({
+ description: 'character name',
+ typeList: [ARGUMENT_TYPE.STRING],
+ isRequired: true,
+ enumProvider: () => selected_group ? commonEnumProviders.characters('character')() : [],
+ }),
+ ],
+ helpString: `
Adds a new group member to the group chat.
@@ -610,20 +610,20 @@ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
`,
-}));
-SlashCommandParser.addCommandObject(SlashCommand.fromProps({
- name: 'member-remove',
- callback: removeGroupMemberCallback,
- aliases: ['removemember', 'memberremove'],
- unnamedArgumentList: [
- SlashCommandArgument.fromProps({
- description: 'member index (starts with 0) or name',
- typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.STRING],
- isRequired: true,
- enumProvider: commonEnumProviders.groupMembers(),
- }),
- ],
- helpString: `
+ }));
+ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
+ name: 'member-remove',
+ callback: removeGroupMemberCallback,
+ aliases: ['removemember', 'memberremove'],
+ unnamedArgumentList: [
+ SlashCommandArgument.fromProps({
+ description: 'member index (starts with 0) or name',
+ typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.STRING],
+ isRequired: true,
+ enumProvider: commonEnumProviders.groupMembers(),
+ }),
+ ],
+ helpString: `
Removes a group member from the group chat.
@@ -637,47 +637,47 @@ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
`,
-}));
-SlashCommandParser.addCommandObject(SlashCommand.fromProps({
- name: 'member-up',
- callback: moveGroupMemberUpCallback,
- aliases: ['upmember', 'memberup'],
- unnamedArgumentList: [
- SlashCommandArgument.fromProps({
- description: 'member index (starts with 0) or name',
- typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.STRING],
- isRequired: true,
- enumProvider: commonEnumProviders.groupMembers(),
- }),
- ],
- helpString: 'Moves a group member up in the group chat list.',
-}));
-SlashCommandParser.addCommandObject(SlashCommand.fromProps({
- name: 'member-down',
- callback: moveGroupMemberDownCallback,
- aliases: ['downmember', 'memberdown'],
- unnamedArgumentList: [
- SlashCommandArgument.fromProps({
- description: 'member index (starts with 0) or name',
- typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.STRING],
- isRequired: true,
- enumProvider: commonEnumProviders.groupMembers(),
- }),
- ],
- helpString: 'Moves a group member down in the group chat list.',
-}));
-SlashCommandParser.addCommandObject(SlashCommand.fromProps({
- name: 'peek',
- callback: peekCallback,
- unnamedArgumentList: [
- SlashCommandArgument.fromProps({
- description: 'member index (starts with 0) or name',
- typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.STRING],
- isRequired: true,
- enumProvider: commonEnumProviders.groupMembers(),
- }),
- ],
- helpString: `
+ }));
+ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
+ name: 'member-up',
+ callback: moveGroupMemberUpCallback,
+ aliases: ['upmember', 'memberup'],
+ unnamedArgumentList: [
+ SlashCommandArgument.fromProps({
+ description: 'member index (starts with 0) or name',
+ typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.STRING],
+ isRequired: true,
+ enumProvider: commonEnumProviders.groupMembers(),
+ }),
+ ],
+ helpString: 'Moves a group member up in the group chat list.',
+ }));
+ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
+ name: 'member-down',
+ callback: moveGroupMemberDownCallback,
+ aliases: ['downmember', 'memberdown'],
+ unnamedArgumentList: [
+ SlashCommandArgument.fromProps({
+ description: 'member index (starts with 0) or name',
+ typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.STRING],
+ isRequired: true,
+ enumProvider: commonEnumProviders.groupMembers(),
+ }),
+ ],
+ helpString: 'Moves a group member down in the group chat list.',
+ }));
+ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
+ name: 'peek',
+ callback: peekCallback,
+ unnamedArgumentList: [
+ SlashCommandArgument.fromProps({
+ description: 'member index (starts with 0) or name',
+ typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.STRING],
+ isRequired: true,
+ enumProvider: commonEnumProviders.groupMembers(),
+ }),
+ ],
+ helpString: `
Shows a group member character card without switching chats.
@@ -691,22 +691,22 @@ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
`,
-}));
-SlashCommandParser.addCommandObject(SlashCommand.fromProps({
- name: 'delswipe',
- callback: deleteSwipeCallback,
- aliases: ['swipedel'],
- unnamedArgumentList: [
- SlashCommandArgument.fromProps({
- description: '1-based swipe id',
- typeList: [ARGUMENT_TYPE.NUMBER],
- isRequired: true,
- enumProvider: () => Array.isArray(chat[chat.length - 1]?.swipes) ?
- chat[chat.length - 1].swipes.map((/** @type {string} */ swipe, /** @type {number} */ i) => new SlashCommandEnumValue(String(i + 1), swipe, enumTypes.enum, enumIcons.message))
- : [],
- }),
- ],
- helpString: `
+ }));
+ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
+ name: 'delswipe',
+ callback: deleteSwipeCallback,
+ aliases: ['swipedel'],
+ unnamedArgumentList: [
+ SlashCommandArgument.fromProps({
+ description: '1-based swipe id',
+ typeList: [ARGUMENT_TYPE.NUMBER],
+ isRequired: true,
+ enumProvider: () => Array.isArray(chat[chat.length - 1]?.swipes) ?
+ chat[chat.length - 1].swipes.map((/** @type {string} */ swipe, /** @type {number} */ i) => new SlashCommandEnumValue(String(i + 1), swipe, enumTypes.enum, enumIcons.message))
+ : [],
+ }),
+ ],
+ helpString: `
Deletes a swipe from the last chat message. If swipe id is not provided, it deletes the current swipe.
@@ -724,34 +724,60 @@ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
`,
-}));
-SlashCommandParser.addCommandObject(SlashCommand.fromProps({
- name: 'echo',
- callback: echoCallback,
- returns: 'the text',
- namedArgumentList: [
- new SlashCommandNamedArgument(
- 'title', 'title of the toast message', [ARGUMENT_TYPE.STRING], false,
- ),
- SlashCommandNamedArgument.fromProps({
- name: 'severity',
- description: 'severity level of the toast message',
- typeList: [ARGUMENT_TYPE.STRING],
- defaultValue: 'info',
- enumProvider: () => [
- new SlashCommandEnumValue('info', 'info', enumTypes.macro, 'ℹ️'),
- new SlashCommandEnumValue('warning', 'warning', enumTypes.enum, '⚠️'),
- new SlashCommandEnumValue('error', 'error', enumTypes.enum, '❗'),
- new SlashCommandEnumValue('success', 'success', enumTypes.enum, '✅'),
- ],
- }),
- ],
- unnamedArgumentList: [
- new SlashCommandArgument(
- 'text', [ARGUMENT_TYPE.STRING], true,
- ),
- ],
- helpString: `
+ }));
+ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
+ name: 'echo',
+ callback: echoCallback,
+ returns: 'the text',
+ namedArgumentList: [
+ new SlashCommandNamedArgument(
+ 'title', 'title of the toast message', [ARGUMENT_TYPE.STRING], false,
+ ),
+ SlashCommandNamedArgument.fromProps({
+ name: 'severity',
+ description: 'severity level of the toast message',
+ typeList: [ARGUMENT_TYPE.STRING],
+ defaultValue: 'info',
+ enumProvider: () => [
+ new SlashCommandEnumValue('info', 'info', enumTypes.macro, 'ℹ️'),
+ new SlashCommandEnumValue('warning', 'warning', enumTypes.enum, '⚠️'),
+ new SlashCommandEnumValue('error', 'error', enumTypes.enum, '❗'),
+ new SlashCommandEnumValue('success', 'success', enumTypes.enum, '✅'),
+ ],
+ }),
+ SlashCommandNamedArgument.fromProps({
+ name: 'timeout',
+ description: 'time in milliseconds to display the toast message. Set this and \'extendedTimeout\' to 0 to show indefinitely until dismissed.',
+ typeList: [ARGUMENT_TYPE.NUMBER],
+ defaultValue: `${toastr.options.timeOut}`,
+ }),
+ SlashCommandNamedArgument.fromProps({
+ name: 'extendedTimeout',
+ description: 'time in milliseconds to display the toast message. Set this and \'timeout\' to 0 to show indefinitely until dismissed.',
+ typeList: [ARGUMENT_TYPE.NUMBER],
+ defaultValue: `${toastr.options.extendedTimeOut}`,
+ }),
+ SlashCommandNamedArgument.fromProps({
+ name: 'preventDuplicates',
+ description: 'prevent duplicate toasts with the same message from being displayed.',
+ typeList: [ARGUMENT_TYPE.BOOLEAN],
+ defaultValue: 'false',
+ enumList: commonEnumProviders.boolean('trueFalse')(),
+ }),
+ SlashCommandNamedArgument.fromProps({
+ name: 'awaitDismissal',
+ description: 'wait for the toast to be dismissed before continuing.',
+ typeList: [ARGUMENT_TYPE.BOOLEAN],
+ defaultValue: 'false',
+ enumList: commonEnumProviders.boolean('trueFalse')(),
+ }),
+ ],
+ unnamedArgumentList: [
+ new SlashCommandArgument(
+ 'text', [ARGUMENT_TYPE.STRING], true,
+ ),
+ ],
+ helpString: `
Echoes the provided text to a toast message. Useful for pipes debugging.
@@ -764,42 +790,42 @@ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
`,
-}));
-SlashCommandParser.addCommandObject(SlashCommand.fromProps({
- name: 'gen',
- callback: generateCallback,
- returns: 'generated text',
- namedArgumentList: [
- new SlashCommandNamedArgument(
- 'lock', 'lock user input during generation', [ARGUMENT_TYPE.BOOLEAN], false, false, null, commonEnumProviders.boolean('onOff')(),
- ),
- SlashCommandNamedArgument.fromProps({
- name: 'name',
- description: 'in-prompt name for instruct mode',
- typeList: [ARGUMENT_TYPE.STRING],
- defaultValue: 'System',
- enumProvider: () => [...commonEnumProviders.characters('character')(), new SlashCommandEnumValue('System', null, enumTypes.enum, enumIcons.assistant)],
- forceEnum: false,
- }),
- new SlashCommandNamedArgument(
- 'length', 'API response length in tokens', [ARGUMENT_TYPE.NUMBER], false,
- ),
- SlashCommandNamedArgument.fromProps({
- name: 'as',
- description: 'role of the output prompt',
- typeList: [ARGUMENT_TYPE.STRING],
- enumList: [
- new SlashCommandEnumValue('system', null, enumTypes.enum, enumIcons.assistant),
- new SlashCommandEnumValue('char', null, enumTypes.enum, enumIcons.character),
- ],
- }),
- ],
- unnamedArgumentList: [
- new SlashCommandArgument(
- 'prompt', [ARGUMENT_TYPE.STRING], true,
- ),
- ],
- helpString: `
+ }));
+ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
+ name: 'gen',
+ callback: generateCallback,
+ returns: 'generated text',
+ namedArgumentList: [
+ new SlashCommandNamedArgument(
+ 'lock', 'lock user input during generation', [ARGUMENT_TYPE.BOOLEAN], false, false, null, commonEnumProviders.boolean('onOff')(),
+ ),
+ SlashCommandNamedArgument.fromProps({
+ name: 'name',
+ description: 'in-prompt name for instruct mode',
+ typeList: [ARGUMENT_TYPE.STRING],
+ defaultValue: 'System',
+ enumProvider: () => [...commonEnumProviders.characters('character')(), new SlashCommandEnumValue('System', null, enumTypes.enum, enumIcons.assistant)],
+ forceEnum: false,
+ }),
+ new SlashCommandNamedArgument(
+ 'length', 'API response length in tokens', [ARGUMENT_TYPE.NUMBER], false,
+ ),
+ SlashCommandNamedArgument.fromProps({
+ name: 'as',
+ description: 'role of the output prompt',
+ typeList: [ARGUMENT_TYPE.STRING],
+ enumList: [
+ new SlashCommandEnumValue('system', null, enumTypes.enum, enumIcons.assistant),
+ new SlashCommandEnumValue('char', null, enumTypes.enum, enumIcons.character),
+ ],
+ }),
+ ],
+ unnamedArgumentList: [
+ new SlashCommandArgument(
+ 'prompt', [ARGUMENT_TYPE.STRING], true,
+ ),
+ ],
+ helpString: `
Generates text using the provided prompt and passes it to the next command through the pipe, optionally locking user input while generating and allowing to configure the in-prompt name for instruct mode (default = "System").
@@ -807,43 +833,43 @@ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
"as" argument controls the role of the output prompt: system (default) or char. If "length" argument is provided as a number in tokens, allows to temporarily override an API response length.
`,
-}));
-SlashCommandParser.addCommandObject(SlashCommand.fromProps({
- name: 'genraw',
- callback: generateRawCallback,
- returns: 'generated text',
- namedArgumentList: [
- new SlashCommandNamedArgument(
- 'lock', 'lock user input during generation', [ARGUMENT_TYPE.BOOLEAN], false, false, null, commonEnumProviders.boolean('onOff')(),
- ),
- new SlashCommandNamedArgument(
- 'instruct', 'use instruct mode', [ARGUMENT_TYPE.BOOLEAN], false, false, 'on', commonEnumProviders.boolean('onOff')(),
- ),
- new SlashCommandNamedArgument(
- 'stop', 'one-time custom stop strings', [ARGUMENT_TYPE.LIST], false,
- ),
- SlashCommandNamedArgument.fromProps({
- name: 'as',
- description: 'role of the output prompt',
- typeList: [ARGUMENT_TYPE.STRING],
- enumList: [
- new SlashCommandEnumValue('system', null, enumTypes.enum, enumIcons.assistant),
- new SlashCommandEnumValue('char', null, enumTypes.enum, enumIcons.character),
- ],
- }),
- new SlashCommandNamedArgument(
- 'system', 'system prompt at the start', [ARGUMENT_TYPE.STRING], false,
- ),
- new SlashCommandNamedArgument(
- 'length', 'API response length in tokens', [ARGUMENT_TYPE.NUMBER], false,
- ),
- ],
- unnamedArgumentList: [
- new SlashCommandArgument(
- 'prompt', [ARGUMENT_TYPE.STRING], true,
- ),
- ],
- helpString: `
+ }));
+ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
+ name: 'genraw',
+ callback: generateRawCallback,
+ returns: 'generated text',
+ namedArgumentList: [
+ new SlashCommandNamedArgument(
+ 'lock', 'lock user input during generation', [ARGUMENT_TYPE.BOOLEAN], false, false, null, commonEnumProviders.boolean('onOff')(),
+ ),
+ new SlashCommandNamedArgument(
+ 'instruct', 'use instruct mode', [ARGUMENT_TYPE.BOOLEAN], false, false, 'on', commonEnumProviders.boolean('onOff')(),
+ ),
+ new SlashCommandNamedArgument(
+ 'stop', 'one-time custom stop strings', [ARGUMENT_TYPE.LIST], false,
+ ),
+ SlashCommandNamedArgument.fromProps({
+ name: 'as',
+ description: 'role of the output prompt',
+ typeList: [ARGUMENT_TYPE.STRING],
+ enumList: [
+ new SlashCommandEnumValue('system', null, enumTypes.enum, enumIcons.assistant),
+ new SlashCommandEnumValue('char', null, enumTypes.enum, enumIcons.character),
+ ],
+ }),
+ new SlashCommandNamedArgument(
+ 'system', 'system prompt at the start', [ARGUMENT_TYPE.STRING], false,
+ ),
+ new SlashCommandNamedArgument(
+ 'length', 'API response length in tokens', [ARGUMENT_TYPE.NUMBER], false,
+ ),
+ ],
+ unnamedArgumentList: [
+ new SlashCommandArgument(
+ 'prompt', [ARGUMENT_TYPE.STRING], true,
+ ),
+ ],
+ helpString: `
Generates text using the provided prompt and passes it to the next command through the pipe, optionally locking user input while generating. Does not include chat history or character card.
@@ -860,55 +886,55 @@ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
If "length" argument is provided as a number in tokens, allows to temporarily override an API response length.
`,
-}));
-SlashCommandParser.addCommandObject(SlashCommand.fromProps({
- name: 'addswipe',
- callback: addSwipeCallback,
- aliases: ['swipeadd'],
- unnamedArgumentList: [
- new SlashCommandArgument(
- 'text', [ARGUMENT_TYPE.STRING], true,
- ),
- ],
- helpString: 'Adds a swipe to the last chat message.',
-}));
-SlashCommandParser.addCommandObject(SlashCommand.fromProps({
- name: 'abort',
- callback: abortCallback,
- namedArgumentList: [
- SlashCommandNamedArgument.fromProps({
- name: 'quiet',
- description: 'Whether to suppress the toast message notifying about the /abort call.',
- typeList: [ARGUMENT_TYPE.BOOLEAN],
- defaultValue: 'true',
- }),
- ],
- unnamedArgumentList: [
- SlashCommandArgument.fromProps({
- description: 'The reason for aborting command execution. Shown when quiet=false',
- typeList: [ARGUMENT_TYPE.STRING],
- }),
- ],
- helpString: 'Aborts the slash command batch execution.',
-}));
-SlashCommandParser.addCommandObject(SlashCommand.fromProps({
- name: 'fuzzy',
- callback: fuzzyCallback,
- returns: 'first matching item',
- namedArgumentList: [
- new SlashCommandNamedArgument(
- 'list', 'list of items to match against', [ARGUMENT_TYPE.LIST], true,
- ),
- new SlashCommandNamedArgument(
- 'threshold', 'fuzzy match threshold (0.0 to 1.0)', [ARGUMENT_TYPE.NUMBER], false, false, '0.4',
- ),
- ],
- unnamedArgumentList: [
- new SlashCommandArgument(
- 'text to search', [ARGUMENT_TYPE.STRING], true,
- ),
- ],
- helpString: `
+ }));
+ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
+ name: 'addswipe',
+ callback: addSwipeCallback,
+ aliases: ['swipeadd'],
+ unnamedArgumentList: [
+ new SlashCommandArgument(
+ 'text', [ARGUMENT_TYPE.STRING], true,
+ ),
+ ],
+ helpString: 'Adds a swipe to the last chat message.',
+ }));
+ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
+ name: 'abort',
+ callback: abortCallback,
+ namedArgumentList: [
+ SlashCommandNamedArgument.fromProps({
+ name: 'quiet',
+ description: 'Whether to suppress the toast message notifying about the /abort call.',
+ typeList: [ARGUMENT_TYPE.BOOLEAN],
+ defaultValue: 'true',
+ }),
+ ],
+ unnamedArgumentList: [
+ SlashCommandArgument.fromProps({
+ description: 'The reason for aborting command execution. Shown when quiet=false',
+ typeList: [ARGUMENT_TYPE.STRING],
+ }),
+ ],
+ helpString: 'Aborts the slash command batch execution.',
+ }));
+ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
+ name: 'fuzzy',
+ callback: fuzzyCallback,
+ returns: 'first matching item',
+ namedArgumentList: [
+ new SlashCommandNamedArgument(
+ 'list', 'list of items to match against', [ARGUMENT_TYPE.LIST], true,
+ ),
+ new SlashCommandNamedArgument(
+ 'threshold', 'fuzzy match threshold (0.0 to 1.0)', [ARGUMENT_TYPE.NUMBER], false, false, '0.4',
+ ),
+ ],
+ unnamedArgumentList: [
+ new SlashCommandArgument(
+ 'text to search', [ARGUMENT_TYPE.STRING], true,
+ ),
+ ],
+ helpString: `
Performs a fuzzy match of each item in the list against the text to search.
If any item matches, then its name is returned. If no item matches the text, no value is returned.
@@ -930,23 +956,23 @@ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
`,
-}));
-SlashCommandParser.addCommandObject(SlashCommand.fromProps({
- name: 'pass',
- callback: (_, arg) => {
- // We do not support arrays of closures. Arrays of strings will be send as JSON
- if (Array.isArray(arg) && arg.some(x => x instanceof SlashCommandClosure)) throw new Error('Command /pass does not support multiple closures');
- if (Array.isArray(arg)) return JSON.stringify(arg);
- return arg;
- },
- returns: 'the provided value',
- unnamedArgumentList: [
- new SlashCommandArgument(
- 'text', [ARGUMENT_TYPE.STRING, ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.BOOLEAN, ARGUMENT_TYPE.LIST, ARGUMENT_TYPE.DICTIONARY, ARGUMENT_TYPE.CLOSURE], true,
- ),
- ],
- aliases: ['return'],
- helpString: `
+ }));
+ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
+ name: 'pass',
+ callback: (_, arg) => {
+ // We do not support arrays of closures. Arrays of strings will be send as JSON
+ if (Array.isArray(arg) && arg.some(x => x instanceof SlashCommandClosure)) throw new Error('Command /pass does not support multiple closures');
+ if (Array.isArray(arg)) return JSON.stringify(arg);
+ return arg;
+ },
+ returns: 'the provided value',
+ unnamedArgumentList: [
+ new SlashCommandArgument(
+ 'text', [ARGUMENT_TYPE.STRING, ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.BOOLEAN, ARGUMENT_TYPE.LIST, ARGUMENT_TYPE.DICTIONARY, ARGUMENT_TYPE.CLOSURE], true,
+ ),
+ ],
+ aliases: ['return'],
+ helpString: `
/pass (text) – passes the text to the next command through the pipe.
@@ -957,17 +983,17 @@ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
`,
-}));
-SlashCommandParser.addCommandObject(SlashCommand.fromProps({
- name: 'delay',
- callback: delayCallback,
- aliases: ['wait', 'sleep'],
- unnamedArgumentList: [
- new SlashCommandArgument(
- 'milliseconds', [ARGUMENT_TYPE.NUMBER], true,
- ),
- ],
- helpString: `
+ }));
+ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
+ name: 'delay',
+ callback: delayCallback,
+ aliases: ['wait', 'sleep'],
+ unnamedArgumentList: [
+ new SlashCommandArgument(
+ 'milliseconds', [ARGUMENT_TYPE.NUMBER], true,
+ ),
+ ],
+ helpString: `
Delays the next command in the pipe by the specified number of milliseconds.
@@ -980,101 +1006,101 @@ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
`,
-}));
-SlashCommandParser.addCommandObject(SlashCommand.fromProps({
- name: 'input',
- aliases: ['prompt'],
- callback: inputCallback,
- returns: 'user input',
- namedArgumentList: [
- new SlashCommandNamedArgument(
- 'default', 'default value of the input field', [ARGUMENT_TYPE.STRING], false, false, '"string"',
- ),
- new SlashCommandNamedArgument(
- 'large', 'show large input field', [ARGUMENT_TYPE.BOOLEAN], false, false, 'off', commonEnumProviders.boolean('onOff')(),
- ),
- new SlashCommandNamedArgument(
- 'wide', 'show wide input field', [ARGUMENT_TYPE.BOOLEAN], false, false, 'off', commonEnumProviders.boolean('onOff')(),
- ),
- new SlashCommandNamedArgument(
- 'okButton', 'text for the ok button', [ARGUMENT_TYPE.STRING], false,
- ),
- new SlashCommandNamedArgument(
- 'rows', 'number of rows for the input field', [ARGUMENT_TYPE.NUMBER], false,
- ),
- ],
- unnamedArgumentList: [
- new SlashCommandArgument(
- 'text to display', [ARGUMENT_TYPE.STRING], false,
- ),
- ],
- helpString: `
+ }));
+ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
+ name: 'input',
+ aliases: ['prompt'],
+ callback: inputCallback,
+ returns: 'user input',
+ namedArgumentList: [
+ new SlashCommandNamedArgument(
+ 'default', 'default value of the input field', [ARGUMENT_TYPE.STRING], false, false, '"string"',
+ ),
+ new SlashCommandNamedArgument(
+ 'large', 'show large input field', [ARGUMENT_TYPE.BOOLEAN], false, false, 'off', commonEnumProviders.boolean('onOff')(),
+ ),
+ new SlashCommandNamedArgument(
+ 'wide', 'show wide input field', [ARGUMENT_TYPE.BOOLEAN], false, false, 'off', commonEnumProviders.boolean('onOff')(),
+ ),
+ new SlashCommandNamedArgument(
+ 'okButton', 'text for the ok button', [ARGUMENT_TYPE.STRING], false,
+ ),
+ new SlashCommandNamedArgument(
+ 'rows', 'number of rows for the input field', [ARGUMENT_TYPE.NUMBER], false,
+ ),
+ ],
+ unnamedArgumentList: [
+ new SlashCommandArgument(
+ 'text to display', [ARGUMENT_TYPE.STRING], false,
+ ),
+ ],
+ helpString: `
Shows a popup with the provided text and an input field.
The default argument is the default value of the input field, and the text argument is the text to display.
`,
-}));
-SlashCommandParser.addCommandObject(SlashCommand.fromProps({
- name: 'run',
- aliases: ['call', 'exec'],
- callback: runCallback,
- returns: 'result of the executed closure of QR',
- namedArgumentList: [
- new SlashCommandNamedArgument(
- 'args', 'named arguments', [ARGUMENT_TYPE.STRING, ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.BOOLEAN, ARGUMENT_TYPE.LIST, ARGUMENT_TYPE.DICTIONARY], false, true,
- ),
- ],
- unnamedArgumentList: [
- SlashCommandArgument.fromProps({
- description: 'scoped variable or qr label',
- typeList: [ARGUMENT_TYPE.VARIABLE_NAME, ARGUMENT_TYPE.STRING],
- isRequired: true,
- enumProvider: () => [
- ...commonEnumProviders.variables('scope')(),
- ...(typeof window['qrEnumProviderExecutables'] === 'function') ? window['qrEnumProviderExecutables']() : [],
- ],
- }),
- ],
- helpString: `
+ }));
+ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
+ name: 'run',
+ aliases: ['call', 'exec'],
+ callback: runCallback,
+ returns: 'result of the executed closure of QR',
+ namedArgumentList: [
+ new SlashCommandNamedArgument(
+ 'args', 'named arguments', [ARGUMENT_TYPE.STRING, ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.BOOLEAN, ARGUMENT_TYPE.LIST, ARGUMENT_TYPE.DICTIONARY], false, true,
+ ),
+ ],
+ unnamedArgumentList: [
+ SlashCommandArgument.fromProps({
+ description: 'scoped variable or qr label',
+ typeList: [ARGUMENT_TYPE.VARIABLE_NAME, ARGUMENT_TYPE.STRING],
+ isRequired: true,
+ enumProvider: () => [
+ ...commonEnumProviders.variables('scope')(),
+ ...(typeof window['qrEnumProviderExecutables'] === 'function') ? window['qrEnumProviderExecutables']() : [],
+ ],
+ }),
+ ],
+ helpString: `
Runs a closure from a scoped variable, or a Quick Reply with the specified name from a currently active preset or from another preset.
Named arguments can be referenced in a QR with {{arg::key}}.
`,
-}));
-SlashCommandParser.addCommandObject(SlashCommand.fromProps({
- name: 'messages',
- callback: getMessagesCallback,
- aliases: ['message'],
- namedArgumentList: [
- new SlashCommandNamedArgument(
- 'names', 'show message author names', [ARGUMENT_TYPE.BOOLEAN], false, false, 'off', commonEnumProviders.boolean('onOff')(),
- ),
- new SlashCommandNamedArgument(
- 'hidden', 'include hidden messages', [ARGUMENT_TYPE.BOOLEAN], false, false, 'on', commonEnumProviders.boolean('onOff')(),
- ),
- SlashCommandNamedArgument.fromProps({
- name: 'role',
- description: 'filter messages by role',
- typeList: [ARGUMENT_TYPE.STRING],
- enumList: [
- new SlashCommandEnumValue('system', null, enumTypes.enum, enumIcons.system),
- new SlashCommandEnumValue('assistant', null, enumTypes.enum, enumIcons.assistant),
- new SlashCommandEnumValue('user', null, enumTypes.enum, enumIcons.user),
- ],
- }),
- ],
- unnamedArgumentList: [
- SlashCommandArgument.fromProps({
- description: 'message index (starts with 0) or range',
- typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.RANGE],
- isRequired: true,
- enumProvider: commonEnumProviders.messages(),
- }),
- ],
- returns: 'the specified message or range of messages as a string',
- helpString: `
+ }));
+ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
+ name: 'messages',
+ callback: getMessagesCallback,
+ aliases: ['message'],
+ namedArgumentList: [
+ new SlashCommandNamedArgument(
+ 'names', 'show message author names', [ARGUMENT_TYPE.BOOLEAN], false, false, 'off', commonEnumProviders.boolean('onOff')(),
+ ),
+ new SlashCommandNamedArgument(
+ 'hidden', 'include hidden messages', [ARGUMENT_TYPE.BOOLEAN], false, false, 'on', commonEnumProviders.boolean('onOff')(),
+ ),
+ SlashCommandNamedArgument.fromProps({
+ name: 'role',
+ description: 'filter messages by role',
+ typeList: [ARGUMENT_TYPE.STRING],
+ enumList: [
+ new SlashCommandEnumValue('system', null, enumTypes.enum, enumIcons.system),
+ new SlashCommandEnumValue('assistant', null, enumTypes.enum, enumIcons.assistant),
+ new SlashCommandEnumValue('user', null, enumTypes.enum, enumIcons.user),
+ ],
+ }),
+ ],
+ unnamedArgumentList: [
+ SlashCommandArgument.fromProps({
+ description: 'message index (starts with 0) or range',
+ typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.RANGE],
+ isRequired: true,
+ enumProvider: commonEnumProviders.messages(),
+ }),
+ ],
+ returns: 'the specified message or range of messages as a string',
+ helpString: `
Returns the specified message or range of messages as a string.
@@ -1098,16 +1124,16 @@ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
`,
-}));
-SlashCommandParser.addCommandObject(SlashCommand.fromProps({
- name: 'setinput',
- callback: setInputCallback,
- unnamedArgumentList: [
- new SlashCommandArgument(
- 'text', [ARGUMENT_TYPE.STRING], true,
- ),
- ],
- helpString: `
+ }));
+ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
+ name: 'setinput',
+ callback: setInputCallback,
+ unnamedArgumentList: [
+ new SlashCommandArgument(
+ 'text', [ARGUMENT_TYPE.STRING], true,
+ ),
+ ],
+ helpString: `
Sets the user input to the specified text and passes it to the next command through the pipe.
@@ -1120,28 +1146,28 @@ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
`,
-}));
-SlashCommandParser.addCommandObject(SlashCommand.fromProps({
- name: 'popup',
- callback: popupCallback,
- returns: 'popup text',
- namedArgumentList: [
- new SlashCommandNamedArgument(
- 'large', 'show large popup', [ARGUMENT_TYPE.BOOLEAN], false, false, null, commonEnumProviders.boolean('onOff')(),
- ),
- new SlashCommandNamedArgument(
- 'wide', 'show wide popup', [ARGUMENT_TYPE.BOOLEAN], false, false, null, commonEnumProviders.boolean('onOff')(),
- ),
- new SlashCommandNamedArgument(
- 'okButton', 'text for the OK button', [ARGUMENT_TYPE.STRING], false,
- ),
- ],
- unnamedArgumentList: [
- new SlashCommandArgument(
- 'text', [ARGUMENT_TYPE.STRING], true,
- ),
- ],
- helpString: `
+ }));
+ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
+ name: 'popup',
+ callback: popupCallback,
+ returns: 'popup text',
+ namedArgumentList: [
+ new SlashCommandNamedArgument(
+ 'large', 'show large popup', [ARGUMENT_TYPE.BOOLEAN], false, false, null, commonEnumProviders.boolean('onOff')(),
+ ),
+ new SlashCommandNamedArgument(
+ 'wide', 'show wide popup', [ARGUMENT_TYPE.BOOLEAN], false, false, null, commonEnumProviders.boolean('onOff')(),
+ ),
+ new SlashCommandNamedArgument(
+ 'okButton', 'text for the OK button', [ARGUMENT_TYPE.STRING], false,
+ ),
+ ],
+ unnamedArgumentList: [
+ new SlashCommandArgument(
+ 'text', [ARGUMENT_TYPE.STRING], true,
+ ),
+ ],
+ helpString: `
Shows a blocking popup with the specified text and buttons.
Returns the popup text.
@@ -1155,22 +1181,22 @@ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
`,
-}));
-SlashCommandParser.addCommandObject(SlashCommand.fromProps({
- name: 'buttons',
- callback: buttonsCallback,
- returns: 'clicked button label',
- namedArgumentList: [
- new SlashCommandNamedArgument(
- 'labels', 'button labels', [ARGUMENT_TYPE.LIST], true,
- ),
- ],
- unnamedArgumentList: [
- new SlashCommandArgument(
- 'text', [ARGUMENT_TYPE.STRING], true,
- ),
- ],
- helpString: `
+ }));
+ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
+ name: 'buttons',
+ callback: buttonsCallback,
+ returns: 'clicked button label',
+ namedArgumentList: [
+ new SlashCommandNamedArgument(
+ 'labels', 'button labels', [ARGUMENT_TYPE.LIST], true,
+ ),
+ ],
+ unnamedArgumentList: [
+ new SlashCommandArgument(
+ 'text', [ARGUMENT_TYPE.STRING], true,
+ ),
+ ],
+ helpString: `
Shows a blocking popup with the specified text and buttons.
Returns the clicked button label into the pipe or empty string if canceled.
@@ -1184,32 +1210,32 @@ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
`,
-}));
-SlashCommandParser.addCommandObject(SlashCommand.fromProps({
- name: 'trimtokens',
- callback: trimTokensCallback,
- returns: 'trimmed text',
- namedArgumentList: [
- new SlashCommandNamedArgument(
- 'limit', 'number of tokens to keep', [ARGUMENT_TYPE.NUMBER], true,
- ),
- SlashCommandNamedArgument.fromProps({
- name: 'direction',
- description: 'trim direction',
- typeList: [ARGUMENT_TYPE.STRING],
- isRequired: true,
- enumList: [
- new SlashCommandEnumValue('start', null, enumTypes.enum, '⏪'),
- new SlashCommandEnumValue('end', null, enumTypes.enum, '⏩'),
- ],
- }),
- ],
- unnamedArgumentList: [
- new SlashCommandArgument(
- 'text', [ARGUMENT_TYPE.STRING], false,
- ),
- ],
- helpString: `
+ }));
+ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
+ name: 'trimtokens',
+ callback: trimTokensCallback,
+ returns: 'trimmed text',
+ namedArgumentList: [
+ new SlashCommandNamedArgument(
+ 'limit', 'number of tokens to keep', [ARGUMENT_TYPE.NUMBER], true,
+ ),
+ SlashCommandNamedArgument.fromProps({
+ name: 'direction',
+ description: 'trim direction',
+ typeList: [ARGUMENT_TYPE.STRING],
+ isRequired: true,
+ enumList: [
+ new SlashCommandEnumValue('start', null, enumTypes.enum, '⏪'),
+ new SlashCommandEnumValue('end', null, enumTypes.enum, '⏩'),
+ ],
+ }),
+ ],
+ unnamedArgumentList: [
+ new SlashCommandArgument(
+ 'text', [ARGUMENT_TYPE.STRING], false,
+ ),
+ ],
+ helpString: `
Trims the start or end of text to the specified number of tokens.
@@ -1222,17 +1248,17 @@ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
`,
-}));
-SlashCommandParser.addCommandObject(SlashCommand.fromProps({
- name: 'trimstart',
- callback: trimStartCallback,
- returns: 'trimmed text',
- unnamedArgumentList: [
- new SlashCommandArgument(
- 'text', [ARGUMENT_TYPE.STRING], true,
- ),
- ],
- helpString: `
+ }));
+ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
+ name: 'trimstart',
+ callback: trimStartCallback,
+ returns: 'trimmed text',
+ unnamedArgumentList: [
+ new SlashCommandArgument(
+ 'text', [ARGUMENT_TYPE.STRING], true,
+ ),
+ ],
+ helpString: `
Trims the text to the start of the first full sentence.
@@ -1245,148 +1271,149 @@ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
`,
-}));
-SlashCommandParser.addCommandObject(SlashCommand.fromProps({
- name: 'trimend',
- callback: trimEndCallback,
- returns: 'trimmed text',
- unnamedArgumentList: [
- new SlashCommandArgument(
- 'text', [ARGUMENT_TYPE.STRING], true,
- ),
- ],
- helpString: 'Trims the text to the end of the last full sentence.',
-}));
-SlashCommandParser.addCommandObject(SlashCommand.fromProps({
- name: 'inject',
- callback: injectCallback,
- namedArgumentList: [
- SlashCommandNamedArgument.fromProps({
- name: 'id',
- description: 'injection ID or variable name pointing to ID',
- typeList: [ARGUMENT_TYPE.STRING],
- isRequired: true,
- enumProvider: commonEnumProviders.injects,
- }),
- new SlashCommandNamedArgument(
- 'position', 'injection position', [ARGUMENT_TYPE.STRING], false, false, 'after', ['before', 'after', 'chat'],
- ),
- new SlashCommandNamedArgument(
- 'depth', 'injection depth', [ARGUMENT_TYPE.NUMBER], false, false, '4',
- ),
- new SlashCommandNamedArgument(
- 'scan', 'include injection content into World Info scans', [ARGUMENT_TYPE.BOOLEAN], false, false, 'false',
- ),
- SlashCommandNamedArgument.fromProps({
- name: 'role',
- description: 'role for in-chat injections',
- typeList: [ARGUMENT_TYPE.STRING],
- isRequired: false,
- enumList: [
- new SlashCommandEnumValue('system', null, enumTypes.enum, enumIcons.system),
- new SlashCommandEnumValue('assistant', null, enumTypes.enum, enumIcons.assistant),
- new SlashCommandEnumValue('user', null, enumTypes.enum, enumIcons.user),
- ],
- }),
- new SlashCommandNamedArgument(
- 'ephemeral', 'remove injection after generation', [ARGUMENT_TYPE.BOOLEAN], false, false, 'false',
- ),
- ],
- unnamedArgumentList: [
- new SlashCommandArgument(
- 'text', [ARGUMENT_TYPE.STRING], false,
- ),
- ],
- helpString: 'Injects a text into the LLM prompt for the current chat. Requires a unique injection ID. Positions: "before" main prompt, "after" main prompt, in-"chat" (default: after). Depth: injection depth for the prompt (default: 4). Role: role for in-chat injections (default: system). Scan: include injection content into World Info scans (default: false).',
-}));
-SlashCommandParser.addCommandObject(SlashCommand.fromProps({
- name: 'listinjects',
- callback: listInjectsCallback,
- helpString: 'Lists all script injections for the current chat.',
-}));
-SlashCommandParser.addCommandObject(SlashCommand.fromProps({
- name: 'flushinject',
- aliases: ['flushinjects'],
- unnamedArgumentList: [
- SlashCommandArgument.fromProps({
- description: 'injection ID or a variable name pointing to ID',
- typeList: [ARGUMENT_TYPE.STRING],
- defaultValue: '',
- enumProvider: commonEnumProviders.injects,
- }),
- ],
- callback: flushInjectsCallback,
- helpString: 'Removes a script injection for the current chat. If no ID is provided, removes all script injections.',
-}));
-SlashCommandParser.addCommandObject(SlashCommand.fromProps({
- name: 'tokens',
- callback: (_, text) => {
- if (text instanceof SlashCommandClosure || Array.isArray(text)) throw new Error('Unnamed argument cannot be a closure for command /tokens');
- return getTokenCountAsync(text).then(count => String(count));
- },
- returns: 'number of tokens',
- unnamedArgumentList: [
- new SlashCommandArgument(
- 'text', [ARGUMENT_TYPE.STRING], true,
- ),
- ],
- helpString: 'Counts the number of tokens in the provided text.',
-}));
-SlashCommandParser.addCommandObject(SlashCommand.fromProps({
- name: 'model',
- callback: modelCallback,
- returns: 'current model',
- unnamedArgumentList: [
- SlashCommandArgument.fromProps({
- description: 'model name',
- typeList: [ARGUMENT_TYPE.STRING],
- enumProvider: () => getModelOptions()?.options.map(option => new SlashCommandEnumValue(option.value, option.value !== option.text ? option.text : null)),
- }),
- ],
- helpString: 'Sets the model for the current API. Gets the current model name if no argument is provided.',
-}));
-SlashCommandParser.addCommandObject(SlashCommand.fromProps({
- name: 'setpromptentry',
- aliases: ['setpromptentries'],
- callback: setPromptEntryCallback,
- namedArgumentList: [
- SlashCommandNamedArgument.fromProps({
- name: 'identifier',
- description: 'Prompt entry identifier(s) to target',
- typeList: [ARGUMENT_TYPE.STRING, ARGUMENT_TYPE.LIST],
- acceptsMultiple: true,
- enumProvider: () => {
- const promptManager = setupChatCompletionPromptManager(oai_settings);
- const prompts = promptManager.serviceSettings.prompts;
- return prompts.map(prompt => new SlashCommandEnumValue(prompt.identifier, prompt.name, enumTypes.enum));
- },
- }),
- SlashCommandNamedArgument.fromProps({
- name: 'name',
- description: 'Prompt entry name(s) to target',
- typeList: [ARGUMENT_TYPE.STRING, ARGUMENT_TYPE.LIST],
- acceptsMultiple: true,
- enumProvider: () => {
- const promptManager = setupChatCompletionPromptManager(oai_settings);
- const prompts = promptManager.serviceSettings.prompts;
- return prompts.map(prompt => new SlashCommandEnumValue(prompt.name, prompt.identifier, enumTypes.enum));
- },
- }),
- ],
- unnamedArgumentList: [
- SlashCommandArgument.fromProps({
- description: 'Set entry/entries on or off',
- typeList: [ARGUMENT_TYPE.STRING],
- isRequired: true,
- acceptsMultiple: false,
- defaultValue: 'toggle', // unnamed arguments don't support default values yet
- enumList: commonEnumProviders.boolean('onOffToggle')(),
- }),
- ],
- helpString: 'Sets the specified prompt manager entry/entries on or off.',
-}));
+ }));
+ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
+ name: 'trimend',
+ callback: trimEndCallback,
+ returns: 'trimmed text',
+ unnamedArgumentList: [
+ new SlashCommandArgument(
+ 'text', [ARGUMENT_TYPE.STRING], true,
+ ),
+ ],
+ helpString: 'Trims the text to the end of the last full sentence.',
+ }));
+ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
+ name: 'inject',
+ callback: injectCallback,
+ namedArgumentList: [
+ SlashCommandNamedArgument.fromProps({
+ name: 'id',
+ description: 'injection ID or variable name pointing to ID',
+ typeList: [ARGUMENT_TYPE.STRING],
+ isRequired: true,
+ enumProvider: commonEnumProviders.injects,
+ }),
+ new SlashCommandNamedArgument(
+ 'position', 'injection position', [ARGUMENT_TYPE.STRING], false, false, 'after', ['before', 'after', 'chat'],
+ ),
+ new SlashCommandNamedArgument(
+ 'depth', 'injection depth', [ARGUMENT_TYPE.NUMBER], false, false, '4',
+ ),
+ new SlashCommandNamedArgument(
+ 'scan', 'include injection content into World Info scans', [ARGUMENT_TYPE.BOOLEAN], false, false, 'false',
+ ),
+ SlashCommandNamedArgument.fromProps({
+ name: 'role',
+ description: 'role for in-chat injections',
+ typeList: [ARGUMENT_TYPE.STRING],
+ isRequired: false,
+ enumList: [
+ new SlashCommandEnumValue('system', null, enumTypes.enum, enumIcons.system),
+ new SlashCommandEnumValue('assistant', null, enumTypes.enum, enumIcons.assistant),
+ new SlashCommandEnumValue('user', null, enumTypes.enum, enumIcons.user),
+ ],
+ }),
+ new SlashCommandNamedArgument(
+ 'ephemeral', 'remove injection after generation', [ARGUMENT_TYPE.BOOLEAN], false, false, 'false',
+ ),
+ ],
+ unnamedArgumentList: [
+ new SlashCommandArgument(
+ 'text', [ARGUMENT_TYPE.STRING], false,
+ ),
+ ],
+ helpString: 'Injects a text into the LLM prompt for the current chat. Requires a unique injection ID. Positions: "before" main prompt, "after" main prompt, in-"chat" (default: after). Depth: injection depth for the prompt (default: 4). Role: role for in-chat injections (default: system). Scan: include injection content into World Info scans (default: false).',
+ }));
+ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
+ name: 'listinjects',
+ callback: listInjectsCallback,
+ helpString: 'Lists all script injections for the current chat.',
+ }));
+ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
+ name: 'flushinject',
+ aliases: ['flushinjects'],
+ unnamedArgumentList: [
+ SlashCommandArgument.fromProps({
+ description: 'injection ID or a variable name pointing to ID',
+ typeList: [ARGUMENT_TYPE.STRING],
+ defaultValue: '',
+ enumProvider: commonEnumProviders.injects,
+ }),
+ ],
+ callback: flushInjectsCallback,
+ helpString: 'Removes a script injection for the current chat. If no ID is provided, removes all script injections.',
+ }));
+ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
+ name: 'tokens',
+ callback: (_, text) => {
+ if (text instanceof SlashCommandClosure || Array.isArray(text)) throw new Error('Unnamed argument cannot be a closure for command /tokens');
+ return getTokenCountAsync(text).then(count => String(count));
+ },
+ returns: 'number of tokens',
+ unnamedArgumentList: [
+ new SlashCommandArgument(
+ 'text', [ARGUMENT_TYPE.STRING], true,
+ ),
+ ],
+ helpString: 'Counts the number of tokens in the provided text.',
+ }));
+ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
+ name: 'model',
+ callback: modelCallback,
+ returns: 'current model',
+ unnamedArgumentList: [
+ SlashCommandArgument.fromProps({
+ description: 'model name',
+ typeList: [ARGUMENT_TYPE.STRING],
+ enumProvider: () => getModelOptions()?.options.map(option => new SlashCommandEnumValue(option.value, option.value !== option.text ? option.text : null)),
+ }),
+ ],
+ helpString: 'Sets the model for the current API. Gets the current model name if no argument is provided.',
+ }));
+ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
+ name: 'setpromptentry',
+ aliases: ['setpromptentries'],
+ callback: setPromptEntryCallback,
+ namedArgumentList: [
+ SlashCommandNamedArgument.fromProps({
+ name: 'identifier',
+ description: 'Prompt entry identifier(s) to target',
+ typeList: [ARGUMENT_TYPE.STRING, ARGUMENT_TYPE.LIST],
+ acceptsMultiple: true,
+ enumProvider: () => {
+ const promptManager = setupChatCompletionPromptManager(oai_settings);
+ const prompts = promptManager.serviceSettings.prompts;
+ return prompts.map(prompt => new SlashCommandEnumValue(prompt.identifier, prompt.name, enumTypes.enum));
+ },
+ }),
+ SlashCommandNamedArgument.fromProps({
+ name: 'name',
+ description: 'Prompt entry name(s) to target',
+ typeList: [ARGUMENT_TYPE.STRING, ARGUMENT_TYPE.LIST],
+ acceptsMultiple: true,
+ enumProvider: () => {
+ const promptManager = setupChatCompletionPromptManager(oai_settings);
+ const prompts = promptManager.serviceSettings.prompts;
+ return prompts.map(prompt => new SlashCommandEnumValue(prompt.name, prompt.identifier, enumTypes.enum));
+ },
+ }),
+ ],
+ unnamedArgumentList: [
+ SlashCommandArgument.fromProps({
+ description: 'Set entry/entries on or off',
+ typeList: [ARGUMENT_TYPE.STRING],
+ isRequired: true,
+ acceptsMultiple: false,
+ defaultValue: 'toggle', // unnamed arguments don't support default values yet
+ enumList: commonEnumProviders.boolean('onOffToggle')(),
+ }),
+ ],
+ helpString: 'Sets the specified prompt manager entry/entries on or off.',
+ }));
-registerVariableCommands();
+ registerVariableCommands();
+}
const NARRATOR_NAME_KEY = 'narrator_name';
const NARRATOR_NAME_DEFAULT = 'System';
@@ -1938,32 +1965,67 @@ async function generateCallback(args, value) {
}
}
+/**
+ *
+ * @param {{title?: string, severity?: string, timeout?: string, extendedTimeout?: string, preventDuplicates?: string, awaitDismissal?: string}} args - named arguments from the slash command
+ * @param {string} value - The string to echo (unnamed argument from the slash command)
+ * @returns {Promise} The text that was echoed
+ */
async function echoCallback(args, value) {
// Note: We don't need to sanitize input, as toastr is set up by default to escape HTML via toastr options
if (value === '') {
console.warn('WARN: No argument provided for /echo command');
- return;
+ return '';
}
- const title = args?.title !== undefined && typeof args?.title === 'string' ? args.title : undefined;
- const severity = args?.severity !== undefined && typeof args?.severity === 'string' ? args.severity : 'info';
+
+ if (args.severity && !['error', 'warning', 'success', 'info'].includes(args.severity)) {
+ toastr.warning(`Invalid severity provided for /echo command: ${args.severity}`);
+ args.severity = null;
+ }
+
+ const title = args.title ? args.title : undefined;
+ const severity = args.severity ? args.severity : 'info';
+
+ /** @type {ToastrOptions} */
+ const options = {};
+ if (args.timeout && !isNaN(parseInt(args.timeout))) options.timeOut = parseInt(args.timeout);
+ if (args.extendedTimeout && !isNaN(parseInt(args.extendedTimeout))) options.extendedTimeOut = parseInt(args.extendedTimeout);
+ if (isTrueBoolean(args.preventDuplicates)) options.preventDuplicates = true;
+
+ // Prepare possible await handling
+ let awaitDismissal = isTrueBoolean(args.awaitDismissal);
+ let resolveToastDismissal;
+
+ if (awaitDismissal) {
+ options.onHidden = () => resolveToastDismissal(value);
+ }
+
switch (severity) {
case 'error':
- toastr.error(value, title);
+ toastr.error(value, title, options);
break;
case 'warning':
- toastr.warning(value, title);
+ toastr.warning(value, title, options);
break;
case 'success':
- toastr.success(value, title);
+ toastr.success(value, title, options);
break;
case 'info':
default:
- toastr.info(value, title);
+ toastr.info(value, title, options);
break;
}
- return value;
+
+ if (awaitDismissal) {
+ return new Promise((resolve) => {
+ resolveToastDismissal = resolve;
+ });
+ } else {
+ return value;
+ }
}
+
async function addSwipeCallback(_, arg) {
const lastMessage = chat[chat.length - 1];
@@ -2428,7 +2490,14 @@ async function sendUserMessageCallback(args, text) {
text = text.trim();
const compact = isTrueBoolean(args?.compact);
const bias = extractMessageBias(text);
- const insertAt = Number(args?.at);
+
+ let insertAt = Number(args?.at);
+
+ // Convert possible depth parameter to index
+ if (!isNaN(insertAt) && (insertAt < 0 || insertAt === Number(-0))) {
+ // Negative value means going back from current chat length. (E.g.: 8 messages, Depth 1 means insert at index 7)
+ insertAt = chat.length + insertAt;
+ }
if ('name' in args) {
const name = args.name || '';
@@ -2737,7 +2806,13 @@ export async function sendMessageAs(args, text) {
},
}];
- const insertAt = Number(args.at);
+ let insertAt = Number(args.at);
+
+ // Convert possible depth parameter to index
+ if (!isNaN(insertAt) && (insertAt < 0 || insertAt === Number(-0))) {
+ // Negative value means going back from current chat length. (E.g.: 8 messages, Depth 1 means insert at index 7)
+ insertAt = chat.length + insertAt;
+ }
if (!isNaN(insertAt) && insertAt >= 0 && insertAt <= chat.length) {
chat.splice(insertAt, 0, message);
@@ -2784,7 +2859,13 @@ export async function sendNarratorMessage(args, text) {
},
};
- const insertAt = Number(args.at);
+ let insertAt = Number(args.at);
+
+ // Convert possible depth parameter to index
+ if (!isNaN(insertAt) && (insertAt < 0 || insertAt === Number(-0))) {
+ // Negative value means going back from current chat length. (E.g.: 8 messages, Depth 1 means insert at index 7)
+ insertAt = chat.length + insertAt;
+ }
if (!isNaN(insertAt) && insertAt >= 0 && insertAt <= chat.length) {
chat.splice(insertAt, 0, message);
@@ -2866,7 +2947,13 @@ async function sendCommentMessage(args, text) {
},
};
- const insertAt = Number(args.at);
+ let insertAt = Number(args.at);
+
+ // Convert possible depth parameter to index
+ if (!isNaN(insertAt) && (insertAt < 0 || insertAt === Number(-0))) {
+ // Negative value means going back from current chat length. (E.g.: 8 messages, Depth 1 means insert at index 7)
+ insertAt = chat.length + insertAt;
+ }
if (!isNaN(insertAt) && insertAt >= 0 && insertAt <= chat.length) {
chat.splice(insertAt, 0, message);
diff --git a/public/scripts/slash-commands/SlashCommandArgument.js b/public/scripts/slash-commands/SlashCommandArgument.js
index 76642a160..02c88b7c2 100644
--- a/public/scripts/slash-commands/SlashCommandArgument.js
+++ b/public/scripts/slash-commands/SlashCommandArgument.js
@@ -59,7 +59,7 @@ export class SlashCommandArgument {
* @param {string|SlashCommandEnumValue|(string|SlashCommandEnumValue)[]} enums
* @param {(executor:SlashCommandExecutor)=>SlashCommandEnumValue[]} enumProvider function that returns auto complete options
*/
- constructor(description, types, isRequired = false, acceptsMultiple = false, defaultValue = null, enums = [], enumProvider = null, forceEnum = true) {
+ constructor(description, types, isRequired = false, acceptsMultiple = false, defaultValue = null, enums = [], enumProvider = null, forceEnum = false) {
this.description = description;
this.typeList = types ? Array.isArray(types) ? types : [types] : [];
this.isRequired = isRequired ?? false;
@@ -90,7 +90,7 @@ export class SlashCommandNamedArgument extends SlashCommandArgument {
* @param {string|SlashCommandClosure} [props.defaultValue=null] default value if no value is provided
* @param {string|SlashCommandEnumValue|(string|SlashCommandEnumValue)[]} [props.enumList=[]] list of accepted values
* @param {(executor:SlashCommandExecutor)=>SlashCommandEnumValue[]} [props.enumProvider=null] function that returns auto complete options
- * @param {boolean} [props.forceEnum=true] default: true - whether the input must match one of the enum values
+ * @param {boolean} [props.forceEnum=false] default: false - whether the input must match one of the enum values
*/
static fromProps(props) {
return new SlashCommandNamedArgument(
@@ -103,7 +103,7 @@ export class SlashCommandNamedArgument extends SlashCommandArgument {
props.enumList ?? [],
props.aliasList ?? [],
props.enumProvider ?? null,
- props.forceEnum ?? true,
+ props.forceEnum ?? false,
);
}
@@ -120,9 +120,9 @@ export class SlashCommandNamedArgument extends SlashCommandArgument {
* @param {string|SlashCommandEnumValue|(string|SlashCommandEnumValue)[]} [enums=[]]
* @param {string[]} [aliases=[]]
* @param {(executor:SlashCommandExecutor)=>SlashCommandEnumValue[]} [enumProvider=null] function that returns auto complete options
- * @param {boolean} [forceEnum=true]
+ * @param {boolean} [forceEnum=false]
*/
- constructor(name, description, types, isRequired = false, acceptsMultiple = false, defaultValue = null, enums = [], aliases = [], enumProvider = null, forceEnum = true) {
+ constructor(name, description, types, isRequired = false, acceptsMultiple = false, defaultValue = null, enums = [], aliases = [], enumProvider = null, forceEnum = false) {
super(description, types, isRequired, acceptsMultiple, defaultValue, enums, enumProvider, forceEnum);
this.name = name;
this.aliasList = aliases ? Array.isArray(aliases) ? aliases : [aliases] : [];
diff --git a/src/endpoints/openai.js b/src/endpoints/openai.js
index 75de75b7b..f63d72b11 100644
--- a/src/endpoints/openai.js
+++ b/src/endpoints/openai.js
@@ -43,7 +43,11 @@ router.post('/caption-image', jsonParser, async (request, response) => {
key = readSecret(request.user.directories, SECRET_KEYS.KOBOLDCPP);
}
- if (!key && !request.body.reverse_proxy && ['custom', 'ooba', 'koboldcpp'].includes(request.body.api) === false) {
+ if (request.body.api === 'vllm') {
+ key = readSecret(request.user.directories, SECRET_KEYS.VLLM);
+ }
+
+ if (!key && !request.body.reverse_proxy && ['custom', 'ooba', 'koboldcpp', 'vllm'].includes(request.body.api) === false) {
console.log('No key found for API', request.body.api);
return response.sendStatus(400);
}
@@ -110,7 +114,7 @@ router.post('/caption-image', jsonParser, async (request, response) => {
});
}
- if (request.body.api === 'koboldcpp') {
+ if (request.body.api === 'koboldcpp' || request.body.api === 'vllm') {
apiUrl = `${trimV1(request.body.server_url)}/v1/chat/completions`;
}