Fix connection profile for CC setting incorrect source by preset

This commit is contained in:
Cohee 2024-09-19 23:12:33 +03:00
parent 5269725f1c
commit 9197ed7fce
2 changed files with 19 additions and 11 deletions

View File

@ -8569,20 +8569,27 @@ async function connectAPISlash(args, text) {
return ''; return '';
} }
$(`#main_api option[value='${apiConfig.selected || text}']`).prop('selected', true); let connectionRequired = false;
$('#main_api').trigger('change');
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 option[value='${apiConfig.source}']`).prop('selected', true);
$('#chat_completion_source').trigger('change'); $('#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 option[value='${apiConfig.type}']`).prop('selected', true);
$('#textgen_type').trigger('change'); $('#textgen_type').trigger('change');
connectionRequired = true;
} }
if (apiConfig.button) { if (connectionRequired && apiConfig.button) {
$(apiConfig.button).trigger('click'); $(apiConfig.button).trigger('click');
} }

View File

@ -19,20 +19,21 @@ const DEFAULT_SETTINGS = {
selectedProfile: null, selectedProfile: null,
}; };
const COMMON_COMMANDS = [ const CC_COMMANDS = [
'api', 'api',
'preset', 'preset',
// Do not fix; CC needs to set the API twice because it could be overridden by the preset
'api',
'api-url', 'api-url',
'model', 'model',
];
const CC_COMMANDS = [
...COMMON_COMMANDS,
'proxy', 'proxy',
]; ];
const TC_COMMANDS = [ const TC_COMMANDS = [
...COMMON_COMMANDS, 'api',
'preset',
'api-url',
'model',
'instruct', 'instruct',
'context', 'context',
'instruct-state', 'instruct-state',