- Files tab: "Download more" adds files to a model's selection and queues them - Colored file labels (Model, MTP, Vision/mmproj, imatrix, Config, …) - Split GGUF/safetensors parts shown and selected as one entry everywhere - Settings page with a Labels section: file label names/colors, tag rename/recolor/delete; new settings table and tags.color - Quants only count model weights Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
151 lines
6.0 KiB
TypeScript
151 lines
6.0 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import { describe, it } from "node:test";
|
|
import { groupSplitFiles, splitInfo } from "./file-groups";
|
|
import { fileRole } from "./file-roles";
|
|
import { modelFamilies, parseRepoMetadata } from "./hub/metadata";
|
|
import { EMPTY_FILTERS, facetCounts, matchesFilters, matchesQuery, type SearchableModel } from "./search";
|
|
|
|
describe("parseRepoMetadata (real Hub responses, trimmed)", () => {
|
|
it("unsloth GGUF quant of Qwen", () => {
|
|
const m = parseRepoMetadata({
|
|
id: "unsloth/Qwen3-8B-GGUF",
|
|
author: "unsloth",
|
|
pipeline_tag: "text-generation",
|
|
tags: ["transformers", "gguf", "qwen3", "qwen", "unsloth", "base_model:Qwen/Qwen3-8B", "base_model:quantized:Qwen/Qwen3-8B", "license:apache-2.0", "endpoints_compatible", "conversational", "arxiv:2309.00071"],
|
|
cardData: { base_model: "Qwen/Qwen3-8B", license: "apache-2.0" },
|
|
gguf: { architecture: "qwen3" },
|
|
});
|
|
assert.deepEqual(m.baseModels, ["Qwen/Qwen3-8B"]);
|
|
assert.equal(m.architecture, "qwen3");
|
|
assert.equal(m.license, "apache-2.0");
|
|
assert.deepEqual(m.hubTags, ["transformers", "gguf", "qwen3", "qwen", "unsloth"]);
|
|
assert.deepEqual(modelFamilies("unsloth/Qwen3-8B-GGUF", m.baseModels), ["Qwen"]);
|
|
});
|
|
|
|
it("finetune with base_model as array and config.model_type", () => {
|
|
const m = parseRepoMetadata({
|
|
id: "TheDrummer/Cydonia-24B-v4.1",
|
|
author: "TheDrummer",
|
|
tags: ["safetensors", "mistral"],
|
|
cardData: { base_model: ["mistralai/Mistral-Small-3.2-24B-Instruct-2507"] },
|
|
config: { model_type: "mistral" },
|
|
});
|
|
assert.deepEqual(m.baseModels, ["mistralai/Mistral-Small-3.2-24B-Instruct-2507"]);
|
|
assert.equal(m.architecture, "mistral");
|
|
assert.deepEqual(modelFamilies("TheDrummer/Cydonia-24B-v4.1", m.baseModels), ["mistralai"]);
|
|
});
|
|
|
|
it("falls back to base_model tags; original models are their own family", () => {
|
|
const m = parseRepoMetadata({ id: "x/y", tags: ["base_model:finetune:Qwen/Qwen3-8B-Base"] });
|
|
assert.deepEqual(m.baseModels, ["Qwen/Qwen3-8B-Base"]);
|
|
assert.equal(m.author, "x");
|
|
assert.deepEqual(modelFamilies("Qwen/Qwen3-8B", []), ["Qwen"]);
|
|
});
|
|
});
|
|
|
|
const model = (over: Partial<SearchableModel>): SearchableModel => ({
|
|
repoId: "unsloth/Qwen3-8B-GGUF",
|
|
author: "unsloth",
|
|
families: ["Qwen"],
|
|
baseModels: ["Qwen/Qwen3-8B"],
|
|
architecture: "qwen3",
|
|
quants: ["Q4_K_M"],
|
|
tags: ["roleplay"],
|
|
hubTags: ["gguf"],
|
|
pipelineTag: "text-generation",
|
|
license: "apache-2.0",
|
|
status: "ready",
|
|
...over,
|
|
});
|
|
|
|
describe("matchesQuery", () => {
|
|
it("matches author, family, quant and tags case-insensitively, all terms required", () => {
|
|
const m = model({});
|
|
assert.ok(matchesQuery(m, "qwen"));
|
|
assert.ok(matchesQuery(m, "unsloth qwen"));
|
|
assert.ok(matchesQuery(m, "q4_k_m"));
|
|
assert.ok(matchesQuery(m, "ROLEPLAY"));
|
|
assert.ok(matchesQuery(m, " "));
|
|
assert.ok(!matchesQuery(m, "unsloth gemma"));
|
|
});
|
|
});
|
|
|
|
describe("filters and facet counts", () => {
|
|
const models = [
|
|
model({}),
|
|
model({ repoId: "bartowski/Qwen_Qwen3-8B-GGUF", author: "bartowski", quants: ["Q6_K"], tags: [] }),
|
|
model({ repoId: "unsloth/gemma-3-27b-it-GGUF", families: ["google"], quants: ["Q4_K_M"], tags: ["security"] }),
|
|
];
|
|
|
|
it("ORs within a facet and ANDs across facets", () => {
|
|
const f = { ...EMPTY_FILTERS, author: ["unsloth"], quant: ["Q4_K_M", "Q6_K"] };
|
|
assert.deepEqual(
|
|
models.filter((m) => matchesFilters(m, f)).map((m) => m.repoId),
|
|
["unsloth/Qwen3-8B-GGUF", "unsloth/gemma-3-27b-it-GGUF"],
|
|
);
|
|
});
|
|
|
|
it("counts a facet without applying its own selection", () => {
|
|
const f = { ...EMPTY_FILTERS, author: ["unsloth"] };
|
|
assert.deepEqual(facetCounts(models, "author", "", f), [["unsloth", 2], ["bartowski", 1]]);
|
|
assert.deepEqual(facetCounts(models, "family", "", f), [["google", 1], ["Qwen", 1]]);
|
|
});
|
|
});
|
|
|
|
|
|
describe("fileRole", () => {
|
|
it("classifies typical GGUF repo files", () => {
|
|
const cases: [string, string][] = [
|
|
["Qwen3.8-27B-UD-Q4_K_M.gguf", "model"],
|
|
["Q4_K_M/Qwen3-235B-A22B-Q4_K_M-00001-of-00003.gguf", "model"],
|
|
["MTP/mtp-Qwen3.8-27B-Q4_0.gguf", "mtp"],
|
|
["mmproj-BF16.gguf", "vision"],
|
|
["mmproj-model-f16.gguf", "vision"],
|
|
["imatrix_unsloth.gguf", "imatrix"],
|
|
["imatrix_unsloth.dat", "imatrix"],
|
|
["Qwen_Qwen3-8B.imatrix", "imatrix"],
|
|
["config.json", "config"],
|
|
["generation_config.json", "config"],
|
|
["params", "config"],
|
|
["tokenizer.json", "tokenizer"],
|
|
["tokenizer_config.json", "tokenizer"],
|
|
["merges.txt", "tokenizer"],
|
|
["chat_template.jinja", "template"],
|
|
["template", "template"],
|
|
["README.md", "docs"],
|
|
["LICENSE", "docs"],
|
|
[".gitattributes", "git"],
|
|
["model-00001-of-00004.safetensors", "model"],
|
|
["adapter_model.safetensors", "adapter"],
|
|
["images/banner.png", "image"],
|
|
];
|
|
for (const [path, role] of cases) assert.equal(fileRole(path), role, path);
|
|
});
|
|
});
|
|
|
|
describe("groupSplitFiles", () => {
|
|
it("merges split parts into one entry and leaves other files alone", () => {
|
|
const files = [
|
|
{ path: ".gitattributes", size: 1 },
|
|
{ path: "BF16/Qwen3.8-27B-BF16-00002-of-00002.gguf", size: 20 },
|
|
{ path: "BF16/Qwen3.8-27B-BF16-00001-of-00002.gguf", size: 50 },
|
|
{ path: "Qwen3.8-27B-Q4_0.gguf", size: 16 },
|
|
];
|
|
const groups = groupSplitFiles(files);
|
|
assert.deepEqual(
|
|
groups.map((g) => [g.path, g.size, g.totalParts, g.parts.map((p) => p.path.slice(-18))]),
|
|
[
|
|
[".gitattributes", 1, 1, [".gitattributes"]],
|
|
["BF16/Qwen3.8-27B-BF16.gguf", 70, 2, ["00001-of-00002.gguf", "00002-of-00002.gguf"].map((s) => s.slice(-18))],
|
|
["Qwen3.8-27B-Q4_0.gguf", 16, 1, ["Qwen3.8-27B-Q4_0.gguf".slice(-18)]],
|
|
],
|
|
);
|
|
});
|
|
|
|
it("parses part numbers", () => {
|
|
assert.deepEqual(splitInfo("Q4_K_M/X-Q4_K_M-00003-of-00010.gguf"), { base: "Q4_K_M/X-Q4_K_M.gguf", part: 3, total: 10 });
|
|
assert.equal(splitInfo("model-00001-of-00004.safetensors")?.base, "model.safetensors");
|
|
assert.equal(splitInfo("Qwen3-8B-Q4_K_M.gguf"), null);
|
|
});
|
|
});
|