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
chat only with gguf for mac devices (#4300)
Manan Shahb2dce8e3a888
diff --git a/studio/backend/core/inference/defaults.py b/studio/backend/core/inference/defaults.pynew file mode 100644index 00000000000..c8e23deb092--- /dev/null+++ b/studio/backend/core/inference/defaults.py@@ -0,0 +1,30 @@+# SPDX-License-Identifier: AGPL-3.0-only+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++"""Default model lists for inference, split by platform."""++import sys++DEFAULT_MODELS_GGUF = [+ "unsloth/Llama-3.2-1B-Instruct-GGUF",+ "unsloth/Llama-3.2-3B-Instruct-GGUF",+ "unsloth/Llama-3.1-8B-Instruct-GGUF",+ "unsloth/gemma-3-1b-it-GGUF",+ "unsloth/gemma-3-4b-it-GGUF",+ "unsloth/Qwen3-4B-GGUF",+]++DEFAULT_MODELS_STANDARD = [+ "unsloth/Qwen3-4B-Instruct-2507",+ "unsloth/Meta-Llama-3.1-8B-Instruct-bnb-4bit",+ "unsloth/Mistral-Nemo-Instruct-2407-bnb-4bit",+ "unsloth/Phi-3.5-mini-instruct",+ "unsloth/Gemma-3-4B-it",+ "unsloth/Qwen2-VL-2B-Instruct-bnb-4bit",+]+++def get_default_models() -> list[str]:+ if sys.platform == "darwin":+ return list(DEFAULT_MODELS_GGUF)+ return list(DEFAULT_MODELS_STANDARD)diff --git a/studio/backend/core/inference/inference.py b/studio/backend/core/inference/inference.pyindex cb287bffa5f..4b162c57271 100644--- a/studio/backend/core/inference/inference.py+++ b/studio/backend/core/inference/inference.py@@ -36,14 +36,9 @@ class InferenceBackend:self.active_model_name = Noneself.loading_models = set()self.loaded_local_models = [] # [(display_name, path), ...]- self.default_models = [- "unsloth/Qwen3-4B-Instruct-2507",- "unsloth/Meta-Llama-3.1-8B-Instruct-bnb-4bit",- "unsloth/Mistral-Nemo-Instruct-2407-bnb-4bit",- "unsloth/Phi-3.5-mini-instruct",- "unsloth/Gemma-3-4B-it",- "unsloth/Qwen2-VL-2B-Instruct-bnb-4bit",- ]+ from core.inference.defaults import get_default_models++ self.default_models = get_default_models()self.device = get_device().valueself._audio_codec_manager = AudioCodecManager()diff --git a/studio/backend/core/inference/orchestrator.py b/studio/backend/core/inference/orchestrator.pyindex 99c43bbd887..3c87d64b126 100644--- a/studio/backend/core/inference/orchestrator.py+++ b/studio/backend/core/inference/orchestrator.py@@ -74,14 +74,9 @@ class InferenceOrchestrator:self.models: dict = {}self.loading_models: set = set()self.loaded_local_models: list = []- self._static_models = [- "unsloth/Qwen3-4B-Instruct-2507",- "unsloth/Llama-3.1-8B-Instruct-bnb-4bit",- "unsloth/Mistral-Nemo-Instruct-2407-bnb-4bit",- "unsloth/Phi-3.5-mini-instruct",- "unsloth/Gemma-3-4B-it",- "unsloth/Qwen2-VL-2B-Instruct-bnb-4bit",- ]+ from core.inference.defaults import get_default_models++ self._static_models = get_default_models()self._top_gguf_cache: Optional[list[str]] = Noneself._top_gguf_fetched = Falsediff --git a/studio/backend/main.py b/studio/backend/main.pyindex 3c2732eb5a3..be46272847b 100644--- a/studio/backend/main.py+++ b/studio/backend/main.py@@ -11,6 +11,7 @@ import osos.environ["PYTHONWARNINGS"] = "ignore"import shutil+import sysimport warningsfrom contextlib import asynccontextmanager@@ -144,10 +145,14 @@ app.include_router(export_router, prefix = "/api/export", tags = ["export"])@app.get("/api/health")async def health_check():"""Health check endpoint"""+ platform_map = {"darwin": "mac", "win32": "windows", "linux": "linux"}+ device_type = platform_map.get(sys.platform, sys.platform)+return {"status": "healthy","timestamp": datetime.now().isoformat(),"service": "Unsloth UI Backend",+ "device_type": device_type,}diff --git a/studio/backend/routes/models.py b/studio/backend/routes/models.pyindex 42587317128..586b18718eb 100644--- a/studio/backend/routes/models.py+++ b/studio/backend/routes/models.py@@ -314,6 +314,7 @@ async def list_models(model_info = ModelDetails(id = model_id,name = model_id.split("/")[-1] if "/" in model_id else model_id,+ is_gguf = model_id.upper().endswith("-GGUF"),)all_models.append(model_info)seen_ids.add(model_id)diff --git a/studio/frontend/src/app/routes/__root.tsx b/studio/frontend/src/app/routes/__root.tsxindex a58343d0c5b..0725d383c72 100644--- a/studio/frontend/src/app/routes/__root.tsx+++ b/studio/frontend/src/app/routes/__root.tsx@@ -2,16 +2,26 @@// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0import { Navbar } from "@/components/navbar";+import { usePlatformStore } from "@/config/env";import {Outlet,createRootRoute,+ redirect,useRouterState,} from "@tanstack/react-router";import { AnimatePresence, motion } from "motion/react";import { Suspense } from "react";import { AppProvider } from "../provider";+const CHAT_ONLY_ALLOWED = new Set(["/", "/chat", "/login", "/signup", "/change-password"]);+export const Route = createRootRoute({+ beforeLoad: ({ location }) => {+ const chatOnly = usePlatformStore.getState().isChatOnly();+ if (chatOnly && !CHAT_ONLY_ALLOWED.has(location.pathname)) {+ throw redirect({ to: "/chat" });+ }+ },component: RootLayout,});diff --git a/studio/frontend/src/components/assistant-ui/model-selector.tsx b/studio/frontend/src/components/assistant-ui/model-selector.tsxindex 28f94dbd197..2df72139d85 100644--- a/studio/frontend/src/components/assistant-ui/model-selector.tsx+++ b/studio/frontend/src/components/assistant-ui/model-selector.tsx@@ -9,6 +9,7 @@ import {PopoverTrigger,} from "@/components/ui/popover";import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";+import { usePlatformStore } from "@/config/env";import { cn } from "@/lib/utils";import {ArrowDown01Icon,@@ -111,6 +112,7 @@ function ModelSelectorContent({dataTour?: string;}) {const hasSelection = Boolean(value);+ const chatOnly = usePlatformStore((s) => s.isChatOnly());return (<PopoverContent@@ -121,24 +123,28 @@ function ModelSelectorContent({className,)}>- <Tabs defaultValue="hub" className="w-full">- <TabsList className="mb-2 w-full">- <TabsTrigger value="hub">Hub models</TabsTrigger>- <TabsTrigger value="lora">Fine-tuned</TabsTrigger>- </TabsList>+ {chatOnly ? (+ <HubModelPicker models={models} value={value} onSelect={onSelect} />+ ) : (+ <Tabs defaultValue="hub" className="w-full">+ <TabsList className="mb-2 w-full">+ <TabsTrigger value="hub">Hub models</TabsTrigger>+ <TabsTrigger value="lora">Fine-tuned</TabsTrigger>+ </TabsList>- <TabsContent value="hub" className="m-0">- <HubModelPicker models={models} value={value} onSelect={onSelect} />- </TabsContent>+ <TabsContent value="hub" className="m-0">+ <HubModelPicker models={models} value={value} onSelect={onSelect} />+ </TabsContent>- <TabsContent value="lora" className="m-0">- <LoraModelPicker- loraModels={loraModels}- value={value}- onSelect={onSelect}- />- </TabsContent>- </Tabs>+ <TabsContent value="lora" className="m-0">+ <LoraModelPicker+ loraModels={loraModels}+ value={value}+ onSelect={onSelect}+ />+ </TabsContent>+ </Tabs>+ )}{hasSelection && onEject ? (<div className="mt-2 border-t border-border/70 pt-2">diff --git a/studio/frontend/src/components/assistant-ui/model-selector/pickers.tsx b/studio/frontend/src/components/assistant-ui/model-selector/pickers.tsxindex 76a32b61298..fe4226c4af3 100644--- a/studio/frontend/src/components/assistant-ui/model-selector/pickers.tsx+++ b/studio/frontend/src/components/assistant-ui/model-selector/pickers.tsx@@ -11,6 +11,7 @@ import {import { listCachedGguf, listGgufVariants } from "@/features/chat/api/chat-api";import type { CachedGgufRepo } from "@/features/chat/api/chat-api";import type { GgufVariantDetail } from "@/features/chat/types/api";+import { usePlatformStore } from "@/config/env";import {useDebouncedValue,useGpuInfo,@@ -377,12 +378,15 @@ export function HubModelPicker({const showHfSection = debouncedQuery.trim().length > 0;const recommendedSet = useMemo(() => new Set(recommendedIds), [recommendedIds]);+ const chatOnly = usePlatformStore((s) => s.isChatOnly());+const hfIds = useMemo(() => {if (!showHfSection) return [];return results.map((result) => result.id)- .filter((id) => !recommendedSet.has(id));- }, [recommendedSet, results, showHfSection]);+ .filter((id) => !recommendedSet.has(id))+ .filter((id) => !chatOnly || isGgufRepo(id));+ }, [recommendedSet, results, showHfSection, chatOnly]);const metricsById = useMemo(() =>diff --git a/studio/frontend/src/components/navbar.tsx b/studio/frontend/src/components/navbar.tsxindex 2fd2e120885..e778b013f28 100644--- a/studio/frontend/src/components/navbar.tsx+++ b/studio/frontend/src/components/navbar.tsx@@ -26,6 +26,7 @@ import {} from "@hugeicons/core-free-icons";import { HugeiconsIcon } from "@hugeicons/react";import { useTrainingRuntimeStore } from "@/features/training";+import { usePlatformStore } from "@/config/env";import { Link, useRouterState } from "@tanstack/react-router";import { motion } from "motion/react";import { useState } from "react";@@ -50,6 +51,8 @@ export function Navbar() {const isTrainingRunning = useTrainingRuntimeStore((s) => s.isTrainingRunning);const [mobileOpen, setMobileOpen] = useState(false);+ const chatOnly = usePlatformStore((s) => s.isChatOnly());+const tourId = getTourId(pathname);const openTour = () => {@@ -63,10 +66,7 @@ export function Navbar() {<header className="relative top-0 z-40 h-16 w-full"><div className="mx-auto grid h-full max-w-7xl grid-cols-[1fr_auto_1fr] items-center px-4 sm:px-6">{/* Left: logo */}- <Link- to="/studio"- className="flex items-center justify-self-start gap-2 select-none"- >+ <Link to={chatOnly ? "/chat" : "/studio"} className="flex items-center justify-self-start select-none"><imgsrc="/blacklogo.png"alt="Unsloth"@@ -92,7 +92,9 @@ export function Navbar() {pathname === item.href || pathname.startsWith(`${item.href}/`);const disabledByTraining =isTrainingRunning && item.href !== "/studio";- if (!item.enabled || disabledByTraining) {+ const disabledByDevice =+ chatOnly && item.href !== "/chat";+ if (!item.enabled || disabledByTraining || disabledByDevice) {return (<spankey={item.href}@@ -237,7 +239,9 @@ export function Navbar() {const active = pathname === item.href;const disabledByTraining =isTrainingRunning && item.href !== "/studio";- if (disabledByTraining) {+ const disabledByDevice =+ chatOnly && item.href !== "/chat";+ if (disabledByTraining || disabledByDevice) {return (<spankey={item.href}diff --git a/studio/frontend/src/config/env.ts b/studio/frontend/src/config/env.tsindex 6dc1c795560..e5b42012a4d 100644--- a/studio/frontend/src/config/env.ts+++ b/studio/frontend/src/config/env.ts@@ -1,9 +1,46 @@// SPDX-License-Identifier: AGPL-3.0-only// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0+import { create } from "zustand";+export const env = {MODE: import.meta.env.MODE,DEV: import.meta.env.DEV,PROD: import.meta.env.PROD,BASE_URL: import.meta.env.BASE_URL,} as const;++// ── Platform / device type ──────────────────────────────────++export type DeviceType = "mac" | "windows" | "linux" | string;++interface PlatformState {+ deviceType: DeviceType;+ fetched: boolean;+ isChatOnly: () => boolean;+}++export const usePlatformStore = create<PlatformState>()((_, get) => ({+ deviceType: "linux",+ fetched: false,+ isChatOnly: () => get().deviceType === "mac",+}));++export async function fetchDeviceType(): Promise<DeviceType> {+ const { fetched } = usePlatformStore.getState();+ if (fetched) return usePlatformStore.getState().deviceType;++ try {+ const res = await fetch("/api/health");+ if (res.ok) {+ const data = (await res.json()) as { device_type?: string };+ const deviceType = data.device_type ?? "linux";+ usePlatformStore.setState({ deviceType, fetched: true });+ return deviceType;+ }+ } catch (err) {+ console.warn("[platform] Failed to fetch device type, will retry", err);+ }++ return usePlatformStore.getState().deviceType;+}diff --git a/studio/frontend/src/features/auth/components/auth-form.tsx b/studio/frontend/src/features/auth/components/auth-form.tsxindex d51fc2814ca..4433f29bd57 100644--- a/studio/frontend/src/features/auth/components/auth-form.tsx+++ b/studio/frontend/src/features/auth/components/auth-form.tsx@@ -89,20 +89,9 @@ export function AuthForm({ mode }: AuthFormProps): ReactElement | null {let canceled = false;async function initializeAuthForm(): Promise<void> {- if (hasRefreshToken()) {- const refreshed = await refreshSession();- if (refreshed) {- if (!canceled) setStatusLoading(false);- navigate({ to: getPostAuthRoute() });- return;- }- }- if (hasAuthToken()) {- if (!canceled) setStatusLoading(false);- navigate({ to: getPostAuthRoute() });- return;- }-+ // Always check the server first — localStorage flags can be stale+ // (e.g. tokens from a previous install attempt). The server's+ // /api/auth/status is the source of truth for requires_password_change.try {const response = await fetch("/api/auth/status");if (!response.ok) throw new Error("Failed to load auth status.");@@ -111,6 +100,8 @@ export function AuthForm({ mode }: AuthFormProps): ReactElement | null {setInitialized(result.initialized);setUsername(result.default_username);setRequiresPasswordChange(result.requires_password_change);++ // Redirect between login ↔ change-password based on server stateif (mode === "login" && result.requires_password_change) {navigate({ to: "/change-password" });return;@@ -119,6 +110,24 @@ export function AuthForm({ mode }: AuthFormProps): ReactElement | null {navigate({ to: "/login" });return;}++ // On login page, if user already has a valid session and no+ // password change is required, skip straight to the app.+ if (isLoginMode && !result.requires_password_change) {+ if (hasRefreshToken()) {+ const refreshed = await refreshSession();+ if (refreshed) {+ if (!canceled) setStatusLoading(false);+ navigate({ to: getPostAuthRoute() });+ return;+ }+ }+ if (hasAuthToken()) {+ if (!canceled) setStatusLoading(false);+ navigate({ to: getPostAuthRoute() });+ return;+ }+ }}} catch (err: unknown) {if (!canceled) {diff --git a/studio/frontend/src/features/auth/session.ts b/studio/frontend/src/features/auth/session.tsindex 5ee2a6b13ba..3d3502e073f 100644--- a/studio/frontend/src/features/auth/session.ts+++ b/studio/frontend/src/features/auth/session.ts@@ -1,12 +1,14 @@// SPDX-License-Identifier: AGPL-3.0-only// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0+import { usePlatformStore } from "@/config/env";+export const AUTH_TOKEN_KEY = "unsloth_auth_token";export const AUTH_REFRESH_TOKEN_KEY = "unsloth_auth_refresh_token";export const ONBOARDING_DONE_KEY = "unsloth_onboarding_done";export const AUTH_MUST_CHANGE_PASSWORD_KEY = "unsloth_auth_must_change_password";-type PostAuthRoute = "/onboarding" | "/studio" | "/change-password";+type PostAuthRoute = "/onboarding" | "/studio" | "/change-password" | "/chat";function canUseStorage(): boolean {return typeof window !== "undefined";@@ -77,5 +79,6 @@ export function resetOnboardingDone(): void {export function getPostAuthRoute(): PostAuthRoute {if (mustChangePassword()) return "/change-password";+ if (usePlatformStore.getState().isChatOnly()) return "/chat";return isOnboardingDone() ? "/studio" : "/onboarding";}diff --git a/studio/frontend/src/main.tsx b/studio/frontend/src/main.tsxindex 77186e09a24..0db37fdb6ec 100644--- a/studio/frontend/src/main.tsx+++ b/studio/frontend/src/main.tsx@@ -5,6 +5,7 @@ import { StrictMode } from "react";import { createRoot } from "react-dom/client";import "./index.css";+import { fetchDeviceType } from "./config/env";import { App } from "./app/app";const globalCrypto = globalThis.crypto as Crypto | undefined;@@ -32,8 +33,10 @@ if (!rootElement) {throw new Error("Root element not found");}-createRoot(rootElement).render(- <StrictMode>- <App />- </StrictMode>,-);+fetchDeviceType().then(() => {+ createRoot(rootElement).render(+ <StrictMode>+ <App />+ </StrictMode>,+ );+});