mirror of
https://github.com/block/buzz.git
synced 2026-08-18 06:50:31 +02:00
Signed-off-by: Tyler Longwell <tlongwell@block.xyz> Co-authored-by: npub1qyvc0c5kl4gqv2fd97fsk46tu378sqgy35vc83rvgfwne90sel7s0ed67d <011987e296fd5006292d2f930b574be47c7801048d1983c46c425d3c95f0cffd@sprout-oss.stage.blox.sqprod.co> Co-authored-by: Max <d8473ee32b973aa31a21a65adddcc4b69cc2a8a4dee8121ecd51926e0cddbc02@sprout-oss.stage.blox.sqprod.co> Co-authored-by: Mari <95cae996907d7cab9f5dbf43c0f53edeac6ab0b032a6feae4abfd784e467b3f5@sprout-oss.stage.blox.sqprod.co> Co-authored-by: Quinn <96f056ad5f2305c8ddf637dc65d048aa4c12d7daeb8867690e34fca46b0ef64c@sprout-oss.stage.blox.sqprod.co> Co-authored-by: Sami <f4a42a97e594b77bdbd8ee35191c8b28a94a4cb871d96f32921558275421fb68@sprout-oss.stage.blox.sqprod.co> Co-authored-by: Perci <5a968df9a7494b4e019b9ecf739e088ba61097b4312124e9a88ae5b42e3f5f3e@sprout-oss.stage.blox.sqprod.co> Co-authored-by: Tyler Longwell <tlongwell@block.xyz>
76 lines
2.0 KiB
JavaScript
76 lines
2.0 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
|
|
import { classifyModelRef, modelRefHintLabel } from "./classifyModelRef.ts";
|
|
|
|
test("empty string → unknown", () => {
|
|
assert.deepEqual(classifyModelRef(""), { kind: "unknown" });
|
|
assert.deepEqual(classifyModelRef(" "), { kind: "unknown" });
|
|
});
|
|
|
|
test("hf:// prefix → huggingface", () => {
|
|
assert.deepEqual(classifyModelRef("hf://meshllm/qwen3-8b@main"), {
|
|
kind: "huggingface",
|
|
ref: "hf://meshllm/qwen3-8b@main",
|
|
});
|
|
});
|
|
|
|
test("absolute path → local-path", () => {
|
|
assert.deepEqual(classifyModelRef("/Users/me/models/qwen.gguf"), {
|
|
kind: "local-path",
|
|
path: "/Users/me/models/qwen.gguf",
|
|
});
|
|
});
|
|
|
|
test("relative path with ./ → local-path", () => {
|
|
assert.deepEqual(classifyModelRef("./models/qwen.gguf"), {
|
|
kind: "local-path",
|
|
path: "./models/qwen.gguf",
|
|
});
|
|
});
|
|
|
|
test("home shortcut → local-path", () => {
|
|
assert.deepEqual(classifyModelRef("~/models/qwen.gguf"), {
|
|
kind: "local-path",
|
|
path: "~/models/qwen.gguf",
|
|
});
|
|
});
|
|
|
|
test(".gguf extension without path prefix → local-path", () => {
|
|
// Bare filename ending in .gguf — user clearly means a file.
|
|
assert.deepEqual(classifyModelRef("my-model.gguf"), {
|
|
kind: "local-path",
|
|
path: "my-model.gguf",
|
|
});
|
|
});
|
|
|
|
test("plain name → catalog", () => {
|
|
assert.deepEqual(classifyModelRef("Qwen3-8B-Q4_K_M"), {
|
|
kind: "catalog",
|
|
name: "Qwen3-8B-Q4_K_M",
|
|
});
|
|
});
|
|
|
|
test("trims whitespace before classifying", () => {
|
|
assert.deepEqual(classifyModelRef(" Qwen3-8B-Q4_K_M "), {
|
|
kind: "catalog",
|
|
name: "Qwen3-8B-Q4_K_M",
|
|
});
|
|
});
|
|
|
|
test("hint labels are user-facing strings", () => {
|
|
assert.equal(
|
|
modelRefHintLabel({ kind: "catalog", name: "x" }),
|
|
"Looks like a catalog name",
|
|
);
|
|
assert.equal(
|
|
modelRefHintLabel({ kind: "huggingface", ref: "hf://x" }),
|
|
"HuggingFace ref",
|
|
);
|
|
assert.equal(
|
|
modelRefHintLabel({ kind: "local-path", path: "/x" }),
|
|
"Local file",
|
|
);
|
|
assert.equal(modelRefHintLabel({ kind: "unknown" }), null);
|
|
});
|