diff --git a/public/scripts/extensions/expressions/index.js b/public/scripts/extensions/expressions/index.js index 9ed19a71f..f6beb9375 100644 --- a/public/scripts/extensions/expressions/index.js +++ b/public/scripts/extensions/expressions/index.js @@ -885,6 +885,22 @@ async function setSpriteSetCommand(_, folder) { moduleWorker(); } +async function classifyCommand(_, text) { + if (!text) { + console.log('No text provided'); + return ''; + } + + if (!modules.includes('classify') && !extension_settings.expressions.local) { + toastr.warning('Text classification is disabled or not available'); + return ''; + } + + const label = getExpressionLabel(text); + console.debug(`Classification result for "${text}": ${label}`); + return label; +} + async function setSpriteSlashCommand(_, spriteId) { if (!spriteId) { console.log('No sprite id provided'); @@ -1758,5 +1774,6 @@ async function fetchImagesNoCache() { registerSlashCommand('sprite', setSpriteSlashCommand, ['emote'], '(spriteId) – force sets the sprite for the current character', true, true); registerSlashCommand('spriteoverride', setSpriteSetCommand, ['costume'], '(optional folder) – sets an override sprite folder for the current character. If the name starts with a slash or a backslash, selects a sub-folder in the character-named folder. Empty value to reset to default.', true, true); registerSlashCommand('lastsprite', (_, value) => lastExpression[value.trim()] ?? '', [], '(charName) – Returns the last set sprite / expression for the named character.', true, true); - registerSlashCommand('th', toggleTalkingHeadCommand, ['talkinghead'], '– Character Expressions: toggles Image Type - talkinghead (extras) on/off.'); + registerSlashCommand('th', toggleTalkingHeadCommand, ['talkinghead'], '– Character Expressions: toggles Image Type - talkinghead (extras) on/off.', true, true); + registerSlashCommand('classify', classifyCommand, [], '(text) – classifies the text and returns a label.', true, true); })();