diff --git a/public/script.js b/public/script.js index 07c568cf4..0d4c96b13 100644 --- a/public/script.js +++ b/public/script.js @@ -8569,20 +8569,27 @@ async function connectAPISlash(args, text) { return ''; } - $(`#main_api option[value='${apiConfig.selected || text}']`).prop('selected', true); - $('#main_api').trigger('change'); + let connectionRequired = false; - if (apiConfig.source) { + if (main_api !== apiConfig.selected) { + $(`#main_api option[value='${apiConfig.selected || text}']`).prop('selected', true); + $('#main_api').trigger('change'); + connectionRequired = true; + } + + if (apiConfig.source && oai_settings.chat_completion_source !== apiConfig.source) { $(`#chat_completion_source option[value='${apiConfig.source}']`).prop('selected', true); $('#chat_completion_source').trigger('change'); + connectionRequired = true; } - if (apiConfig.type) { + if (apiConfig.type && textgen_settings.type !== apiConfig.type) { $(`#textgen_type option[value='${apiConfig.type}']`).prop('selected', true); $('#textgen_type').trigger('change'); + connectionRequired = true; } - if (apiConfig.button) { + if (connectionRequired && apiConfig.button) { $(apiConfig.button).trigger('click'); } diff --git a/public/scripts/extensions/connection-manager/index.js b/public/scripts/extensions/connection-manager/index.js index 2fbcdec2b..91f0badb0 100644 --- a/public/scripts/extensions/connection-manager/index.js +++ b/public/scripts/extensions/connection-manager/index.js @@ -19,20 +19,21 @@ const DEFAULT_SETTINGS = { selectedProfile: null, }; -const COMMON_COMMANDS = [ +const CC_COMMANDS = [ 'api', 'preset', + // Do not fix; CC needs to set the API twice because it could be overridden by the preset + 'api', 'api-url', 'model', -]; - -const CC_COMMANDS = [ - ...COMMON_COMMANDS, 'proxy', ]; const TC_COMMANDS = [ - ...COMMON_COMMANDS, + 'api', + 'preset', + 'api-url', + 'model', 'instruct', 'context', 'instruct-state',