Recommended files with a quant; floating selection bar

Picking model weights in Add model or Download more also selects the
files that usually go with them (chat template, MTP head, mmproj, ...),
shown in a strip where each can be unchecked. Variants are matched by
quant, otherwise the best single one; kinds already selected aren't
added twice. Which kinds is set in Settings -> Downloads.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Pascal LinxweilerandClaude Opus 5.5 committed 2026-10-05 23:10:53 +02:00
1 parent 145818f149
commit 0247f257fb
16 files changed
+514 -27

No files matched your search

+56
View File
@@ -0,0 +1,56 @@
import assert from "node:assert/strict";
import { describe, it } from "node:test";
import { DEFAULT_RECOMMENDED_ROLES, quantTag, recommendFiles } from "./recommend";
const f = (path: string, size = 1) => ({ path, size });
// Trimmed from unsloth/Qwen3.8-27B-GGUF and unsloth/Qwen3-8B-GGUF.
const qwen38 = [
f(".gitattributes"),
f("MTP/mtp-Qwen3.8-27B-Q4_0.gguf", 1_369_590_656),
f("Qwen3.8-27B-Q4_0.gguf"),
f("Qwen3.8-27B-UD-Q4_K_XL.gguf"),
f("README.md"),
f("config.json"),
f("imatrix_unsloth.gguf"),
f("mmproj-BF16.gguf", 931_146_432),
f("mmproj-F16.gguf", 927_607_488),
];
const qwen3 = [f("Qwen3-8B-Q4_K_M.gguf"), f("Qwen3-8B-Q8_0.gguf"), f("params"), f("template"), f("config.json"), f("imatrix_unsloth.dat")];
describe("quantTag", () => {
it("reads quant and precision tags", () => {
assert.equal(quantTag("MTP/mtp-Qwen3.8-27B-Q4_0.gguf"), "q4_0");
assert.equal(quantTag("mmproj-F16.gguf"), "f16");
assert.equal(quantTag("Qwen3.8-27B-UD-Q4_K_XL.gguf"), "ud-q4_k_xl");
});
});
describe("recommendFiles", () => {
it("adds the only MTP head and prefers the F16 mmproj", () => {
const rec = recommendFiles(qwen38, ["Qwen3.8-27B-UD-Q4_K_XL.gguf"], DEFAULT_RECOMMENDED_ROLES);
assert.deepEqual(rec.sort(), ["MTP/mtp-Qwen3.8-27B-Q4_0.gguf", "mmproj-F16.gguf"]);
});
it("matches the variant with the same quant", () => {
const files = [...qwen38, f("MTP/mtp-Qwen3.8-27B-Q8_0.gguf"), f("Qwen3.8-27B-Q8_0.gguf")];
assert.deepEqual(recommendFiles(files, ["Qwen3.8-27B-Q8_0.gguf"], ["mtp"]), ["MTP/mtp-Qwen3.8-27B-Q8_0.gguf"]);
assert.deepEqual(recommendFiles(files, ["Qwen3.8-27B-Q4_0.gguf"], ["mtp"]), ["MTP/mtp-Qwen3.8-27B-Q4_0.gguf"]);
});
it("adds the chat template, and config only when enabled", () => {
assert.deepEqual(recommendFiles(qwen3, ["Qwen3-8B-Q4_K_M.gguf"], DEFAULT_RECOMMENDED_ROLES), ["template"]);
assert.deepEqual(recommendFiles(qwen3, ["Qwen3-8B-Q4_K_M.gguf"], ["config"]).sort(), ["config.json", "params"]);
});
it("doesn't add a second variant when one is already selected", () => {
assert.deepEqual(recommendFiles(qwen38, ["Qwen3.8-27B-Q4_0.gguf"], ["vision"], ["mmproj-BF16.gguf"]), []);
assert.deepEqual(recommendFiles(qwen38, ["Qwen3.8-27B-Q4_0.gguf", "mmproj-BF16.gguf"], ["vision", "mtp"]), [
"MTP/mtp-Qwen3.8-27B-Q4_0.gguf",
]);
});
it("recommends nothing without picked model files", () => {
assert.deepEqual(recommendFiles(qwen38, [], DEFAULT_RECOMMENDED_ROLES), []);
});
});