Fix model restoration on load

4babf322c1201d22c1b77207716c5ca1ad41dc2d

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

1 files changed, +7 -1Ignore whitespace
public/scripts/openai.js+7 -1
@@ -1652,7 +1652,8 @@ function saveModelList(data) {
16521652 }));
16531653 });
16541654
1655- if (!oai_settings.nanogpt_model && model_list.length > 0) {
1655+ const selectedModel = model_list.find(model => model.id === oai_settings.nanogpt_model);
1656+ if (model_list.length > 0 && (!selectedModel || !oai_settings.nanogpt_model)) {
16561657 oai_settings.nanogpt_model = model_list[0].id;
16571658 }
16581659
@@ -4010,6 +4011,11 @@ async function onModelChange() {
40104011 }
40114012
40124013 if ($(this).is('#model_nanogpt_select')) {
4014+ if (!value) {
4015+ console.debug('Null NanoGPT model selected. Ignoring.');
4016+ return;
4017+ }
4018+
40134019 console.log('NanoGPT model changed to', value);
40144020 oai_settings.nanogpt_model = value;
40154021 }