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) {
1858 const selectedModel = model_list.find(model => model.id === oai_settings.mistralai_model);1858 const selectedModel = model_list.find(model => model.id === oai_settings.mistralai_model);
1859 if (!selectedModel) {1859 if (!selectedModel) {
1860 oai_settings.mistralai_model = model_list.find(model => model?.capabilities?.completion_chat)?.id;1860 oai_settings.mistralai_model = model_list.find(model => model?.capabilities?.completion_chat)?.id;
1861 $('#model_mistralai_select').val(oai_settings.mistralai_model).trigger('change');
1862 }1861 }
1862
1863 $('#model_mistralai_select').val(oai_settings.mistralai_model).trigger('change');
1863 }1864 }
1864 }1865 }
18651866
@@ -4643,12 +4644,14 @@ async function onModelChange() {
4643 }4644 }
46444645
4645 if ($(this).is('#model_mistralai_select')) {4646 if ($(this).is('#model_mistralai_select')) {
4647 if (!value) {
4648 console.debug('Null MistralAI model selected. Ignoring.');
4649 return;
4650 }
4646 // Upgrade old mistral models to new naming scheme4651 // Upgrade old mistral models to new naming scheme
4647 // would have done this in loadOpenAISettings, but it wasn't updating on preset change?4652 // would have done this in loadOpenAISettings, but it wasn't updating on preset change?
4648 if (value === 'mistral-medium' || value === 'mistral-small') {4653 if (value === 'mistral-medium' || value === 'mistral-small') {
4649 value = value + '-latest';4654 value = value + '-latest';
4650 } else if (value === '') {
4651 value = default_settings.mistralai_model;
4652 }4655 }
4653 console.log('MistralAI model changed to', value);4656 console.log('MistralAI model changed to', value);
4654 oai_settings.mistralai_model = value;4657 oai_settings.mistralai_model = value;