MistralAI: fix selection of endpoint provided models

addfcade32dc3481e8c831626ef338ffd78e05b7

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

1 files changed, +6 -3Showing whitespace changes
public/scripts/openai.js+6 -3
@@ -1858,8 +1858,9 @@ function saveModelList(data) {
18581858 const selectedModel = model_list.find(model => model.id === oai_settings.mistralai_model);
18591859 if (!selectedModel) {
18601860 oai_settings.mistralai_model = model_list.find(model => model?.capabilities?.completion_chat)?.id;
1861- $('#model_mistralai_select').val(oai_settings.mistralai_model).trigger('change');
18621861 }
1862+
1863+ $('#model_mistralai_select').val(oai_settings.mistralai_model).trigger('change');
18631864 }
18641865 }
18651866
@@ -4643,12 +4644,14 @@ async function onModelChange() {
46434644 }
46444645
46454646 if ($(this).is('#model_mistralai_select')) {
4647+ if (!value) {
4648+ console.debug('Null MistralAI model selected. Ignoring.');
4649+ return;
4650+ }
46464651 // Upgrade old mistral models to new naming scheme
46474652 // would have done this in loadOpenAISettings, but it wasn't updating on preset change?
46484653 if (value === 'mistral-medium' || value === 'mistral-small') {
46494654 value = value + '-latest';
4650- } else if (value === '') {
4651- value = default_settings.mistralai_model;
46524655 }
46534656 console.log('MistralAI model changed to', value);
46544657 oai_settings.mistralai_model = value;