replace registerSlashCommand with detailed declarations

This commit is contained in:
LenAnderson
2024-04-24 18:50:16 -04:00
parent e7da03d64d
commit 586fe54913
16 changed files with 966 additions and 79 deletions

View File

@ -1,6 +1,8 @@
import { callPopup, main_api } from '../../../script.js';
import { getContext } from '../../extensions.js';
import { registerSlashCommand } from '../../slash-commands.js';
import { SlashCommand } from '../../slash-commands/SlashCommand.js';
import { SlashCommandParser } from '../../slash-commands/SlashCommandParser.js';
import { getFriendlyTokenizerName, getTextTokens, getTokenCountAsync, tokenizers } from '../../tokenizers.js';
import { resetScrollHeight, debounce } from '../../utils.js';
@ -131,5 +133,11 @@ jQuery(() => {
</div>`;
$('#extensionsMenu').prepend(buttonHtml);
$('#token_counter').on('click', doTokenCounter);
registerSlashCommand('count', doCount, [], ' counts the number of tokens in the current chat', true, false);
SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'count',
callback: doCount,
helpString: 'Counts the number of tokens in the current chat.',
interruptsGeneration: true,
purgeFromMessage: false,
}));
});