Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved.
import assert from "node:assert/strict";
import test from "node:test";
import { readSrc } from "./helpers/kit.ts";
import {
DEFAULT_ENGINE_LAUNCH_FIELDS,
engineLaunchFieldsFromParams,
} from "../src/features/chat/lib/engine-launch-fields.ts";
const composer = readSrc("features/chat/shared-composer.tsx");
const start = composer.indexOf("const paneEngine = ");
const end = composer.indexOf("let loadTrustRemoteCode", start);
assert.ok(start >= 0 && end > start);
const paneFieldsBody = new Function(
"targetIsGguf",
"ownConfig",
"reconcilePersistedGpuIds",
"engineLaunchFieldsFromParams",
`${composer.slice(start, end)} return paneEngineFields;`,
);
const paneFields = (
targetIsGguf: boolean,
ownConfig: Record<string, unknown>,
reconcile: (ids: number[] | null) => number[] | null,
): Record<string, unknown> =>
paneFieldsBody(
targetIsGguf,
ownConfig,
reconcile,
engineLaunchFieldsFromParams,
);
const reconcile = (ids: number[] | null) => ids;
test("a compare pane loads its remembered vLLM or SGLang settings", () => {
const fields = paneFields(
false,
{
engine: "sglang",
enginePrecision: "int4",
engineParallelism: "pipeline",
selectedGpuIds: [1, 2],
},
reconcile,
);
assert.deepEqual(fields, {
engine: "sglang",
engine_precision: "int4",
engine_parallelism: "pipeline",
...DEFAULT_ENGINE_LAUNCH_FIELDS,
load_in_4bit: false,
gpu_ids: [1, 2],
});
const tuned = paneFields(
false,
{
engine: "vllm",
engineKvCacheDtype: "fp8",
engineSeed: 0,
engineGpuMemoryUtilization: 0.5,
},
reconcile,
);
assert.equal(tuned.engine_kv_cache_dtype, "fp8");
assert.equal(tuned.engine_seed, 0);
assert.equal(tuned.engine_gpu_memory_utilization, 0.5);
assert.equal(composer.match(/\.\.\.paneEngineFields,/g)?.length, 1);
assert.match(composer, /loadModel\(\{\s*\.\.\.panePayload\(\),/);
});
test("a default or GGUF compare pane keeps the default backend and no GPU pick", () => {
for (const [isGguf, config] of [
[false, { selectedGpuIds: [1] }],
[true, { engine: "vllm", selectedGpuIds: [1] }],
] as const) {
const fields = paneFields(isGguf, config, reconcile);
assert.equal(fields.engine, "auto");
assert.equal(fields.load_in_4bit, true);
assert.equal("gpu_ids" in fields, false);
}
});