Fix connection profile for CC setting incorrect source by preset

9197ed7fcef9ca9ab6c443bbb1de770d1af311ec

Cohee <18619528+Cohee1207@users.noreply.github.com>

2 files changed, +17 -9Showing whitespace changes
public/script.js+10 -3
@@ -8569,20 +8569,27 @@ async function connectAPISlash(args, text) {
8569 return '';8569 return '';
8570 }8570 }
85718571
8572 let connectionRequired = false;
8573
8574 if (main_api !== apiConfig.selected) {
8572 $(`#main_api option[value='${apiConfig.selected || text}']`).prop('selected', true);8575 $(`#main_api option[value='${apiConfig.selected || text}']`).prop('selected', true);
8573 $('#main_api').trigger('change');8576 $('#main_api').trigger('change');
8577 connectionRequired = true;
8578 }
85748579
8575 if (apiConfig.source) {8580 if (apiConfig.source && oai_settings.chat_completion_source !== apiConfig.source) {
8576 $(`#chat_completion_source option[value='${apiConfig.source}']`).prop('selected', true);8581 $(`#chat_completion_source option[value='${apiConfig.source}']`).prop('selected', true);
8577 $('#chat_completion_source').trigger('change');8582 $('#chat_completion_source').trigger('change');
8583 connectionRequired = true;
8578 }8584 }
85798585
8580 if (apiConfig.type) {8586 if (apiConfig.type && textgen_settings.type !== apiConfig.type) {
8581 $(`#textgen_type option[value='${apiConfig.type}']`).prop('selected', true);8587 $(`#textgen_type option[value='${apiConfig.type}']`).prop('selected', true);
8582 $('#textgen_type').trigger('change');8588 $('#textgen_type').trigger('change');
8589 connectionRequired = true;
8583 }8590 }
85848591
8585 if (apiConfig.button) {8592 if (connectionRequired && apiConfig.button) {
8586 $(apiConfig.button).trigger('click');8593 $(apiConfig.button).trigger('click');
8587 }8594 }
85888595
public/scripts/extensions/connection-manager/index.js+7 -6
@@ -19,20 +19,21 @@ const DEFAULT_SETTINGS = {
19 selectedProfile: null,19 selectedProfile: null,
20};20};
2121
22const COMMON_COMMANDS = [22const CC_COMMANDS = [
23 'api',23 'api',
24 'preset',24 'preset',
25 // Do not fix; CC needs to set the API twice because it could be overridden by the preset
26 'api',
25 'api-url',27 'api-url',
26 'model',28 'model',
27];
28
29const CC_COMMANDS = [
30 ...COMMON_COMMANDS,
31 'proxy',29 'proxy',
32];30];
3331
34const TC_COMMANDS = [32const TC_COMMANDS = [
35 ...COMMON_COMMANDS,33 'api',
34 'preset',
35 'api-url',
36 'model',
36 'instruct',37 'instruct',
37 'context',38 'context',
38 'instruct-state',39 'instruct-state',