Refactor main slassh-commands into init func

cba2b54531293167424a7f4f17f3ba979cbe9a0a

Wolfsblvt <wolfsblvt@gmx.de>

2 files changed, +7 -5Showing whitespace changes
public/script.js+2 -1
@@ -159,7 +159,7 @@ import {
159import { debounce_timeout } from './scripts/constants.js';159import { debounce_timeout } from './scripts/constants.js';
160160
161import { ModuleWorkerWrapper, doDailyExtensionUpdatesCheck, extension_settings, getContext, loadExtensionSettings, renderExtensionTemplate, renderExtensionTemplateAsync, runGenerationInterceptors, saveMetadataDebounced, writeExtensionField } from './scripts/extensions.js';161import { ModuleWorkerWrapper, doDailyExtensionUpdatesCheck, extension_settings, getContext, loadExtensionSettings, renderExtensionTemplate, renderExtensionTemplateAsync, runGenerationInterceptors, saveMetadataDebounced, writeExtensionField } from './scripts/extensions.js';
162import { COMMENT_NAME_DEFAULT, executeSlashCommands, executeSlashCommandsOnChatInput, getSlashCommandsHelp, isExecutingCommandsFromChatInput, pauseScriptExecution, processChatSlashCommands, registerSlashCommand, stopScriptExecution } from './scripts/slash-commands.js';162import { COMMENT_NAME_DEFAULT, executeSlashCommands, executeSlashCommandsOnChatInput, getSlashCommandsHelp, initDefaultSlashCommands, isExecutingCommandsFromChatInput, pauseScriptExecution, processChatSlashCommands, registerSlashCommand, stopScriptExecution } from './scripts/slash-commands.js';
163import {163import {
164 tag_map,164 tag_map,
165 tags,165 tags,
@@ -911,6 +911,7 @@ async function firstLoadInit() {
911 initKeyboard();911 initKeyboard();
912 initDynamicStyles();912 initDynamicStyles();
913 initTags();913 initTags();
914 initDefaultSlashCommands();
914 await getUserAvatars(true, user_avatar);915 await getUserAvatars(true, user_avatar);
915 await getCharacters();916 await getCharacters();
916 await getBackgrounds();917 await getBackgrounds();
public/scripts/slash-commands.js+5 -4
@@ -38,13 +38,13 @@ import {
38 system_message_types,38 system_message_types,
39 this_chid,39 this_chid,
40} from '../script.js';40} from '../script.js';
41import { PARSER_FLAG, SlashCommandParser } from './slash-commands/SlashCommandParser.js';41import { SlashCommandParser } from './slash-commands/SlashCommandParser.js';
42import { SlashCommandParserError } from './slash-commands/SlashCommandParserError.js';42import { SlashCommandParserError } from './slash-commands/SlashCommandParserError.js';
43import { getMessageTimeStamp } from './RossAscends-mods.js';43import { getMessageTimeStamp } from './RossAscends-mods.js';
44import { hideChatMessageRange } from './chats.js';44import { hideChatMessageRange } from './chats.js';
45import { extension_settings, getContext, saveMetadataDebounced } from './extensions.js';45import { getContext, saveMetadataDebounced } from './extensions.js';
46import { getRegexedString, regex_placement } from './extensions/regex/engine.js';46import { getRegexedString, regex_placement } from './extensions/regex/engine.js';
47import { findGroupMemberId, getGroupMembers, groups, is_group_generating, openGroupById, resetSelectedGroup, saveGroupChat, selected_group } from './group-chats.js';47import { findGroupMemberId, groups, is_group_generating, openGroupById, resetSelectedGroup, saveGroupChat, selected_group } from './group-chats.js';
48import { chat_completion_sources, oai_settings, setupChatCompletionPromptManager } from './openai.js';48import { chat_completion_sources, oai_settings, setupChatCompletionPromptManager } from './openai.js';
49import { autoSelectPersona, retriggerFirstMessageOnEmptyChat, setPersonaLockState, togglePersonaLock, user_avatar } from './personas.js';49import { autoSelectPersona, retriggerFirstMessageOnEmptyChat, setPersonaLockState, togglePersonaLock, user_avatar } from './personas.js';
50import { addEphemeralStoppingString, chat_styles, flushEphemeralStoppingStrings, power_user } from './power-user.js';50import { addEphemeralStoppingString, chat_styles, flushEphemeralStoppingStrings, power_user } from './power-user.js';
@@ -53,7 +53,6 @@ import { decodeTextTokens, getFriendlyTokenizerName, getTextTokens, getTokenCoun
53import { debounce, delay, isFalseBoolean, isTrueBoolean, stringToRange, trimToEndSentence, trimToStartSentence, waitUntilCondition } from './utils.js';53import { debounce, delay, isFalseBoolean, isTrueBoolean, stringToRange, trimToEndSentence, trimToStartSentence, waitUntilCondition } from './utils.js';
54import { registerVariableCommands, resolveVariable } from './variables.js';54import { registerVariableCommands, resolveVariable } from './variables.js';
55import { background_settings } from './backgrounds.js';55import { background_settings } from './backgrounds.js';
56import { SlashCommandScope } from './slash-commands/SlashCommandScope.js';
57import { SlashCommandClosure } from './slash-commands/SlashCommandClosure.js';56import { SlashCommandClosure } from './slash-commands/SlashCommandClosure.js';
58import { SlashCommandClosureResult } from './slash-commands/SlashCommandClosureResult.js';57import { SlashCommandClosureResult } from './slash-commands/SlashCommandClosureResult.js';
59import { ARGUMENT_TYPE, SlashCommandArgument, SlashCommandNamedArgument } from './slash-commands/SlashCommandArgument.js';58import { ARGUMENT_TYPE, SlashCommandArgument, SlashCommandNamedArgument } from './slash-commands/SlashCommandArgument.js';
@@ -75,6 +74,7 @@ export const parser = new SlashCommandParser();
75const registerSlashCommand = SlashCommandParser.addCommand.bind(SlashCommandParser);74const registerSlashCommand = SlashCommandParser.addCommand.bind(SlashCommandParser);
76const getSlashCommandsHelp = parser.getHelpString.bind(parser);75const getSlashCommandsHelp = parser.getHelpString.bind(parser);
7776
77export function initDefaultSlashCommands() {
78 SlashCommandParser.addCommandObject(SlashCommand.fromProps({78 SlashCommandParser.addCommandObject(SlashCommand.fromProps({
79 name: '?',79 name: '?',
80 callback: helpCommandCallback,80 callback: helpCommandCallback,
@@ -1387,6 +1387,7 @@ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
1387 }));1387 }));
13881388
1389 registerVariableCommands();1389 registerVariableCommands();
1390}
13901391
1391const NARRATOR_NAME_KEY = 'narrator_name';1392const NARRATOR_NAME_KEY = 'narrator_name';
1392const NARRATOR_NAME_DEFAULT = 'System';1393const NARRATOR_NAME_DEFAULT = 'System';