Apply regex to parsed reasoning
| @@ -8,7 +8,7 @@ import { SlashCommand } from './slash-commands/SlashCommand.js'; | ||
| 8 | 8 | import { ARGUMENT_TYPE, SlashCommandArgument, SlashCommandNamedArgument } from './slash-commands/SlashCommandArgument.js'; |
| 9 | 9 | import { commonEnumProviders } from './slash-commands/SlashCommandCommonEnumsProvider.js'; |
| 10 | 10 | import { SlashCommandParser } from './slash-commands/SlashCommandParser.js'; |
| 11 | 11 | import { copyText, escapeRegex, isFalseBoolean } from './utils.js'; |
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | 14 | * Gets a message from a jQuery element. |
| @@ -172,13 +172,22 @@ function registerReasoningSlashCommands() { | ||
| 172 | 172 | name: 'reasoning-parse', |
| 173 | 173 | returns: 'reasoning string', |
| 174 | 174 | helpString: t`Extracts the reasoning block from a string using the Reasoning Formatting settings.`, |
| 175 | + namedArgumentList: [ | |
| 176 | + SlashCommandNamedArgument.fromProps({ | |
| 177 | + name: 'regex', | |
| 178 | + description: 'Whether to apply regex scripts to the reasoning content.', | |
| 179 | + typeList: ARGUMENT_TYPE.BOOLEAN, | |
| 180 | + defaultValue: 'true', | |
| 181 | + isRequired: false, | |
| 182 | + }), | |
| 183 | + ], | |
| 175 | 184 | unnamedArgumentList: [ |
| 176 | 185 | SlashCommandArgument.fromProps({ |
| 177 | 186 | description: 'input string', |
| 178 | 187 | typeList: ARGUMENT_TYPE.STRING, |
| 179 | 188 | }), |
| 180 | 189 | ], |
| 181 | 190 | callback: (_args, value) => { |
| 182 | 191 | if (!value) { |
| 183 | 192 | return ''; |
| 184 | 193 | } |
| @@ -194,7 +203,10 @@ function registerReasoningSlashCommands() { | ||
| 194 | 203 | return ''; |
| 195 | 204 | } |
| 196 | 205 | |
| 197 | - return getRegexedString(parsedReasoning.reasoning, regex_placement.REASONING); | |
| 206 | + const applyRegex = !isFalseBoolean(args.regex.toString()); | |
| 207 | + return applyRegex | |
| 208 | + ? getRegexedString(parsedReasoning.reasoning, regex_placement.REASONING) | |
| 209 | + : parsedReasoning.reasoning; | |
| 198 | 210 | }, |
| 199 | 211 | })); |
| 200 | 212 | } |
| @@ -398,7 +410,7 @@ function registerReasoningAppEvents() { | ||
| 398 | 410 | |
| 399 | 411 | // If reasoning was found, add it to the message |
| 400 | 412 | if (parsedReasoning.reasoning) { |
| 401 | 413 | message.extra.reasoning = getRegexedString(parsedReasoning.reasoning, regex_placement.REASONING); |
| 402 | 414 | } |
| 403 | 415 | |
| 404 | 416 | // Update the message text if it was changed |