nanoodle 0.8.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +59 -2
- package/bin/nanoodle.mjs +7 -1
- package/package.json +1 -1
- package/src/browser.mjs +1 -1
- package/src/catalog.mjs +19 -0
- package/src/cleanvoice.mjs +104 -0
- package/src/client.mjs +87 -8
- package/src/decide.mjs +160 -0
- package/src/endpoint.mjs +406 -0
- package/src/estimate.mjs +141 -20
- package/src/graph.mjs +18 -2
- package/src/index.mjs +2 -0
- package/src/io.mjs +32 -1
- package/src/local-media.mjs +38 -0
- package/src/media.mjs +3 -0
- package/src/nodes.mjs +205 -21
- package/src/workflow.mjs +155 -18
package/src/graph.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { NanoodleError } from "./errors.mjs";
|
|
|
3
3
|
/* Dynamic input-port families (mirrors the nanoodle app's runGraph). A wire landing on one of
|
|
4
4
|
these ports — or on a port declared in NODE_TYPES[type].inputs — is a data input; a wire
|
|
5
5
|
landing on ANY other port is a field override (wired prompt/system/lyrics/q/...). */
|
|
6
|
-
export const IMG_PORT_RE = /^img\d+$/; // llm vision references
|
|
6
|
+
export const IMG_PORT_RE = /^img\d+$/; // llm vision references, decide candidates
|
|
7
7
|
export const EDIT_IMG_RE = /^image\d*$/; // edit multi-reference: image, image2, ...
|
|
8
8
|
export const VID_PORT_RE = /^vid\d+$/;
|
|
9
9
|
export const CLIP_PORT_RE = /^clip\d+$/; // combine clips
|
|
@@ -40,6 +40,7 @@ export const NODE_TYPES = {
|
|
|
40
40
|
upload: { title: "Image input", inputs: [], outputs: [{ name: "image", type: "image" }], local: true },
|
|
41
41
|
aupload: { title: "Audio input", inputs: [], outputs: [{ name: "audio", type: "audio" }], local: true },
|
|
42
42
|
vupload: { title: "Video input", inputs: [], outputs: [{ name: "video", type: "video" }], local: true },
|
|
43
|
+
mupload: { title: "3D input", inputs: [], outputs: [{ name: "model", type: "model3d" }], local: true },
|
|
43
44
|
choice: { title: "Choice", inputs: [], outputs: [{ name: "text", type: "text" }], local: true },
|
|
44
45
|
join: { title: "Join", inputs: ["a", "b"], outputs: [{ name: "text", type: "text" }], local: true },
|
|
45
46
|
llm: { title: "LLM", inputs: [], outputs: [{ name: "text", type: "text" }], network: true },
|
|
@@ -48,8 +49,10 @@ export const NODE_TYPES = {
|
|
|
48
49
|
inpaint: { title: "Inpaint", inputs: ["image", "mask"], outputs: [{ name: "image", type: "image" }], network: true },
|
|
49
50
|
resize: { title: "Resize / crop", inputs: ["image"], outputs: [{ name: "image", type: "image" }], local: true },
|
|
50
51
|
vision: { title: "Vision", inputs: ["image"], outputs: [{ name: "text", type: "text" }], network: true },
|
|
52
|
+
decide: { title: "Decide", inputs: ["text"], outputs: [{ name: "text", type: "text" }, { name: "image", type: "image" }], network: true }, // img1… candidates (IMG_PORT_RE)
|
|
51
53
|
tvideo: { title: "Text→Video", inputs: [], outputs: [{ name: "video", type: "video" }], network: true },
|
|
52
54
|
ivideo: { title: "Image→Video", inputs: ["image"], outputs: [{ name: "video", type: "video" }], network: true },
|
|
55
|
+
model3d: { title: "3D model", inputs: ["image"], outputs: [{ name: "model", type: "model3d" }], network: true },
|
|
53
56
|
vedit: { title: "Video edit", inputs: ["video"], outputs: [{ name: "video", type: "video" }], network: true },
|
|
54
57
|
vframes: { title: "Video → frames", inputs: ["video"], outputs: [{ name: "frame1", type: "image" }], local: true, framesOut: true }, // dynamic frame1..N
|
|
55
58
|
combine: { title: "Combine videos", inputs: [], outputs: [{ name: "video", type: "video" }], local: true },
|
|
@@ -61,6 +64,10 @@ export const NODE_TYPES = {
|
|
|
61
64
|
trim: { title: "Trim audio", inputs: ["audio"], outputs: [{ name: "audio", type: "audio" }], local: true },
|
|
62
65
|
extractaudio: { title: "Extract audio", inputs: ["video"], outputs: [{ name: "audio", type: "audio" }], local: true },
|
|
63
66
|
transcribe: { title: "Transcribe", inputs: ["audio"], outputs: [{ name: "text", type: "text" }], network: true },
|
|
67
|
+
cleanvoice: { title: "Clean voice", inputs: ["audio", "video"], outputs: [{ name: "audio", type: "audio" }], network: true },
|
|
68
|
+
// Custom URL — not a NanoGPT call, so `network` stays unset (no API key required).
|
|
69
|
+
// Output port follows fields.mode (see deriveOutputs / endpointOutPort).
|
|
70
|
+
endpoint: { title: "Custom endpoint", inputs: ["text", "image", "audio", "video"], outputs: [{ name: "text", type: "text" }] },
|
|
64
71
|
comment: { title: "Comment", inputs: [], outputs: [], note: true, local: true },
|
|
65
72
|
};
|
|
66
73
|
|
|
@@ -83,6 +90,12 @@ export function optionalNode(node) {
|
|
|
83
90
|
return v === true || v === "true";
|
|
84
91
|
}
|
|
85
92
|
|
|
93
|
+
/** Author-locked node: fields.locked keeps every field at its stored value (no inputs derived). */
|
|
94
|
+
export function lockedNode(node) {
|
|
95
|
+
const v = node && node.fields && node.fields.locked;
|
|
96
|
+
return v === true || v === "true";
|
|
97
|
+
}
|
|
98
|
+
|
|
86
99
|
/** Is a wire landing on `port` of `node` a data input (vs a field override)? */
|
|
87
100
|
export function isInputPort(node, port) {
|
|
88
101
|
const t = NODE_TYPES[node.type];
|
|
@@ -104,7 +117,10 @@ const MEDIA_FIELD_KEYS = ["image", "mask", "audio", "video"];
|
|
|
104
117
|
const MEDIA_URL_RE = /^(data:|https?:)/i;
|
|
105
118
|
|
|
106
119
|
function scrubMediaPlaceholders(n, warnings) {
|
|
107
|
-
|
|
120
|
+
// mupload stores the .glb on fields.model. That key is an AI model id on every
|
|
121
|
+
// other node, so it is only treated as media here.
|
|
122
|
+
const keys = n.type === "mupload" ? MEDIA_FIELD_KEYS.concat(["model"]) : MEDIA_FIELD_KEYS;
|
|
123
|
+
for (const k of keys) {
|
|
108
124
|
const v = n.fields[k];
|
|
109
125
|
if (v == null || v === "" || (typeof v === "string" && MEDIA_URL_RE.test(v.trim()))) continue;
|
|
110
126
|
const shown = typeof v === "string"
|
package/src/index.mjs
CHANGED
|
@@ -6,6 +6,8 @@ export {
|
|
|
6
6
|
} from "./media.mjs";
|
|
7
7
|
export { NanoClient } from "./client.mjs";
|
|
8
8
|
export { NODE_TYPES, displayName, materialize, topoSort, wiredFramesFloor, MAX_FRAMES } from "./graph.mjs";
|
|
9
|
+
// edit models whose image ports are ORDERED roles — a caller building graphs needs the slot order
|
|
10
|
+
export { IMG_INPUT_ROLES } from "./nodes.mjs";
|
|
9
11
|
export { deriveInputs, deriveOutputs, deriveSettings, INPUT_SPECS, SETTING_SPECS } from "./io.mjs";
|
|
10
12
|
export { estimateGraphCost, graphModelKinds } from "./estimate.mjs";
|
|
11
13
|
// prompt length caps — a caller doing its own orchestration needs the same trim-and-say-so
|
package/src/io.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { NanoodleError } from "./errors.mjs";
|
|
2
|
-
import { NODE_TYPES, displayName, optionalNode, topoSort, wiredFramesFloor, MAX_FRAMES } from "./graph.mjs";
|
|
2
|
+
import { NODE_TYPES, displayName, lockedNode, optionalNode, topoSort, wiredFramesFloor, MAX_FRAMES } from "./graph.mjs";
|
|
3
|
+
import { endpointOutPort } from "./endpoint.mjs";
|
|
3
4
|
|
|
4
5
|
/* ============================== INPUTS ============================== */
|
|
5
6
|
|
|
@@ -9,6 +10,7 @@ export const INPUT_SPECS = {
|
|
|
9
10
|
upload: [{ f: "image", label: "Image", kind: "image" }],
|
|
10
11
|
aupload: [{ f: "audio", label: "Audio", kind: "audio" }],
|
|
11
12
|
vupload: [{ f: "video", label: "Video", kind: "video" }],
|
|
13
|
+
mupload: [{ f: "model", label: "3D file", kind: "model3d" }],
|
|
12
14
|
llm: [{ f: "prompt", label: "Prompt", kind: "textarea" },
|
|
13
15
|
{ f: "system", label: "System prompt", kind: "textarea", optional: true, def: "You are a helpful, concise assistant." }],
|
|
14
16
|
image: [{ f: "prompt", label: "Image prompt", kind: "textarea" }],
|
|
@@ -16,6 +18,9 @@ export const INPUT_SPECS = {
|
|
|
16
18
|
music: [{ f: "prompt", label: "Style / prompt", kind: "textarea" }],
|
|
17
19
|
remix: [{ f: "prompt", label: "Style / direction", kind: "textarea" }],
|
|
18
20
|
tts: [{ f: "prompt", label: "Text to speak", kind: "textarea" }],
|
|
21
|
+
// Optional: image-only 3D models run with a photo and no prompt.
|
|
22
|
+
model3d: [{ f: "prompt", label: "3D prompt", kind: "textarea", optional: true }],
|
|
23
|
+
endpoint:[{ f: "prompt", label: "Prompt", kind: "textarea" }],
|
|
19
24
|
};
|
|
20
25
|
|
|
21
26
|
/**
|
|
@@ -36,6 +41,9 @@ export function deriveInputs(graph) {
|
|
|
36
41
|
};
|
|
37
42
|
for (const n of graph.nodes) {
|
|
38
43
|
if (n.unknown) continue;
|
|
44
|
+
// fields.locked: the node's fields are fixed by the graph — never surfaced as inputs,
|
|
45
|
+
// so runs use the stored values.
|
|
46
|
+
if (lockedNode(n)) continue;
|
|
39
47
|
if (n.type === "inpaint") {
|
|
40
48
|
if (!fed(n.id, "prompt")) entries.push(mk(n, "prompt", "What to paint in", "textarea", false));
|
|
41
49
|
// image and/or mask surface whenever not wired (SPEC-io). The app's combined brush widget
|
|
@@ -163,6 +171,8 @@ export function deriveOutputs(graph) {
|
|
|
163
171
|
ports = [];
|
|
164
172
|
for (let i = 1; i <= count; i++) ports.push({ name: "frame" + i, type: "image" });
|
|
165
173
|
}
|
|
174
|
+
// Custom endpoint's output port follows fields.mode (chat→text, image, video, audio, json→text).
|
|
175
|
+
if (n.type === "endpoint") ports = [endpointOutPort(n)];
|
|
166
176
|
return { key, nodeId: n.id, type: n.type, ports };
|
|
167
177
|
});
|
|
168
178
|
}
|
|
@@ -187,6 +197,14 @@ export const SETTING_SPECS = {
|
|
|
187
197
|
{ f: "model", label: "Model", kind: "model" },
|
|
188
198
|
{ f: "q", label: "Question", kind: "textarea", def: "Describe this image." },
|
|
189
199
|
],
|
|
200
|
+
decide: [
|
|
201
|
+
{ f: "model", label: "Model", kind: "model" },
|
|
202
|
+
{ f: "mode", label: "Decide", kind: "select", options: ["pick", "choose", "score", "yesno"], def: "pick" },
|
|
203
|
+
{ f: "question", label: "Question", kind: "textarea" },
|
|
204
|
+
{ f: "options", label: "Labels (one per line)", kind: "textarea" },
|
|
205
|
+
{ f: "levels", label: "Scale (worst → best, one per line)", kind: "textarea", def: "poor\nokay\ngood\ngreat" },
|
|
206
|
+
{ f: "gate", label: "Gate: stop downstream on no", kind: "boolean" },
|
|
207
|
+
],
|
|
190
208
|
image: [
|
|
191
209
|
{ f: "model", label: "Model", kind: "model" },
|
|
192
210
|
{ f: "size", label: "Image size", kind: "select", options: SIZES, def: "1024x1024" },
|
|
@@ -245,6 +263,19 @@ export const SETTING_SPECS = {
|
|
|
245
263
|
{ f: "model", label: "Model", kind: "model" },
|
|
246
264
|
{ f: "language", label: "Language", kind: "text", def: "auto" },
|
|
247
265
|
],
|
|
266
|
+
cleanvoice: [
|
|
267
|
+
{ f: "model", label: "Model", kind: "model" },
|
|
268
|
+
{ f: "url", label: "Public link (when nothing is wired)", kind: "text" },
|
|
269
|
+
],
|
|
270
|
+
model3d: [
|
|
271
|
+
{ f: "model", label: "Model", kind: "model" },
|
|
272
|
+
],
|
|
273
|
+
endpoint: [
|
|
274
|
+
{ f: "url", label: "URL", kind: "text", def: "http://127.0.0.1:8787/v1/chat/completions" },
|
|
275
|
+
{ f: "mode", label: "Mode", kind: "select", options: ["chat", "image", "video", "audio", "json"], def: "chat" },
|
|
276
|
+
{ f: "model", label: "Model", kind: "text", def: "local" },
|
|
277
|
+
{ f: "auth", label: "Authorization (optional)", kind: "text", def: "" },
|
|
278
|
+
],
|
|
248
279
|
join: [{ f: "sep", label: "Separator (use \\n for a line break)", kind: "text", def: " " }],
|
|
249
280
|
inpaint: [
|
|
250
281
|
{ f: "model", label: "Model", kind: "model" },
|
package/src/local-media.mjs
CHANGED
|
@@ -729,6 +729,44 @@ export async function fitImageInline(url, { budget = INLINE_IMAGE_BUDGET, fetch:
|
|
|
729
729
|
throw new NanoodleError("image is too large to send inline even after resizing (~4 MB max) — use a smaller image");
|
|
730
730
|
}
|
|
731
731
|
|
|
732
|
+
/**
|
|
733
|
+
* Shrink an image to fit a decision model's limits (⚖️ Decide): long edge ≤ maxDim and the
|
|
734
|
+
* data: URL ≤ budget characters. JPEG on white (a transparent PNG can't turn black), stepping
|
|
735
|
+
* quality down, then size, until it fits — the twin of the browser's canvas decideFitImage.
|
|
736
|
+
* Needs ffmpeg (decisions without images never touch this).
|
|
737
|
+
*/
|
|
738
|
+
export async function fitImageJpeg(url, maxDim, budget, { fetch: fetchFn, signal } = {}) {
|
|
739
|
+
return withTemp(async (dir) => {
|
|
740
|
+
throwIfAborted(signal);
|
|
741
|
+
const inPath = await writeInput(dir, "in", url, fetchFn);
|
|
742
|
+
const probe = await runProc("ffprobe", [
|
|
743
|
+
"-v", "error", "-select_streams", "v:0",
|
|
744
|
+
"-show_entries", "stream=width,height", "-of", "csv=p=0:s=x", inPath,
|
|
745
|
+
], { signal });
|
|
746
|
+
const dims = String(probe.stdout).trim().split("x").map(Number);
|
|
747
|
+
const sw = dims[0], sh = dims[1];
|
|
748
|
+
if (!(sw > 0) || !(sh > 0)) throw new NanoodleError("couldn’t read an image to judge");
|
|
749
|
+
let s = Math.min(1, maxDim / Math.max(sw, sh));
|
|
750
|
+
const qs = [3, 5, 8, 12]; // mjpeg -q:v (2 = best … 31 = worst) ≈ canvas quality 0.85 → 0.48
|
|
751
|
+
for (let round = 0; round < 6; round++) {
|
|
752
|
+
const w = Math.max(2, Math.round(sw * s / 2) * 2), h = Math.max(2, Math.round(sh * s / 2) * 2);
|
|
753
|
+
for (const q of qs) {
|
|
754
|
+
throwIfAborted(signal);
|
|
755
|
+
const outPath = join(dir, `fit-${round}-${q}.jpg`);
|
|
756
|
+
await runProc("ffmpeg", [
|
|
757
|
+
"-y", "-i", inPath, "-filter_complex",
|
|
758
|
+
`color=c=white:s=${w}x${h}[bg];[0:v]scale=${w}:${h},format=rgba[fg];[bg][fg]overlay=shortest=1,format=yuvj420p`,
|
|
759
|
+
"-frames:v", "1", "-q:v", String(q), outPath,
|
|
760
|
+
], { signal });
|
|
761
|
+
const out = await dataUrlFromFile(outPath, "image/jpeg");
|
|
762
|
+
if (out.length <= budget) return out;
|
|
763
|
+
}
|
|
764
|
+
s *= 0.75;
|
|
765
|
+
}
|
|
766
|
+
throw new NanoodleError("couldn’t shrink an image small enough for the decision model");
|
|
767
|
+
});
|
|
768
|
+
}
|
|
769
|
+
|
|
732
770
|
async function resizeCropImageFfmpeg(url, m, w, h, { fetch: fetchFn, signal } = {}) {
|
|
733
771
|
return withTemp(async (dir) => {
|
|
734
772
|
throwIfAborted(signal);
|
package/src/media.mjs
CHANGED
|
@@ -42,6 +42,7 @@ const EXT_MIME = {
|
|
|
42
42
|
".mp3": "audio/mpeg", ".wav": "audio/wav", ".ogg": "audio/ogg", ".opus": "audio/ogg",
|
|
43
43
|
".aac": "audio/aac", ".flac": "audio/flac", ".m4a": "audio/mp4",
|
|
44
44
|
".mp4": "video/mp4", ".webm": "video/webm", ".mov": "video/quicktime", ".mkv": "video/x-matroska",
|
|
45
|
+
".glb": "model/gltf-binary",
|
|
45
46
|
".txt": "text/plain", ".json": "application/json",
|
|
46
47
|
};
|
|
47
48
|
|
|
@@ -50,6 +51,7 @@ const MIME_EXT = {
|
|
|
50
51
|
"audio/mpeg": "mp3", "audio/wav": "wav", "audio/ogg": "ogg", "audio/aac": "aac",
|
|
51
52
|
"audio/flac": "flac", "audio/mp4": "m4a",
|
|
52
53
|
"video/mp4": "mp4", "video/webm": "webm", "video/quicktime": "mov",
|
|
54
|
+
"model/gltf-binary": "glb",
|
|
53
55
|
"text/plain": "txt", "application/json": "json",
|
|
54
56
|
};
|
|
55
57
|
|
|
@@ -80,6 +82,7 @@ export function sniffMime(bytes) {
|
|
|
80
82
|
if (ascii(0, "fLaC")) return "audio/flac";
|
|
81
83
|
if (b.length >= 12 && ascii(4, "ftyp")) return "video/mp4";
|
|
82
84
|
if (b.length >= 4 && b[0] === 0x1a && b[1] === 0x45 && b[2] === 0xdf && b[3] === 0xa3) return "video/webm";
|
|
85
|
+
if (b.length >= 4 && ascii(0, "glTF")) return "model/gltf-binary";
|
|
83
86
|
return "application/octet-stream";
|
|
84
87
|
}
|
|
85
88
|
|
package/src/nodes.mjs
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { NanoodleError } from "./errors.mjs";
|
|
2
|
-
import { catItem, chatModelCan } from "./catalog.mjs";
|
|
2
|
+
import { catItem, chatModelCan, pricingAdvertisesRefs } from "./catalog.mjs";
|
|
3
3
|
import { IMG_PORT_RE, EDIT_IMG_RE, REF_PORT_RE, CLIP_PORT_RE, VID_PORT_RE, optionalNode } from "./graph.mjs";
|
|
4
4
|
import { MEDIA_INLINE_MAX } from "./media.mjs";
|
|
5
5
|
import {
|
|
6
6
|
resizeCropImage, trimAudioToWav, extractAudioToWav,
|
|
7
|
-
extractVideoFrames, concatVideos, muxSoundtrack, maskToSource, fitImageInline,
|
|
7
|
+
extractVideoFrames, concatVideos, muxSoundtrack, maskToSource, fitImageInline, fitImageJpeg,
|
|
8
8
|
} from "./local-media.mjs";
|
|
9
|
+
import { decideRun, decideImageLimits } from "./decide.mjs";
|
|
10
|
+
import { cleanVoiceRun, CLEANVOICE_DEFAULT_MODEL } from "./cleanvoice.mjs";
|
|
11
|
+
import { runEndpoint } from "./endpoint.mjs";
|
|
9
12
|
|
|
10
13
|
function mdl(n) {
|
|
11
14
|
const m = String((n.fields && n.fields.model) || "").trim();
|
|
@@ -52,6 +55,46 @@ function collectPorts(inp, re) {
|
|
|
52
55
|
.filter(Boolean);
|
|
53
56
|
}
|
|
54
57
|
|
|
58
|
+
/**
|
|
59
|
+
* Edit models that demand a FIXED, ORDERED set of input images. Nothing in the live catalog
|
|
60
|
+
* declares a minimum — a full 215-model scan (2026-07-31) found no min_items/min_input_images
|
|
61
|
+
* field, only free text — so the roles live here. The order IS the slot order: role 1 = the
|
|
62
|
+
* `image` port, role 2 = `image2`, … (flux vto auto-detects the wearer either way, but a
|
|
63
|
+
* garment-first send drifts the identity toward the garment photo's model).
|
|
64
|
+
*/
|
|
65
|
+
export const IMG_INPUT_ROLES = {
|
|
66
|
+
"flux-pro/v1/vto": ["person", "garment"],
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const imgSlot = (i) => (i === 1 ? "image" : "image" + i); // slot index → EDIT_IMG_RE port name
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Refuse a role-model edit BEFORE the paid call unless every slot is wired. Read the RAW inp
|
|
73
|
+
* keys, never collectPorts: that compacts (.filter(Boolean)), so wiring only `image2` promotes
|
|
74
|
+
* the garment into the person slot and buys a silently wrong result.
|
|
75
|
+
*/
|
|
76
|
+
function guardInputRoles(model, inp) {
|
|
77
|
+
const roles = IMG_INPUT_ROLES[String(model || "").trim()];
|
|
78
|
+
if (!roles) return;
|
|
79
|
+
const missing = roles.filter((r, i) => !inp[imgSlot(i + 1)]);
|
|
80
|
+
if (!missing.length) return;
|
|
81
|
+
const slots = roles.map((r, i) => `${r} (${imgSlot(i + 1)})`).join(", ");
|
|
82
|
+
throw new NanoodleError(
|
|
83
|
+
`${model} needs ${roles.length} images: ${slots} — ${roles.length - missing.length} wired (missing: ${missing.join(", ")})`,
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* edit/inpaint have a single image output, but some models always bill (and return) a fixed
|
|
89
|
+
* batch — midjourney/text-to-image and higgsfield-soul declare fixed_image_count: 4. Ask with
|
|
90
|
+
* multi so we can SEE the extras and say we dropped them; the return shape stays one url.
|
|
91
|
+
*/
|
|
92
|
+
function keptFirst(urls, ctx) {
|
|
93
|
+
if (!Array.isArray(urls)) return urls; // host-injected ctx.image that ignores multi → already one url
|
|
94
|
+
if (urls.length > 1 && ctx && ctx.progress) ctx.progress(`model returned ${urls.length} images, kept the first`);
|
|
95
|
+
return urls[0];
|
|
96
|
+
}
|
|
97
|
+
|
|
55
98
|
function promptOf(n, inp, errMsg) {
|
|
56
99
|
const raw = inp.prompt != null ? inp.prompt : n.fields.prompt != null ? n.fields.prompt : "";
|
|
57
100
|
const p = String(raw).trim();
|
|
@@ -126,7 +169,10 @@ function loraFamily(model) {
|
|
|
126
169
|
if (/flux-2/i.test(m)) return "flux2dev";
|
|
127
170
|
if (/z-image/i.test(m)) return "zimage";
|
|
128
171
|
if (/ltx/i.test(m)) return "ltx";
|
|
129
|
-
if (/
|
|
172
|
+
if (/minimax-h3/i.test(m)) return "h3";
|
|
173
|
+
if (/anima/i.test(m) && /lora/i.test(m)) return "anima";
|
|
174
|
+
if (/qwen-image-2\.1/i.test(m) && /lora/i.test(m)) return "qwen21";
|
|
175
|
+
if (/lora/i.test(m)) return /krea/i.test(m) ? "krea" : "flux";
|
|
130
176
|
return null;
|
|
131
177
|
}
|
|
132
178
|
|
|
@@ -135,7 +181,10 @@ function loraKind(type) { return (type === "image" || type === "edit" || type ==
|
|
|
135
181
|
function imageTakesLora(id) {
|
|
136
182
|
id = String(id || "");
|
|
137
183
|
if (/inpaint/i.test(id)) return false;
|
|
138
|
-
|
|
184
|
+
// flux-2-klein-* only (lora-capable per catalog); FLUX.3 Klein (blackforestlabs/flux-3/klein/…)
|
|
185
|
+
// takes no lora_url — twin of the app's imageTakesLora (nanoodle #732)
|
|
186
|
+
if (/flux-2-klein/i.test(id)) return true;
|
|
187
|
+
if (/minimax-h3\/(text-to-image|image-edit)/i.test(id)) return true;
|
|
139
188
|
return /(^|[-\/])lora($|[-\/])/i.test(id);
|
|
140
189
|
}
|
|
141
190
|
|
|
@@ -149,7 +198,7 @@ function modelTakesLora(kind, id) {
|
|
|
149
198
|
function loraCap(model) {
|
|
150
199
|
switch (loraFamily(model)) {
|
|
151
200
|
case "flux2dev": return 4;
|
|
152
|
-
case "flux2klein": case "zimage": case "ltx": return 3;
|
|
201
|
+
case "flux2klein": case "zimage": case "ltx": case "krea": case "h3": case "anima": case "qwen21": return 3;
|
|
153
202
|
default: return 1; // flux-lora, pimage — single slot
|
|
154
203
|
}
|
|
155
204
|
}
|
|
@@ -165,7 +214,7 @@ function nodeLoras(n) {
|
|
|
165
214
|
function loraBodyFor(model, items) {
|
|
166
215
|
const fam = loraFamily(model), sc = (v) => (isNaN(v) ? 1 : v);
|
|
167
216
|
if (fam === "pimage") return { lora_weights: items[0].url, lora_scale: sc(items[0].scale) };
|
|
168
|
-
if (fam === "flux2dev" || fam === "flux2klein" || fam === "zimage" || fam === "ltx") {
|
|
217
|
+
if (fam === "flux2dev" || fam === "flux2klein" || fam === "zimage" || fam === "ltx" || fam === "krea" || fam === "h3" || fam === "anima" || fam === "qwen21") {
|
|
169
218
|
const b = {};
|
|
170
219
|
items.forEach((it, i) => { b["lora_url_" + (i + 1)] = it.url; b["lora_scale_" + (i + 1)] = sc(it.scale); });
|
|
171
220
|
return b;
|
|
@@ -237,6 +286,13 @@ function imgExtra(n) {
|
|
|
237
286
|
const np = String(n.fields.negativePrompt || "").trim();
|
|
238
287
|
if (np) e.negative_prompt = np;
|
|
239
288
|
}
|
|
289
|
+
// FIBO 1.5: size is 1mp/4mp; shape rides as aspect_ratio. Only this advertised id —
|
|
290
|
+
// leftover fields.aspect after a model swap must not go out on Muse/Recraft/etc.
|
|
291
|
+
// Marketing /api/models additionalParams.aspect_ratio (v1 image-models still omits it).
|
|
292
|
+
if (n.fields.model === "bria/fibo-generate-1.5/text-to-image") {
|
|
293
|
+
const av = (n.fields.aspect != null && n.fields.aspect !== "") ? n.fields.aspect : "1:1";
|
|
294
|
+
if (av !== "") e.aspect_ratio = String(av);
|
|
295
|
+
}
|
|
240
296
|
return e;
|
|
241
297
|
}
|
|
242
298
|
|
|
@@ -255,12 +311,17 @@ function videoDims(n, ctx) {
|
|
|
255
311
|
const aWire = p.aspect_ratio ? "aspect_ratio" : p.orientation ? "orientation" : p.resolution_ratio ? "resolution_ratio" : "aspect_ratio";
|
|
256
312
|
const dP = p.duration || p.seconds;
|
|
257
313
|
const dWire = p.duration ? "duration" : p.seconds ? "seconds" : "duration";
|
|
314
|
+
// tvideo/ivideo soft-send aspect+duration (those nodes always show the knobs).
|
|
315
|
+
// vedit/lipsync and resolution never forward a leftover the model did not list.
|
|
316
|
+
// Gallery: Omni v1 has duration+aspect only; leftover 720p/4k from v1.1 must not POST.
|
|
317
|
+
// Matches play videoDimParams (pack.resolution / dimDefs) — including catalog-miss omit.
|
|
318
|
+
const soft = n.type !== "vedit" && n.type !== "lipsync";
|
|
258
319
|
let asp = f.aspect, dur = f.duration;
|
|
259
320
|
if ((asp == null || asp === "") && aP && aP.default != null) asp = aP.default;
|
|
260
321
|
if ((dur == null || dur === "") && dP && dP.default != null) dur = dP.default;
|
|
261
|
-
if (f.resolution != null && f.resolution !== "") out.resolution = f.resolution;
|
|
262
|
-
if (asp != null && asp !== "") out[aWire] = asp;
|
|
263
|
-
if (dur != null && dur !== "") out[dWire] = dur;
|
|
322
|
+
if (p.resolution && f.resolution != null && f.resolution !== "") out.resolution = f.resolution;
|
|
323
|
+
if ((aP || soft) && asp != null && asp !== "") out[aWire] = asp;
|
|
324
|
+
if ((dP || soft) && dur != null && dur !== "") out[dWire] = dur;
|
|
264
325
|
return out;
|
|
265
326
|
}
|
|
266
327
|
|
|
@@ -268,10 +329,13 @@ function videoDims(n, ctx) {
|
|
|
268
329
|
Video models disagree on the ref-array param name AND its size limit; sending the wrong
|
|
269
330
|
key silently degrades to a plain video, sending too many can over-bill. Resolve the
|
|
270
331
|
model's REAL key from the catalog and clamp to its declared max. */
|
|
271
|
-
function refMaxFor(model) {
|
|
332
|
+
function refMaxFor(model, pricing) {
|
|
272
333
|
const id = String(model || "");
|
|
273
334
|
if (/seedance/i.test(id)) return 9;
|
|
335
|
+
if (/minimax-h3/i.test(id)) return 9; // upstream cap; the first 5 are included, 6-9 bill extra_reference_image each
|
|
274
336
|
if (/luma|ray/i.test(id)) return 4;
|
|
337
|
+
const inc = pricing && +pricing.included_reference_images;
|
|
338
|
+
if (inc > 0) return inc; // no family entry: the included count is the only number the catalog gives us
|
|
275
339
|
return 4;
|
|
276
340
|
}
|
|
277
341
|
|
|
@@ -285,15 +349,15 @@ function modelRefSpec(model, ctx) {
|
|
|
285
349
|
const m = catItem(ctx && ctx.catalog, "video", model);
|
|
286
350
|
if (!m) return { key: "reference_images", cap: refMaxFor(model) };
|
|
287
351
|
const sp = m.supported_parameters || {}, pp = sp.parameters || sp;
|
|
288
|
-
const key = keys.find((k) => k in pp);
|
|
289
|
-
if (!key) return null; // known model with no ref-image param
|
|
352
|
+
const key = keys.find((k) => k in pp) || (pricingAdvertisesRefs(m.pricing) ? "reference_images" : null);
|
|
353
|
+
if (!key) return null; // known model with no ref-image param and no ref pricing
|
|
290
354
|
const d = pp[key];
|
|
291
355
|
let cap = null;
|
|
292
356
|
if (d && typeof d === "object") {
|
|
293
357
|
const mx = d.max != null ? d.max : d.maxItems != null ? d.maxItems : d.max_items;
|
|
294
358
|
if (mx != null && +mx > 0) cap = +mx;
|
|
295
359
|
}
|
|
296
|
-
return { key, cap: cap != null ? cap : refMaxFor(model) };
|
|
360
|
+
return { key, cap: cap != null ? cap : refMaxFor(model, m.pricing) };
|
|
297
361
|
}
|
|
298
362
|
|
|
299
363
|
/** Attach wired refs to video opts under the model's real key, clamped to its cap (twin of the app runtimes: say so, never silently discard). */
|
|
@@ -337,22 +401,42 @@ function audioParams(n, ctx) {
|
|
|
337
401
|
const durOk = !sp || (sp.min_duration != null && sp.max_duration != null); // cat:duration
|
|
338
402
|
const secDurOk = !sp || (sp.min_duration != null && sp.max_duration != null && +((m.pricing || {}).per_second) > 0); // cat:secduration
|
|
339
403
|
const voiceOk = !sp || (Array.isArray(sp.voices) && sp.voices.length > 0); // cat:voices
|
|
404
|
+
// Yue2 catalogs the file type as output_format (mp3/wav/flac). The OpenAI response_format
|
|
405
|
+
// key is ignored, so a wav/flac choice came back as mp3. No output_format in the catalog
|
|
406
|
+
// (or no catalog) keeps the old response_format send.
|
|
407
|
+
const putFormat = (fmt) => {
|
|
408
|
+
if (!nonEmpty(fmt)) return;
|
|
409
|
+
const of = sp && sp.output_format;
|
|
410
|
+
const values = of && Array.isArray(of.values) ? of.values : null;
|
|
411
|
+
if (values) {
|
|
412
|
+
if (values.indexOf(fmt) < 0) return;
|
|
413
|
+
const def = of.default != null ? of.default : "mp3";
|
|
414
|
+
if (fmt === def) return;
|
|
415
|
+
body.output_format = fmt;
|
|
416
|
+
return;
|
|
417
|
+
}
|
|
418
|
+
if (fmt !== "mp3") body.response_format = fmt;
|
|
419
|
+
};
|
|
340
420
|
if (n.type === "music") {
|
|
341
421
|
if (nonEmpty(f.lyrics)) body.lyrics = f.lyrics;
|
|
342
422
|
if (f.instrumental === true || f.instrumental === "true") body.instrumental = true;
|
|
343
423
|
if (nonEmpty(f.duration) && num(f.duration) != null && durOk) body.duration = num(f.duration);
|
|
344
424
|
if (nonEmpty(f.negative_prompt)) body.negative_prompt = f.negative_prompt;
|
|
345
425
|
if (nonEmpty(f.seed) && num(f.seed) != null) body.seed = num(f.seed);
|
|
346
|
-
|
|
426
|
+
putFormat(f.response_format);
|
|
347
427
|
} else if (n.type === "tts") {
|
|
348
428
|
if (nonEmpty(f.voice) && voiceOk) body.voice = f.voice;
|
|
349
429
|
if (nonEmpty(f.speed) && num(f.speed) != null && num(f.speed) !== 1) body.speed = num(f.speed); // omit when 1
|
|
350
430
|
if (nonEmpty(f.instructions)) body.instructions = f.instructions;
|
|
351
|
-
|
|
431
|
+
putFormat(f.response_format);
|
|
352
432
|
} else if (n.type === "remix") {
|
|
353
433
|
if (nonEmpty(f.lyrics)) body.lyrics = f.lyrics;
|
|
354
434
|
if (nonEmpty(f.duration) && num(f.duration) != null && secDurOk) body.duration = num(f.duration);
|
|
355
|
-
|
|
435
|
+
// Format is a remix knob only when the catalog lists output_format (Yue2 music-to-music).
|
|
436
|
+
// A cover model with no such key must not receive a stale response_format.
|
|
437
|
+
const of = sp && sp.output_format;
|
|
438
|
+
const fmtListed = !!(of && Array.isArray(of.values) && of.values.length);
|
|
439
|
+
if (!sp || fmtListed) putFormat(f.response_format);
|
|
356
440
|
}
|
|
357
441
|
if ((f.extraJson || "").trim()) {
|
|
358
442
|
try { Object.assign(body, JSON.parse(f.extraJson)); }
|
|
@@ -422,6 +506,13 @@ export const RUNNERS = {
|
|
|
422
506
|
}
|
|
423
507
|
return { video: n.fields.video };
|
|
424
508
|
},
|
|
509
|
+
async mupload(n) {
|
|
510
|
+
if (!n.fields.model) {
|
|
511
|
+
if (optionalNode(n)) return { model: "" };
|
|
512
|
+
throw new NanoodleError("no 3D file — drop a .glb first");
|
|
513
|
+
}
|
|
514
|
+
return { model: n.fields.model };
|
|
515
|
+
},
|
|
425
516
|
|
|
426
517
|
async choice(n) {
|
|
427
518
|
const opts = String(n.fields.options || "").split("\n").map((s) => s.trim()).filter(Boolean);
|
|
@@ -504,7 +595,16 @@ export const RUNNERS = {
|
|
|
504
595
|
|
|
505
596
|
async llm(n, inp, ctx) {
|
|
506
597
|
const prompt = promptOf(n, inp, "no prompt");
|
|
507
|
-
|
|
598
|
+
// Wired image ports: a text-only chat model can't see the pictures and NanoGPT still
|
|
599
|
+
// bills the image tokens, so drop them for a KNOWN text-only model and note it —
|
|
600
|
+
// mirrors play's chatModelCan("vision") / editor modelSupportsImages gate (permissive
|
|
601
|
+
// for catalog-absent models; twin of the audio gate below).
|
|
602
|
+
const allImgs = collectPorts(inp, IMG_PORT_RE);
|
|
603
|
+
const seesImages = chatModelCan(ctx.catalog, mdl(n), "vision");
|
|
604
|
+
const imgs = seesImages
|
|
605
|
+
? await Promise.all(allImgs.map((u) => fitImage(u, ctx, "wired image")))
|
|
606
|
+
: [];
|
|
607
|
+
if (allImgs.length && !seesImages) ctx.progress("image(s) ignored — this model is text-only");
|
|
508
608
|
// hosted audio (music/tts nodes return https CDN URLs verbatim) → download + inline as base64:
|
|
509
609
|
// the chat input_audio part carries bytes, never a URL
|
|
510
610
|
let audioPart = null;
|
|
@@ -536,6 +636,17 @@ export const RUNNERS = {
|
|
|
536
636
|
return { text: await ctx.chat(messages, mdl(n), {}) };
|
|
537
637
|
},
|
|
538
638
|
|
|
639
|
+
// ⚖️ Decide: one typed question to a NanoGPT decision model (twin of the editor/play node).
|
|
640
|
+
// A closed yes/no gate throws a NanoodleError with code "decide-gate" — downstream skips, unbilled.
|
|
641
|
+
async decide(n, inp, ctx) {
|
|
642
|
+
const model = mdl(n);
|
|
643
|
+
const it = catItem(ctx.catalog, "chat", model);
|
|
644
|
+
// a catalog row WITHOUT decision_input (e.g. the non-detailed /api/v1/models list) is "unknown", not text-only
|
|
645
|
+
const lim = decideImageLimits(it && it.decision_input, !!(it && it.decision_input));
|
|
646
|
+
const fit = (u, maxDim, budget) => fitImageJpeg(u, maxDim, budget, mediaOpts(ctx));
|
|
647
|
+
return decideRun(n.fields || {}, model, inp.text, collectPorts(inp, IMG_PORT_RE), lim, (body) => ctx.decide(body), fit);
|
|
648
|
+
},
|
|
649
|
+
|
|
539
650
|
async image(n, inp, ctx) {
|
|
540
651
|
const prompt = promptOf(n, inp, "no prompt");
|
|
541
652
|
let want = Math.max(1, parseInt(n.fields.variations, 10) || 1);
|
|
@@ -549,6 +660,7 @@ export const RUNNERS = {
|
|
|
549
660
|
},
|
|
550
661
|
|
|
551
662
|
async edit(n, inp, ctx) {
|
|
663
|
+
guardInputRoles(n.fields.model, inp); // role models: refuse holes before spending
|
|
552
664
|
let imgs = collectPorts(inp, EDIT_IMG_RE);
|
|
553
665
|
if (!imgs.length) throw new NanoodleError("no image input");
|
|
554
666
|
// cap to the model's max_input_images (item present but silent → 1; absent → no cap):
|
|
@@ -567,7 +679,8 @@ export const RUNNERS = {
|
|
|
567
679
|
imgs = await Promise.all(imgs.map((u) => fitImage(u, ctx, "source image")));
|
|
568
680
|
guardRefsSize(imgs);
|
|
569
681
|
const src = imgs.length > 1 ? imgs : imgs[0]; // array → multi-image composite; string → single edit
|
|
570
|
-
|
|
682
|
+
const urls = await ctx.image({ prompt, model: mdl(n), size: n.fields.size || "1024x1024", imageDataUrl: src, extra: imgExtra(n), multi: true });
|
|
683
|
+
return { image: keptFirst(urls, ctx) };
|
|
571
684
|
},
|
|
572
685
|
|
|
573
686
|
async inpaint(n, inp, ctx) {
|
|
@@ -580,7 +693,8 @@ export const RUNNERS = {
|
|
|
580
693
|
// ctx.maskToSource lets a browser host inject its canvas compositor (handles JPEG/WebP
|
|
581
694
|
// sources the pure-PNG path can't, where ffmpeg isn't an option).
|
|
582
695
|
const mask = await (ctx.maskToSource || maskToSource)(rawMask, source, mediaOpts(ctx));
|
|
583
|
-
|
|
696
|
+
const urls = await ctx.image({ prompt, model: mdl(n), size: n.fields.size || "1024x1024", imageDataUrl: source, maskDataUrl: mask, extra: imgExtra(n), multi: true });
|
|
697
|
+
return { image: keptFirst(urls, ctx) };
|
|
584
698
|
},
|
|
585
699
|
|
|
586
700
|
async tvideo(n, inp, ctx) {
|
|
@@ -607,7 +721,12 @@ export const RUNNERS = {
|
|
|
607
721
|
},
|
|
608
722
|
|
|
609
723
|
async lipsync(n, inp, ctx) {
|
|
610
|
-
|
|
724
|
+
// Portrait required only for image_to_video avatars. Preset-only talking avatars (audio→video,
|
|
725
|
+
// catalog image_to_video false — e.g. HeyGen Avatar V) run from the preset + audio alone, and a
|
|
726
|
+
// wired image is NOT forwarded. Catalog miss / no catalog keeps the portrait requirement.
|
|
727
|
+
// Twin of play's built-in lipsync runner (nanoodle #733).
|
|
728
|
+
const needsPortrait = avatarNeedsPortrait(ctx && ctx.catalog, String((n.fields && n.fields.model) || "").trim());
|
|
729
|
+
if (needsPortrait && !inp.image) throw new NanoodleError("no image input");
|
|
611
730
|
if (!inp.audio) throw new NanoodleError("no audio input");
|
|
612
731
|
const prompt = promptOf(n, inp);
|
|
613
732
|
// Avatar models cap audio length (LongCat = 30s) and the cap isn't reliably in the catalog,
|
|
@@ -619,7 +738,7 @@ export const RUNNERS = {
|
|
|
619
738
|
// ctx.trimAudio lets a browser host inject its Web Audio trimmer so the retry bytes match
|
|
620
739
|
// its built-in runner exactly; default is the local-media trimmer (pure-JS WAV, ffmpeg).
|
|
621
740
|
const trim = ctx.trimAudio || ((url, start, len, rate) => trimAudioToWav(url, start, len, rate, mediaOpts(ctx)));
|
|
622
|
-
const img = await fitImage(inp.image, ctx, "portrait image");
|
|
741
|
+
const img = needsPortrait ? await fitImage(inp.image, ctx, "portrait image") : null;
|
|
623
742
|
let trimSec = null;
|
|
624
743
|
for (let attempt = 0; attempt < 2; attempt++) {
|
|
625
744
|
let opts;
|
|
@@ -688,4 +807,69 @@ export const RUNNERS = {
|
|
|
688
807
|
if (!inp.audio) throw new NanoodleError("no audio input");
|
|
689
808
|
return { text: await ctx.transcribe(mdl(n), inp.audio, (n.fields.language || "auto").trim()) };
|
|
690
809
|
},
|
|
810
|
+
|
|
811
|
+
// 🎧 Clean voice: hosted audio or video → voice-only audio. data:/blob: refused before any request.
|
|
812
|
+
async cleanvoice(n, inp, ctx) {
|
|
813
|
+
const model = String((n.fields && n.fields.model) || "").trim() || CLEANVOICE_DEFAULT_MODEL;
|
|
814
|
+
return cleanVoiceRun(model, inp, n.fields, (m, extra) => ctx.audio(m, "", extra));
|
|
815
|
+
},
|
|
816
|
+
|
|
817
|
+
// 🧊 3D model: image and/or text → GLB via the video submit/poll API (mediaKind model3d).
|
|
818
|
+
async model3d(n, inp, ctx) {
|
|
819
|
+
const model = String((n.fields && n.fields.model) || "").trim() || MODEL3D_IMAGE_DEFAULT;
|
|
820
|
+
const mods = model3dInputMods(ctx && ctx.catalog, model);
|
|
821
|
+
const prompt = promptOf(n, inp);
|
|
822
|
+
let image = mods.image ? (inp.image || "") : "";
|
|
823
|
+
if (inp.image && !mods.image && ctx && ctx.progress) {
|
|
824
|
+
ctx.progress("This model takes text only — the image wire stays, but this run ignores it.");
|
|
825
|
+
}
|
|
826
|
+
if (prompt && !mods.text && ctx && ctx.progress) {
|
|
827
|
+
ctx.progress("This model takes an image only — the prompt stays, but this run ignores it.");
|
|
828
|
+
}
|
|
829
|
+
if (mods.image && !mods.text && !image) throw new NanoodleError("Connect an image first.");
|
|
830
|
+
if (mods.text && !mods.image && !prompt) throw new NanoodleError("Add a prompt first.");
|
|
831
|
+
if (mods.image && mods.text && !image && !prompt) throw new NanoodleError("Add a prompt or connect an image first.");
|
|
832
|
+
if (image) image = await fitImage(image, ctx, "source image");
|
|
833
|
+
const url = await ctx.video(model, mods.text ? prompt : "", {
|
|
834
|
+
extra: n.fields.modelOpts || {},
|
|
835
|
+
mediaKind: "model3d",
|
|
836
|
+
}, image || null);
|
|
837
|
+
return { model: url };
|
|
838
|
+
},
|
|
839
|
+
|
|
840
|
+
// 🔌 Custom endpoint: POST to the graph's own URL. ctx.fetch so tests can point it at a mock.
|
|
841
|
+
async endpoint(n, inp, ctx) {
|
|
842
|
+
return runEndpoint(n, inp, { fetch: ctx && ctx.fetch, signal: ctx && ctx.signal });
|
|
843
|
+
},
|
|
691
844
|
};
|
|
845
|
+
|
|
846
|
+
/**
|
|
847
|
+
* Does this avatar/lipsync model need a portrait image? True unless the model is in the
|
|
848
|
+
* opt-in catalog and is preset-only (no image_to_video — audio→video talking avatars such as
|
|
849
|
+
* HeyGen Avatar V). Catalog miss → true (the long-standing portrait requirement).
|
|
850
|
+
* Mirrors play's built-in lipsync runner: raw `capabilities.image_to_video` or a normalized `i2v`.
|
|
851
|
+
*/
|
|
852
|
+
function avatarNeedsPortrait(catalog, model) {
|
|
853
|
+
const m = catItem(catalog, "video", model);
|
|
854
|
+
return !m || !!((m.capabilities || {}).image_to_video) || !!m.i2v;
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
// Image→3D (Tripo) takes a photo only. Hunyuan Rapid takes text and an optional image.
|
|
858
|
+
// Anything else, including a catalog miss, accepts either — the editor's same fallback.
|
|
859
|
+
const MODEL3D_IMAGE_DEFAULT = "tripo3d/v2.5";
|
|
860
|
+
const MODEL3D_TEXT_DEFAULT = "wavespeed-ai/hunyuan-3d-v3.1-rapid";
|
|
861
|
+
|
|
862
|
+
function model3dInputMods(catalog, id) {
|
|
863
|
+
const it = catItem(catalog, "model3d", id);
|
|
864
|
+
const raw = it && (
|
|
865
|
+
(Array.isArray(it.modalities) && it.modalities)
|
|
866
|
+
|| (it.architecture && Array.isArray(it.architecture.input_modalities) && it.architecture.input_modalities)
|
|
867
|
+
);
|
|
868
|
+
if (raw && raw.length) {
|
|
869
|
+
const mods = raw.filter((x) => x === "image" || x === "text");
|
|
870
|
+
if (mods.length) return { image: mods.includes("image"), text: mods.includes("text") };
|
|
871
|
+
}
|
|
872
|
+
if (id === MODEL3D_IMAGE_DEFAULT) return { image: true, text: false };
|
|
873
|
+
if (id === MODEL3D_TEXT_DEFAULT) return { image: true, text: true };
|
|
874
|
+
return { image: true, text: true };
|
|
875
|
+
}
|