Local models: the folder's README.md is the model card

The worker reads README.md when it scans the models folder (the web
app can't see it) and stores it on the folder and, after import, on
the model; every scan refreshes it for local models. Relative images
and links are dropped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Pascal LinxweilerandClaude Opus 5.5 committed 2026-11-08 00:27:17 +01:00
1 parent 5a8893e7db
commit d27e79bba0
10 files changed
+1660 -17

No files matched your search

+16 -1
View File
@@ -69,9 +69,24 @@ describe("models folder scan", () => {
it("compares the file list, not only the counts", () => {
const at = new Date();
const found = { path: "o/m", files: [{ path: "b.gguf", size: 2 }], fileCount: 1, totalBytes: 2, commit: null, scannedAt: at };
const same = { path: "o/m", filesJson: JSON.stringify(found.files), fileCount: 1, totalBytes: 2, commit: null };
const same = { path: "o/m", filesJson: JSON.stringify(found.files), fileCount: 1, totalBytes: 2, commit: null, readme: null };
assert.deepEqual(scan.folderChanges([same], [found]), { insert: [], update: [], remove: [] });
const renamed = { ...same, filesJson: JSON.stringify([{ path: "a.gguf", size: 2 }]) };
assert.deepEqual(scan.folderChanges([renamed], [found]).update, [found]);
});
it("writes a folder again when its README changed", () => {
const at = new Date();
const found = { path: "o/m", files: [{ path: "README.md", size: 3 }], fileCount: 1, totalBytes: 3, commit: null, readme: "new", scannedAt: at };
const stored = { path: "o/m", filesJson: JSON.stringify(found.files), fileCount: 1, totalBytes: 3, commit: null, readme: "old" };
assert.deepEqual(scan.folderChanges([stored], [found]).update, [found]);
});
it("reads README.md in any case, and only at the top level", async () => {
const folder = join(dir, "readme-test"); // outside MODELS_DIR: no other test scans it
put(join(folder, "sub", "README.md"), 1);
assert.equal(await scan.readReadme(folder), null);
writeFileSync(join(folder, "ReadMe.md"), "# Hello\n");
assert.equal(await scan.readReadme(folder), "# Hello\n");
});
});