BugFixes and added top model categorie selection

409d83e6ea35e8957afecbe01e9797669df9be1f

DarokCx <77368869+DarokCx@users.noreply.github.com>

3 files changed, +35 -9Ignore whitespace
public/index.html+1 -1
@@ -2274,7 +2274,7 @@
22742274 <option value="asc">A-Z</option>
22752275 <option value="desc">Z-A</option>
22762276 </select>
22772277 <select id="featherless_selectioncategory_selection">
22782278 <option value="" disabled selected data-i18n="category">category</option>
22792279 <option value="Favorite" data-i18n="Top">Favorite</option>
22802280 <option value="Top" data-i18n="Top">Top</option>
public/scripts/textgen-models.js+29 -5
@@ -265,12 +265,14 @@ export async function loadAphroditeModels(data) {
265265 }
266266}
267267
268+let selectedModelId = null;
268269export async function loadFeatherlessModels(data) {
269270 const searchBar = document.getElementById('model_search_bar');
270271 const modelCardBlock = document.getElementById('model_card_block');
271272 const paginationContainer = $('#model_pagination_container');
272273 const sortOrderSelect = document.getElementById('model_sort_order');
273274 const classSelect = document.getElementById('class_selection');
275+ const categoriesSelect = document.getElementById('category_selection');
274276 const storageKey = 'Models_PerPage';
275277
276278 // Store the original models data for search and filtering
@@ -284,6 +286,7 @@ export async function loadFeatherlessModels(data) {
284286 // Sort the data by model id (default A-Z)
285287 data.sort((a, b) => a.id.localeCompare(b.id));
286288 originalModels = data; // Store the original data for search
289+ featherlessModels = data;
287290
288291 // Populate class select options with unique classes
289292 populateClassSelection(data);
@@ -324,7 +327,7 @@ export async function loadFeatherlessModels(data) {
324327
325328 const modelTitle = document.createElement('div');
326329 modelTitle.classList.add('model-title');
327330 modelTitle.textContent = model.id.replace(/_/g, '_\u200B');
328331 modelNameContainer.appendChild(modelTitle);
329332
330333 const detailsContainer = document.createElement('div');
@@ -388,6 +391,10 @@ export async function loadFeatherlessModels(data) {
388391 applyFiltersAndSort();
389392 });
390393
394+ categoriesSelect.addEventListener('change', function() {
395+ applyFiltersAndSort();
396+ });
397+
391398 // Function to populate class selection dropdown
392399 function populateClassSelection(models) {
393400 const uniqueClasses = [...new Set(models.map(model => model.model_class).filter(Boolean))]; // Get unique class names
@@ -400,15 +407,26 @@ export async function loadFeatherlessModels(data) {
400407 }
401408
402409 // Function to apply sorting and filtering based on user input
403410 async function applyFiltersAndSort() {
404411 const searchQuery = searchBar.value.toLowerCase();
405412 const selectedSortOrder = sortOrderSelect.value;
406413 const selectedClass = classSelect.value;
407-
414+ const selectedCategory = categoriesSelect.value;
415+ const featherlessTop = await fetchFeatherlessStats();
416+ const featherlessIds = featherlessTop.map(stat => stat.id);
408417 // Filter the models based on the search query and selected class
409418 let filteredModels = originalModels.filter(model => {
410419 const matchesSearch = model.id.toLowerCase().includes(searchQuery);
411420 const matchesClass = selectedClass ? model.model_class === selectedClass : true;
421+ const matchesTop = featherlessIds.includes(model.id);
422+
423+ if (selectedCategory === 'All') {
424+ return matchesSearch && matchesClass;
425+ }
426+ else if (selectedCategory === 'Top') {
427+ return matchesSearch && matchesClass && matchesTop;
428+ }
429+
412430 return matchesSearch && matchesClass;
413431 });
414432
@@ -424,14 +442,20 @@ export async function loadFeatherlessModels(data) {
424442 }
425443}
426444
427-let selectedModelId = null;
445+async function fetchFeatherlessStats() {
446+ const response = await fetch('https://api.featherless.ai/feather/popular');
447+ const data = await response.json();
448+ return data.popular;
449+}
450+
428451function onFeatherlessModelSelect(modelId) {
429452 // Find the selected model and set the settings
430453 const model = featherlessModels.find(x => x.id === modelId);
454+ selectedModelId = modelId;
431455 textgen_settings.featherless_model = modelId;
432456 $('#api_button_textgenerationwebui').trigger('click');
433457 setGenerationParamsFromPreset({ max_length: model.context_length });
434- selectedModelId = modelId; // Store the selected model ID
458+ toastr.info(`Selected model: ${modelId}`, '', { timeOut: 2000 });
435459}
436460
437461let isGridView = true; // Default state set to grid view
public/style.css+5 -3
@@ -5524,6 +5524,7 @@ body:not(.movingUI) .drawer-content.maximized {
55245524.model-title {
55255525 font-size: 16px;
55265526 font-weight: bold; /* Bold text for the model title */
5527+ overflow: hidden;
55275528}
55285529
55295530/* Model details section */
@@ -5545,6 +5546,7 @@ body:not(.movingUI) .drawer-content.maximized {
55455546
55465547/* Grid-view layout for the card container */
55475548#model_card_block.grid-view {
5549+ grid-row: 1 / span 2; /* Span two rows */
55485550 display: flex;
55495551 flex-wrap: wrap; /* Cards wrap onto new lines when necessary */
55505552 gap: 15px; /* Space between grid items */
@@ -5554,14 +5556,14 @@ body:not(.movingUI) .drawer-content.maximized {
55545556/* Grid-view card */
55555557#model_card_block.grid-view .model-card {
55565558 flex-direction: column; /* Stack title, class, and context length vertically for grid */
55575559 flex: 1 1 calc(33.3350% - 30px); /* 3 cards per row with spacing */
55585560 margin-bottom: 10px;
55595561}
55605562
55615563/* Ensure the search bar takes most of the width */
55625564#model_search_bar {
55635565 flex-grow: 1;
55645566 min-width: 010ch;
55655567}
55665568
55675569/* Sort dropdown should be auto-sized based on its content */
@@ -5577,7 +5579,7 @@ body:not(.movingUI) .drawer-content.maximized {
55775579 cursor: pointer;
55785580}
55795581
55805582#featherless_selectioncategory_selection
55815583{
55825584 display: flex;
55835585 width: auto;