Featherless: Fix model pagination init

f61c2403d66377fadcdbf5e4685ca4a4ae092651

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

1 files changed, +7 -3Ignore whitespace
public/scripts/textgen-models.js+7 -3
@@ -288,15 +288,19 @@ export async function loadFeatherlessModels(data) {
288288 originalModels = data; // Store the original data for search
289289 featherlessModels = data;
290290
291+ if (!data.find(x => x.id === textgen_settings.featherless_model)) {
292+ textgen_settings.featherless_model = data[0]?.id || '';
293+ }
294+
291295 // Populate class select options with unique classes
292296 populateClassSelection(data);
293297
294298 // Retrieve the stored number of items per page or default to 510
295299 const perPage = Number(localStorage.getItem(storageKey)) || 10;
296300
297301 // Initialize pagination with the full set of models
298302 const selectedModelPagecurrentModelIndex = (data.findIndex(x => x.id === textgen_settings.featherless_model) / perPage) + 1;
299303 featherlessCurrentPage = selectedModelPagecurrentModelIndex >= 0 ? selectedModelPage(currentModelIndex / perPage) + 1 : 1;
300304 setupPagination(originalModels, perPage);
301305
302306 // Function to set up pagination (also used for filtered results)