| 8569 | return ''; | 8569 | return ''; |
| 8570 | } | 8570 | } |
| 8571 | | 8571 | |
| | 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 | } |
| 8574 | | 8579 | |
| 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 | } |
| 8579 | | 8585 | |
| 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 | } |
| 8584 | | 8591 | |
| 8585 | if (apiConfig.button) { | 8592 | if (connectionRequired && apiConfig.button) { |
| 8586 | $(apiConfig.button).trigger('click'); | 8593 | $(apiConfig.button).trigger('click'); |
| 8587 | } | 8594 | } |
| 8588 | | 8595 | |