import assert from "node:assert/strict"; import { describe, it } from "node:test"; import { buildCommand, renderCommand } from "./deploy-command"; const model = { repoId: "unsloth/Qwen3-0.6B-GGUF", localPath: "unsloth/Qwen3-0.6B-GGUF" }; describe("buildCommand", () => { it("builds llama-server arguments with mmproj and MTP draft", () => { const cmd = buildCommand({ engine: "llama.cpp", model, runtime: { env: {}, extraArgs: ["--jinja"] }, options: { modelFile: "Qwen3-0.6B-Q4_K_M.gguf", mmproj: "mmproj-F16.gguf", draftFile: "MTP/mtp-Q4_0.gguf", draftType: "draft-mtp", contextSize: 4096, threads: 8, parallel: 1, cacheTypeK: "q8_0", extraArgs: ["--temp", "0.7"], }, }); assert.equal(cmd.port, 8080); assert.deepEqual(cmd.args.slice(0, 2), ["-m", "/models/unsloth/Qwen3-0.6B-GGUF/Qwen3-0.6B-Q4_K_M.gguf"]); const s = cmd.args.join(" "); assert.match(s, /-c 4096 -t 8 -tb 8 -np 1 -ctk q8_0/); assert.match(s, /--mmproj \/models\/unsloth\/Qwen3-0\.6B-GGUF\/mmproj-F16\.gguf/); assert.match(s, /-md \/models\/unsloth\/Qwen3-0\.6B-GGUF\/MTP\/mtp-Q4_0\.gguf --spec-type draft-mtp/); assert.ok(s.endsWith("--metrics --jinja --temp 0.7")); assert.ok(!s.includes("-b "), "unset options are left out"); }); it("builds vllm serve arguments; deployment dtype and KV cache override the runtime", () => { const cmd = buildCommand({ engine: "vllm", model: { repoId: "HuggingFaceTB/SmolLM2-135M-Instruct", localPath: "HuggingFaceTB/SmolLM2-135M-Instruct" }, runtime: { env: { VLLM_CPU_KVCACHE_SPACE: "4" }, extraArgs: ["--dtype=bfloat16"] }, options: { modelFile: "", contextSize: 2048, maxNumSeqs: 4, dtype: "float32", kvCacheGb: 2, extraArgs: [] }, }); assert.equal(cmd.port, 8000); assert.equal(cmd.args[0], "/models/HuggingFaceTB/SmolLM2-135M-Instruct"); assert.equal(cmd.env.VLLM_CPU_KVCACHE_SPACE, "2"); const s = cmd.args.join(" "); assert.ok(s.indexOf("--dtype=bfloat16") < s.indexOf("--dtype float32")); assert.match(renderCommand("vllm/vllm-openai-cpu:v0.31.0", cmd), /^docker run -e VLLM_CPU_KVCACHE_SPACE=2 /); }); });