| 288 | originalModels = data; // Store the original data for search | 288 | originalModels = data; // Store the original data for search |
| 289 | featherlessModels = data; | 289 | featherlessModels = data; |
| 290 | | 290 | |
| | 291 | if (!data.find(x => x.id === textgen_settings.featherless_model)) { |
| | 292 | textgen_settings.featherless_model = data[0]?.id || ''; |
| | 293 | } |
| | 294 | |
| 291 | // Populate class select options with unique classes | 295 | // Populate class select options with unique classes |
| 292 | populateClassSelection(data); | 296 | populateClassSelection(data); |
| 293 | | 297 | |
| 294 | // Retrieve the stored number of items per page or default to 5 | 298 | // Retrieve the stored number of items per page or default to 10 |
| 295 | const perPage = Number(localStorage.getItem(storageKey)) || 10; | 299 | const perPage = Number(localStorage.getItem(storageKey)) || 10; |
| 296 | | 300 | |
| 297 | // Initialize pagination with the full set of models | 301 | // Initialize pagination with the full set of models |
| 298 | const selectedModelPage = (data.findIndex(x => x.id === textgen_settings.featherless_model) / perPage) + 1; | 302 | const currentModelIndex = data.findIndex(x => x.id === textgen_settings.featherless_model); |
| 299 | featherlessCurrentPage = selectedModelPage > 0 ? selectedModelPage : 1; | 303 | featherlessCurrentPage = currentModelIndex >= 0 ? (currentModelIndex / perPage) + 1 : 1; |
| 300 | setupPagination(originalModels, perPage); | 304 | setupPagination(originalModels, perPage); |
| 301 | | 305 | |
| 302 | // Function to set up pagination (also used for filtered results) | 306 | // Function to set up pagination (also used for filtered results) |