The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.
TypeScript ai-videocomfyuicreative-toolsgenerative-aiideogramimage-generationimage-to-3dimage-to-videoltx-videominimax-h3nextjsopen-sourceopen-weightsqwen-imagetext-to-imagevideo-generationwan
Image to 3D: the open text-to-3D chain starts when the request leaves op out
Claude627b965496ea
diff --git a/src/lib/catalog/canvas.ts b/src/lib/catalog/canvas.tsindex a4f7c956..1235e9a8 100644--- a/src/lib/catalog/canvas.ts+++ b/src/lib/catalog/canvas.ts@@ -9,7 +9,7 @@*/import { getModel, getPreset, MODELS, supportsOp } from "./index";import { chainedWaitMessage, keyframeChain } from "./keyframes";-import { estimateCost, inferOperation, planGeneration, type Plan } from "./plan";+import { estimateCost, inferOperation, planGeneration, routesFor, type Plan } from "./plan";import {OPERATION_LABELS,OPERATION_OUTPUT,@@ -867,8 +867,10 @@ export function describeNode(graph: CanvasGraph, n: CanvasNode, ctx: DescribeConif ("error" in built) return { model, costUsd: null, error: built.error };try {const plan = planGeneration(withPlaceholders(built.request), getModel, getPreset);- // A film built clip by clip is planned from its inputs when it starts: it can't wait for another node (said before Run).- if (built.deps.length && plan.op === "keyframes" && keyframeChain(plan.model)) return { ...built, model, costUsd: null, error: chainedWaitMessage(plan.model.name) };+ // A film built clip by clip, or the open text-to-3D still and model, is planned from its inputs when it starts:+ // it can't wait for another node (said before Run).+ const chained = plan.op === "keyframes" ? !!keyframeChain(plan.model) : routesFor(plan.model, plan.op).some((r) => r.chained);+ if (built.deps.length && chained) return { ...built, model, costUsd: null, error: chainedWaitMessage(plan.model.name, plan.op) };return { ...built, model, plan, costUsd: estimateCost(plan.model, plan.params, plan.jobs, plan.op) };} catch (e) {return { ...built, model, costUsd: null, error: (e as Error).message };diff --git a/src/lib/catalog/keyframes.ts b/src/lib/catalog/keyframes.tsindex 052f3412..72b5d652 100644--- a/src/lib/catalog/keyframes.ts+++ b/src/lib/catalog/keyframes.ts@@ -13,7 +13,7 @@** No catalog import (types only), so the composer can use it in the browser.*/-import type { Engine, ModelDef, ModelRoute } from "./types";+import type { Engine, ModelDef, ModelRoute, Operation } from "./types";/** Kling 4.0 and FLUX 3 Max take up to 10 frames. */export const MAX_KEYFRAMES = 10;@@ -60,9 +60,14 @@ export const FRAMES_MODELS: Record<Engine, { id: string; name: string }> = {open: { id: "oss-wan22-14b", name: "Wan 2.2 14B" },};-/** Why a chained route can't be a step that waits (a Canvas node fed by another node, a pipeline step): its clips are planned from its inputs when it's created. */-export const chainedWaitMessage = (name: string) =>- `${name} builds this film from several clips of the images you add when it starts — give it uploaded images and a typed prompt, not another step's output`;+/**+ * Why a chained route can't be a step that waits (a Canvas node fed by another node, a pipeline step): its steps+ * are planned from its inputs when it's created (a film's clips; the open text-to-3D route's still).+ */+export const chainedWaitMessage = (name: string, op?: Operation) =>+ op === "text-to-3d"+ ? `${name} draws the object first, then builds it in 3D, from words typed in when it starts — give it a typed description, not another step's output`+ : `${name} builds this film from several clips of the images you add when it starts — give it uploaded images and a typed prompt, not another step's output`;/** What stops Generate in Frames mode before the planner speaks: no start frame, or a model that can't follow frames. */export function framesBlocker(model: Pick<ModelDef, "name" | "engine" | "routes" | "options">, count: number): { message: string; slot?: "frames" } | null {diff --git a/src/server/chains.ts b/src/server/chains.tsindex ced4c2b4..de4a7ac0 100644--- a/src/server/chains.ts+++ b/src/server/chains.ts@@ -308,8 +308,17 @@ export function createStillTo3d(original: GenerationRequest, model: ModelDef, ro{ batchId },)[0];try {+ // The model is built from the still alone (a photo sent with the words has no place in this route).+ const { images: _ignored, ...inputs } = original.inputs ?? {};const built = createGenerations(- { ...original, modelId: builder, op: "image-to-3d", chain: [{ slot: "images", position: "first" }], step: { label: "3D model", index: 1, of: 2 } },+ {+ ...original,+ modelId: builder,+ op: "image-to-3d",+ inputs: Object.keys(inputs).length ? inputs : undefined,+ chain: [{ slot: "images", position: "first" }],+ step: { label: "3D model", index: 1, of: 2 },+ },{ batchId, dependsOn: still.id },)[0];return [built, still];diff --git a/src/server/generations.ts b/src/server/generations.tsindex b4543cba..7c1b4f09 100644--- a/src/server/generations.ts+++ b/src/server/generations.ts@@ -498,7 +498,7 @@ export function previewChained(req: GenerationRequest, deps: number) {// A waiting step always runs as one job (createGenerations doesn't batch dependents).const p = previewGeneration(withChainInputs(req, slotsFor(req, deps).map(placeholderFor)));// Refused before anything starts, as createGenerations refuses it.- if (routesFor(p.model, p.op).some((r) => r.chained)) throw new Error(chainedWaitMessage(p.model.name));+ if (routesFor(p.model, p.op).some((r) => r.chained)) throw new Error(chainedWaitMessage(p.model.name, p.op));const jobs = Math.max(1, p.jobs);return { ...p, jobs: 1, outputs: p.outputs / jobs, costUsd: p.costUsd === null ? null : p.costUsd / jobs };}@@ -527,16 +527,17 @@ export function createGenerations(original: GenerationRequest, opts: CreateOptio// Frames mode on an open model: one start/end-frame clip per pair of frames, then joined.const filmRoute = shotModel && keyframeChain(shotModel);if (!opts.dependsOn && filmRoute && inferOperation(shotModel, original) === "keyframes") return createKeyframeFilm(original, shotModel, filmRoute);- // Text to 3D on the open engine: a still first, then the 3D model of it.- const stillTo3d = shotModel && original.op === "text-to-3d" ? routesFor(shotModel, "text-to-3d").find((r) => r.chained) : undefined;- if (!opts.dependsOn && shotModel && stillTo3d) return createStillTo3d(original, shotModel, stillTo3d);+ // Text to 3D on the open engine: a still first, then the 3D model of it. The operation is read as the planner+ // reads it (Assist, MCP and API clients usually leave op out).+ const stillTo3d = !opts.dependsOn && shotModel && inferOperation(shotModel, original) === "text-to-3d" ? routesFor(shotModel, "text-to-3d").find((r) => r.chained) : undefined;+ if (shotModel && stillTo3d) return createStillTo3d(original, shotModel, stillTo3d);const deps = opts.dependsOn === undefined ? [] : Array.isArray(opts.dependsOn) ? opts.dependsOn : [opts.dependsOn];const waits = deps.length > 0;// A dependent job can't be planned until its inputs exist; it's validated with placeholders, then launched by the runner.const p = waits ? prepare(withChainInputs(original, slotsFor(original, deps.length).map(placeholderFor))) : prepare(original);const { req, plan, route, demo, providerId, cost, notes } = p;// A chained route is built from its inputs when it's created; it can't wait for another step's output.- if (waits && route.chained) throw new Error(chainedWaitMessage(plan.model.name));+ if (waits && route.chained) throw new Error(chainedWaitMessage(plan.model.name, plan.op));const jobs = waits ? 1 : plan.jobs;const batchId = opts.batchId ?? (jobs > 1 ? nanoid(10) : null);const now = Date.now();diff --git a/tests/model3d.test.ts b/tests/model3d.test.tsindex 672eb733..853ee291 100644--- a/tests/model3d.test.ts+++ b/tests/model3d.test.ts@@ -282,6 +282,24 @@ describe("open engine: text to 3D as a Z-Image Turbo still, then TRELLIS.2", ()expect(done.request.inputs?.images?.length).toBe(1);}, 60_000);+ it("runs as the same two steps when the request leaves op out (Assist, MCP, the API)", () => {+ const steps = gens.createGenerations({ feature: "image-to-3d", modelId: "oss-text-trellis2", prompt: "a brass lantern" });+ expect(steps.map((g) => [g.modelId, g.op])).toEqual([+ ["oss-trellis2", "image-to-3d"],+ ["oss-z-image-turbo", "t2i"],+ ]);+ // A photo sent along has no place in this route: the model is built from the still alone.+ const [built] = gens.createGenerations({ feature: "image-to-3d", modelId: "oss-text-trellis2", prompt: "a brass lantern", inputs: { images: ["/api/files/p.png"] } });+ expect(built.request.inputs?.images).toBeUndefined();+ expect(built.request.chain).toEqual([{ slot: "images", position: "first" }]);+ });++ it("can't wait for another step's words, and says so in 3D terms", () => {+ expect(() => gens.createGenerations({ feature: "image-to-3d", modelId: "oss-text-trellis2", op: "text-to-3d", prompt: "{text}", chain: [{ slot: "prompt" }] }, { dependsOn: "x" })).toThrow(+ /draws the object first, then builds it in 3D/,+ );+ });+it("needs the words", () => {expect(() => gens.createGenerations({ feature: "image-to-3d", modelId: "oss-text-trellis2", op: "text-to-3d", prompt: " " })).toThrow();});