BugFixes and added top model categorie selection
| @@ -2274,7 +2274,7 @@ | |||
| 2274 | <option value="asc">A-Z</option> | 2274 | <option value="asc">A-Z</option> |
| 2275 | <option value="desc">Z-A</option> | 2275 | <option value="desc">Z-A</option> |
| 2276 | </select> | 2276 | </select> |
| 2277 | <select id="featherless_selection"> | 2277 | <select id="category_selection"> |
| 2278 | <option value="" disabled selected data-i18n="category">category</option> | 2278 | <option value="" disabled selected data-i18n="category">category</option> |
| 2279 | <option value="Favorite" data-i18n="Top">Favorite</option> | 2279 | <option value="Favorite" data-i18n="Top">Favorite</option> |
| 2280 | <option value="Top" data-i18n="Top">Top</option> | 2280 | <option value="Top" data-i18n="Top">Top</option> |
| @@ -265,12 +265,14 @@ export async function loadAphroditeModels(data) { | |||
| 265 | } | 265 | } |
| 266 | } | 266 | } |
| 267 | 267 | ||
| 268 | let selectedModelId = null; | ||
| 268 | export async function loadFeatherlessModels(data) { | 269 | export async function loadFeatherlessModels(data) { |
| 269 | const searchBar = document.getElementById('model_search_bar'); | 270 | const searchBar = document.getElementById('model_search_bar'); |
| 270 | const modelCardBlock = document.getElementById('model_card_block'); | 271 | const modelCardBlock = document.getElementById('model_card_block'); |
| 271 | const paginationContainer = $('#model_pagination_container'); | 272 | const paginationContainer = $('#model_pagination_container'); |
| 272 | const sortOrderSelect = document.getElementById('model_sort_order'); | 273 | const sortOrderSelect = document.getElementById('model_sort_order'); |
| 273 | const classSelect = document.getElementById('class_selection'); | 274 | const classSelect = document.getElementById('class_selection'); |
| 275 | const categoriesSelect = document.getElementById('category_selection'); | ||
| 274 | const storageKey = 'Models_PerPage'; | 276 | const storageKey = 'Models_PerPage'; |
| 275 | 277 | ||
| 276 | // Store the original models data for search and filtering | 278 | // Store the original models data for search and filtering |
| @@ -284,6 +286,7 @@ export async function loadFeatherlessModels(data) { | |||
| 284 | // Sort the data by model id (default A-Z) | 286 | // Sort the data by model id (default A-Z) |
| 285 | data.sort((a, b) => a.id.localeCompare(b.id)); | 287 | data.sort((a, b) => a.id.localeCompare(b.id)); |
| 286 | originalModels = data; // Store the original data for search | 288 | originalModels = data; // Store the original data for search |
| 289 | featherlessModels = data; | ||
| 287 | 290 | ||
| 288 | // Populate class select options with unique classes | 291 | // Populate class select options with unique classes |
| 289 | populateClassSelection(data); | 292 | populateClassSelection(data); |
| @@ -324,7 +327,7 @@ export async function loadFeatherlessModels(data) { | |||
| 324 | 327 | ||
| 325 | const modelTitle = document.createElement('div'); | 328 | const modelTitle = document.createElement('div'); |
| 326 | modelTitle.classList.add('model-title'); | 329 | modelTitle.classList.add('model-title'); |
| 327 | modelTitle.textContent = model.id; | 330 | modelTitle.textContent = model.id.replace(/_/g, '_\u200B'); |
| 328 | modelNameContainer.appendChild(modelTitle); | 331 | modelNameContainer.appendChild(modelTitle); |
| 329 | 332 | ||
| 330 | const detailsContainer = document.createElement('div'); | 333 | const detailsContainer = document.createElement('div'); |
| @@ -388,6 +391,10 @@ export async function loadFeatherlessModels(data) { | |||
| 388 | applyFiltersAndSort(); | 391 | applyFiltersAndSort(); |
| 389 | }); | 392 | }); |
| 390 | 393 | ||
| 394 | categoriesSelect.addEventListener('change', function() { | ||
| 395 | applyFiltersAndSort(); | ||
| 396 | }); | ||
| 397 | |||
| 391 | // Function to populate class selection dropdown | 398 | // Function to populate class selection dropdown |
| 392 | function populateClassSelection(models) { | 399 | function populateClassSelection(models) { |
| 393 | const uniqueClasses = [...new Set(models.map(model => model.model_class).filter(Boolean))]; // Get unique class names | 400 | 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) { | |||
| 400 | } | 407 | } |
| 401 | 408 | ||
| 402 | // Function to apply sorting and filtering based on user input | 409 | // Function to apply sorting and filtering based on user input |
| 403 | function applyFiltersAndSort() { | 410 | async function applyFiltersAndSort() { |
| 404 | const searchQuery = searchBar.value.toLowerCase(); | 411 | const searchQuery = searchBar.value.toLowerCase(); |
| 405 | const selectedSortOrder = sortOrderSelect.value; | 412 | const selectedSortOrder = sortOrderSelect.value; |
| 406 | const selectedClass = classSelect.value; | 413 | const selectedClass = classSelect.value; |
| 407 | 414 | const selectedCategory = categoriesSelect.value; | |
| 415 | const featherlessTop = await fetchFeatherlessStats(); | ||
| 416 | const featherlessIds = featherlessTop.map(stat => stat.id); | ||
| 408 | // Filter the models based on the search query and selected class | 417 | // Filter the models based on the search query and selected class |
| 409 | let filteredModels = originalModels.filter(model => { | 418 | let filteredModels = originalModels.filter(model => { |
| 410 | const matchesSearch = model.id.toLowerCase().includes(searchQuery); | 419 | const matchesSearch = model.id.toLowerCase().includes(searchQuery); |
| 411 | const matchesClass = selectedClass ? model.model_class === selectedClass : true; | 420 | 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 | |||
| 412 | return matchesSearch && matchesClass; | 430 | return matchesSearch && matchesClass; |
| 413 | }); | 431 | }); |
| 414 | 432 | ||
| @@ -424,14 +442,20 @@ export async function loadFeatherlessModels(data) { | |||
| 424 | } | 442 | } |
| 425 | } | 443 | } |
| 426 | 444 | ||
| 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 | |||
| 428 | function onFeatherlessModelSelect(modelId) { | 451 | function onFeatherlessModelSelect(modelId) { |
| 429 | // Find the selected model and set the settings | 452 | // Find the selected model and set the settings |
| 430 | const model = featherlessModels.find(x => x.id === modelId); | 453 | const model = featherlessModels.find(x => x.id === modelId); |
| 454 | selectedModelId = modelId; | ||
| 431 | textgen_settings.featherless_model = modelId; | 455 | textgen_settings.featherless_model = modelId; |
| 432 | $('#api_button_textgenerationwebui').trigger('click'); | 456 | $('#api_button_textgenerationwebui').trigger('click'); |
| 433 | setGenerationParamsFromPreset({ max_length: model.context_length }); | 457 | setGenerationParamsFromPreset({ max_length: model.context_length }); |
| 434 | selectedModelId = modelId; // Store the selected model ID | 458 | toastr.info(`Selected model: ${modelId}`, '', { timeOut: 2000 }); |
| 435 | } | 459 | } |
| 436 | 460 | ||
| 437 | let isGridView = true; // Default state set to grid view | 461 | let isGridView = true; // Default state set to grid view |
| @@ -5524,6 +5524,7 @@ body:not(.movingUI) .drawer-content.maximized { | |||
| 5524 | .model-title { | 5524 | .model-title { |
| 5525 | font-size: 16px; | 5525 | font-size: 16px; |
| 5526 | font-weight: bold; /* Bold text for the model title */ | 5526 | font-weight: bold; /* Bold text for the model title */ |
| 5527 | overflow: hidden; | ||
| 5527 | } | 5528 | } |
| 5528 | 5529 | ||
| 5529 | /* Model details section */ | 5530 | /* Model details section */ |
| @@ -5545,6 +5546,7 @@ body:not(.movingUI) .drawer-content.maximized { | |||
| 5545 | 5546 | ||
| 5546 | /* Grid-view layout for the card container */ | 5547 | /* Grid-view layout for the card container */ |
| 5547 | #model_card_block.grid-view { | 5548 | #model_card_block.grid-view { |
| 5549 | grid-row: 1 / span 2; /* Span two rows */ | ||
| 5548 | display: flex; | 5550 | display: flex; |
| 5549 | flex-wrap: wrap; /* Cards wrap onto new lines when necessary */ | 5551 | flex-wrap: wrap; /* Cards wrap onto new lines when necessary */ |
| 5550 | gap: 15px; /* Space between grid items */ | 5552 | gap: 15px; /* Space between grid items */ |
| @@ -5554,14 +5556,14 @@ body:not(.movingUI) .drawer-content.maximized { | |||
| 5554 | /* Grid-view card */ | 5556 | /* Grid-view card */ |
| 5555 | #model_card_block.grid-view .model-card { | 5557 | #model_card_block.grid-view .model-card { |
| 5556 | flex-direction: column; /* Stack title, class, and context length vertically for grid */ | 5558 | flex-direction: column; /* Stack title, class, and context length vertically for grid */ |
| 5557 | flex: 1 1 calc(33.33% - 30px); /* 3 cards per row with spacing */ | 5559 | flex: 1 1 calc(50% - 30px); /* 3 cards per row with spacing */ |
| 5558 | margin-bottom: 10px; | 5560 | margin-bottom: 10px; |
| 5559 | } | 5561 | } |
| 5560 | 5562 | ||
| 5561 | /* Ensure the search bar takes most of the width */ | 5563 | /* Ensure the search bar takes most of the width */ |
| 5562 | #model_search_bar { | 5564 | #model_search_bar { |
| 5563 | flex-grow: 1; | 5565 | flex-grow: 1; |
| 5564 | min-width: 0; | 5566 | min-width: 10ch; |
| 5565 | } | 5567 | } |
| 5566 | 5568 | ||
| 5567 | /* Sort dropdown should be auto-sized based on its content */ | 5569 | /* Sort dropdown should be auto-sized based on its content */ |
| @@ -5577,7 +5579,7 @@ body:not(.movingUI) .drawer-content.maximized { | |||
| 5577 | cursor: pointer; | 5579 | cursor: pointer; |
| 5578 | } | 5580 | } |
| 5579 | 5581 | ||
| 5580 | #featherless_selection | 5582 | #category_selection |
| 5581 | { | 5583 | { |
| 5582 | display: flex; | 5584 | display: flex; |
| 5583 | width: auto; | 5585 | width: auto; |