Move openai slash commands to init function

This commit is contained in:
Wolfsblvt
2024-07-11 22:43:25 +02:00
parent b80ed958ae
commit 63a0ebb885
2 changed files with 19 additions and 16 deletions

View File

@@ -101,6 +101,7 @@ import {
proxies, proxies,
loadProxyPresets, loadProxyPresets,
selected_proxy, selected_proxy,
initOpenai,
} from './scripts/openai.js'; } from './scripts/openai.js';
import { import {
@@ -915,6 +916,7 @@ async function firstLoadInit() {
initKeyboard(); initKeyboard();
initDynamicStyles(); initDynamicStyles();
initTags(); initTags();
initOpenai();
await getUserAvatars(true, user_avatar); await getUserAvatars(true, user_avatar);
await getCharacters(); await getCharacters();
await getBackgrounds(); await getBackgrounds();

View File

@@ -4679,22 +4679,23 @@ function runProxyCallback(_, value) {
return foundName; return foundName;
} }
SlashCommandParser.addCommandObject(SlashCommand.fromProps({ export function initOpenai() {
name: 'proxy', SlashCommandParser.addCommandObject(SlashCommand.fromProps({
callback: runProxyCallback, name: 'proxy',
returns: 'current proxy', callback: runProxyCallback,
namedArgumentList: [], returns: 'current proxy',
unnamedArgumentList: [ namedArgumentList: [],
SlashCommandArgument.fromProps({ unnamedArgumentList: [
description: 'name', SlashCommandArgument.fromProps({
typeList: [ARGUMENT_TYPE.STRING], description: 'name',
isRequired: true, typeList: [ARGUMENT_TYPE.STRING],
enumProvider: () => proxies.map(preset => new SlashCommandEnumValue(preset.name, preset.url)), isRequired: true,
}), enumProvider: () => proxies.map(preset => new SlashCommandEnumValue(preset.name, preset.url)),
], }),
helpString: 'Sets a proxy preset by name.', ],
})); helpString: 'Sets a proxy preset by name.',
}));
}
$(document).ready(async function () { $(document).ready(async function () {
$('#test_api_button').on('click', testApiConnection); $('#test_api_button').on('click', testApiConnection);