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. See /studio/LICENSE.AGPL-3.0
// For custom-code models the fallback is the only 4-bit path, so it is offered next to Install.
import assert from "node:assert/strict";
import test from "node:test";
import {
upgradeDialogActions,
upgradeInstallVersion,
} from "../src/features/transformers-upgrade/lib/upgrade-dialog-actions.ts";
import type { TransformersUpgradeInfo } from "../src/features/transformers-upgrade/types.ts";
const INSTALLABLE: TransformersUpgradeInfo = {
// biome-ignore lint/style/useNamingConvention: API schema
model_type: "muse_glimmer",
// biome-ignore lint/style/useNamingConvention: API schema
pypi_version: "5.15.0",
// biome-ignore lint/style/useNamingConvention: API schema
supported_in_pypi: true,
// biome-ignore lint/style/useNamingConvention: API schema
supported_in_main: true,
};
const DEV_ONLY: TransformersUpgradeInfo = {
...INSTALLABLE,
// biome-ignore lint/style/useNamingConvention: API schema
supported_in_pypi: false,
};
test("an installable release offers the custom-code way out alongside Install", () => {
const actions = upgradeDialogActions({
upgrade: INSTALLABLE,
phase: "consent",
trustRemoteCodeFallback: true,
});
assert.equal(actions.installable, true);
assert.equal(actions.devOnly, false);
assert.equal(
actions.customCode,
true,
"installing forces 16-bit, so hiding this leaves a 4-bit run no way to start",
);
});
test("a model without its own code still offers Install alone", () => {
const actions = upgradeDialogActions({
upgrade: INSTALLABLE,
phase: "consent",
trustRemoteCodeFallback: false,
});
assert.equal(actions.installable, true);
assert.equal(actions.customCode, false);
});
test("a failed install keeps the fallback offered", () => {
const actions = upgradeDialogActions({
upgrade: INSTALLABLE,
phase: "error",
trustRemoteCodeFallback: true,
});
assert.equal(actions.customCode, true);
});
test("a running install offers nothing that would abandon it", () => {
const actions = upgradeDialogActions({
upgrade: INSTALLABLE,
phase: "installing",
trustRemoteCodeFallback: true,
});
assert.equal(actions.customCode, false);
});
test("a main-only upgrade without a known main version has nothing to install", () => {
const actions = upgradeDialogActions({
upgrade: DEV_ONLY,
phase: "consent",
trustRemoteCodeFallback: true,
});
assert.equal(actions.installable, false);
assert.equal(actions.devOnly, true);
assert.equal(actions.customCode, true);
});
test("an upgrade no transformers ships at all offers only Cancel", () => {
const actions = upgradeDialogActions({
upgrade: {
...DEV_ONLY,
// biome-ignore lint/style/useNamingConvention: API schema
supported_in_main: false,
},
phase: "consent",
trustRemoteCodeFallback: false,
});
assert.deepEqual(actions, {
installable: false,
fromMain: false,
devOnly: false,
customCode: false,
});
});
test("a main-only architecture installs transformers main after consent", () => {
const upgrade: TransformersUpgradeInfo = {
...DEV_ONLY,
// biome-ignore lint/style/useNamingConvention: API schema
main_version: "5.19.0.dev0",
};
const actions = upgradeDialogActions({
upgrade,
phase: "consent",
trustRemoteCodeFallback: false,
});
assert.equal(actions.installable, true);
assert.equal(actions.fromMain, true);
assert.equal(actions.devOnly, false);
assert.equal(upgradeInstallVersion(upgrade), "5.19.0.dev0");
});
test("a released version wins over main", () => {
const upgrade: TransformersUpgradeInfo = {
...INSTALLABLE,
// biome-ignore lint/style/useNamingConvention: API schema
main_version: "5.19.0.dev0",
};
const actions = upgradeDialogActions({
upgrade,
phase: "consent",
trustRemoteCodeFallback: false,
});
assert.equal(actions.fromMain, false);
assert.equal(upgradeInstallVersion(upgrade), "5.15.0");
});