Skip to content

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.

3.6 KB
Raw Blame
// 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 {
  Edit03Icon,
  MagicWand01Icon,
  ZoomInAreaIcon,
} from "@hugeicons/core-free-icons";
import type { IconSvgElement } from "@hugeicons/react";
// Relative with .ts: the node tests import this file and cannot resolve @/.
import { ExpandArrowsIcon } from "../../lib/expand-icons.ts";
import { AiImageIcon } from "../../lib/hugeicons-derived.ts";
import { ImagesIcon } from "../../lib/hugeicons-derived.ts";
import { PaintbrushIcon } from "../../lib/paintbrush-icon.ts";

export type WorkflowId =
  | "create"
  | "transform"
  | "inpaint"
  | "extend"
  | "upscale"
  | "reference"
  | "edit";

/** `requires` is the backend workflow id the loaded model must support; null = always. */
export const WORKFLOW_TABS: Array<{
  id: WorkflowId;
  label: string;
  heading?: string;
  requires: string | null;
  icon: IconSvgElement;
  hint: string;
}> = [
  {
    id: "create",
    label: "Create",
    heading: "Create images",
    requires: null,
    // Not the pencil: that is the sidebar's New chat icon.
    icon: AiImageIcon,
    hint: "Generate a new image from a prompt",
  },
  {
    id: "edit",
    label: "Edit",
    icon: Edit03Icon,
    requires: "edit",
    hint: "Change an image with an instruction",
  },
  {
    id: "transform",
    label: "Transform",
    icon: MagicWand01Icon,
    requires: "img2img",
    hint: "Redraw an image from your prompt",
  },
  {
    id: "inpaint",
    label: "Inpaint",
    icon: PaintbrushIcon,
    requires: "inpaint",
    hint: "Regenerate a painted region",
  },
  {
    id: "extend",
    label: "Extend",
    icon: ExpandArrowsIcon,
    requires: "outpaint",
    hint: "Grow the canvas and fill the edges",
  },
  {
    id: "upscale",
    label: "Upscale",
    icon: ZoomInAreaIcon,
    requires: "upscale",
    hint: "Enlarge and re-detail an image",
  },
  {
    id: "reference",
    label: "Reference",
    icon: ImagesIcon,
    requires: "reference",
    hint: "Generate guided by a reference image",
  },
];

/** Create and Edit only: the others need a strength or mask, which servers' /images/edits do not take uniformly. */
export const CONNECTION_WORKFLOWS: readonly WorkflowId[] = ["create", "edit"];

export const BACKEND_WORKFLOW_RECIPE_LABELS: Record<string, string> = {
  txt2img: "Create",
  img2img: "Transform",
  edit: "Edit",
  inpaint: "Inpaint",
  outpaint: "Extend",
  upscale: "Upscale",
  reference: "Reference",
  controlnet: "ControlNet",
};

export function recipeWorkflowLabel(workflow: string | null | undefined): string {
  if (!workflow || workflow === "txt2img") return "Create";
  return BACKEND_WORKFLOW_RECIPE_LABELS[workflow] ?? workflow;
}

export const WORKFLOW_EXAMPLE_PROMPTS: Record<WorkflowId, string> = {
  create:
    "A cozy wooden cabin on a snowy mountain at dusk, warm light glowing from the windows, pine trees and gently falling snow. Cinematic photo, soft golden light.",
  edit: "Make the sky a bright sunset orange and add a red kite flying above the trees.",
  transform:
    "Turn this into a watercolor painting with soft pastel colors and loose, visible brush strokes.",
  inpaint:
    "A fluffy orange cat curled up asleep in the painted area, soft window light, realistic fur.",
  extend:
    "Continue the scene outward with more sandy beach, gentle waves and palm trees under a clear blue sky.",
  upscale: "Sharp, highly detailed photo with crisp textures, clean edges and natural colors.",
  reference:
    "The character from the reference exploring a neon lit city street at night, cinematic lighting.",
};