Fix model restoration on load
| @@ -1652,7 +1652,8 @@ function saveModelList(data) { | ||
| 1652 | 1652 | })); |
| 1653 | 1653 | }); |
| 1654 | 1654 | |
| 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)) { | |
| 1656 | 1657 | oai_settings.nanogpt_model = model_list[0].id; |
| 1657 | 1658 | } |
| 1658 | 1659 | |
| @@ -4010,6 +4011,11 @@ async function onModelChange() { | ||
| 4010 | 4011 | } |
| 4011 | 4012 | |
| 4012 | 4013 | if ($(this).is('#model_nanogpt_select')) { |
| 4014 | + if (!value) { | |
| 4015 | + console.debug('Null NanoGPT model selected. Ignoring.'); | |
| 4016 | + return; | |
| 4017 | + } | |
| 4018 | + | |
| 4013 | 4019 | console.log('NanoGPT model changed to', value); |
| 4014 | 4020 | oai_settings.nanogpt_model = value; |
| 4015 | 4021 | } |