Files
DemonGatanjieuandClaude Opus 5.5 98148481bc Models page tabs, base model filter, Tidy tab redone with covers
- The models page has tabs: All models, Tidy (with its count) and Sources;
  the type bar keeps the type chips and Import.
- Base model chips under the type chips (All, Illustrious, SDXL, Unknown...),
  one per family the listed models have (model_bases.js; SDXL 1.0 = SDXL);
  models not scanned are listed by their header's guess (metadata base_guess).
- Tidy is cards with the model's cover and name in two steps: models in a
  folder whose loader cannot read them (from -> to, one plain reason, Move
  there, Change place), and identical files side by side with the copy to
  keep marked (the one in the right folder; click another to change) and one
  button for the extra copies. Models that load anyway and extra copies of a
  well-placed file are not in step 1. Same-size files up to 256 MB are
  compared at once; larger ones on Compare.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-08 23:02:00 +08:00

28 lines
1.2 KiB
JavaScript

/**
* The models page's base model filter: which family a model is listed under (its scanned base
* model, else what its header tells, named as download_places.js names base model folders, so
* "SDXL 1.0" and "SDXL" are one) and how many of each a list has. No DOM.
*/
import { baseFolder } from './download_places.js';
/** The base model family a model is listed under; '' when not known. */
export function baseFamily(model) {
const meta = model?.metadata || {};
const base = String(meta.baseModel || meta.base_guess || '').trim();
return /^(unknown|other)?$/i.test(base) ? '' : baseFolder(base);
}
/** [[family, count]] of `models`, most first, the unknown ones last. */
export function countBases(models) {
const counts = new Map();
for (const model of models || []) {
const family = baseFamily(model);
counts.set(family, (counts.get(family) || 0) + 1);
}
return [...counts].sort((a, b) => Number(a[0] === '') - Number(b[0] === '') || b[1] - a[1] || a[0].localeCompare(b[0]));
}
/** Whether a model is listed under `family` (null: every model). */
export const inFamily = (model, family) => family === null || family === undefined || baseFamily(model) === family;