nanoodle 0.6.1 → 0.6.2
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 +7 -0
- package/bin/nanoodle.mjs +19 -2
- package/package.json +1 -1
- package/src/graph.mjs +31 -0
package/README.md
CHANGED
|
@@ -144,6 +144,13 @@ Media is sent inline as base64 (NanoGPT has no upload endpoint). Files over
|
|
|
144
144
|
~4.4 MB (~3.5 MB for transcription) are refused locally with a clear error
|
|
145
145
|
before any paid call.
|
|
146
146
|
|
|
147
|
+
When authoring a graph by hand, leave media fields **empty** (`"image": ""` or
|
|
148
|
+
omit them) — the input then shows up as *required* in `inspect`/`wf.inputs` and
|
|
149
|
+
you supply the file at run time. Don’t write prose placeholders like
|
|
150
|
+
`"[image provided separately]"` into `fields.image`: anything that isn’t a
|
|
151
|
+
`data:` or `http(s)` URL is treated as empty at load (with a warning), never
|
|
152
|
+
sent to the API.
|
|
153
|
+
|
|
147
154
|
### Progress and errors
|
|
148
155
|
|
|
149
156
|
```js
|
package/bin/nanoodle.mjs
CHANGED
|
@@ -178,10 +178,27 @@ then: NANOGPT_API_KEY=... nanoodle run ${dest} --input Text="your idea"`);
|
|
|
178
178
|
|
|
179
179
|
if (cmd === "inspect") {
|
|
180
180
|
const pad = (s, n) => String(s).padEnd(n);
|
|
181
|
+
// Media defaults are data: URLs (megabytes of base64) — summarize instead of dumping,
|
|
182
|
+
// and tell the caller HOW to supply an unfilled media input, right in the listing.
|
|
183
|
+
const MEDIA_INPUT_KINDS = new Set(["image", "audio", "video"]);
|
|
184
|
+
const fmtSize = (chars) => chars >= 1024 * 1024
|
|
185
|
+
? (chars / 1024 / 1024).toFixed(1) + " MB" : Math.max(1, Math.round(chars / 1024)) + " KB";
|
|
186
|
+
const describeDefault = (i) => {
|
|
187
|
+
if (i.def == null) return null;
|
|
188
|
+
const s = String(i.def);
|
|
189
|
+
if (!MEDIA_INPUT_KINDS.has(i.kind)) return `default: ${JSON.stringify(i.def)}`;
|
|
190
|
+
if (/^data:/i.test(s)) {
|
|
191
|
+
const mime = (s.match(/^data:([^;,]+)/) || [])[1] || i.kind;
|
|
192
|
+
return `prefilled: inline ${mime} (${fmtSize(s.length)})`;
|
|
193
|
+
}
|
|
194
|
+
return `prefilled: ${s.length > 60 ? s.slice(0, 57) + "…" : s}`;
|
|
195
|
+
};
|
|
181
196
|
console.log("Inputs:");
|
|
182
197
|
for (const i of wf.inputs) {
|
|
183
|
-
const extras = [i.optional ? "optional" : "required",
|
|
184
|
-
i.options ? `options: ${i.options.join(" | ")}` : null
|
|
198
|
+
const extras = [i.optional ? "optional" : "required", describeDefault(i),
|
|
199
|
+
i.options ? `options: ${i.options.join(" | ")}` : null,
|
|
200
|
+
MEDIA_INPUT_KINDS.has(i.kind) && i.def == null ? `supply: --input "${i.key}=@file"` : null,
|
|
201
|
+
].filter(Boolean).join(", ");
|
|
185
202
|
console.log(` ${pad('"' + i.key + '"', 26)} ${pad(i.nodeId + "." + i.field, 16)} ${pad(i.kind, 9)} ${extras}`);
|
|
186
203
|
}
|
|
187
204
|
if (!wf.inputs.length) console.log(" (none)");
|
package/package.json
CHANGED
package/src/graph.mjs
CHANGED
|
@@ -92,10 +92,39 @@ export function isInputPort(node, port) {
|
|
|
92
92
|
return DYNAMIC_INPUT_RES.some((re) => re.test(port));
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
+
/**
|
|
96
|
+
* Media fields (upload image, inpaint image/mask, audio/video clips) hold a data: or
|
|
97
|
+
* http(s) URL — the editor writes data: URLs, hand-authored graphs may inline either.
|
|
98
|
+
* Agents authoring graphs sometimes leave a prose placeholder instead ("[image will be
|
|
99
|
+
* provided at run time]") or a bare file path: those LOOK filled (inspect prints a
|
|
100
|
+
* default, run() skips the required-input check) but post garbage to the API. Anything
|
|
101
|
+
* that isn't a real media URL is treated as EMPTY at load, with a warning that says how
|
|
102
|
+
* to actually supply the media.
|
|
103
|
+
*/
|
|
104
|
+
const MEDIA_FIELD_KEYS = ["image", "mask", "audio", "video"];
|
|
105
|
+
const MEDIA_URL_RE = /^(data:|https?:)/i;
|
|
106
|
+
|
|
107
|
+
function scrubMediaPlaceholders(n, warnings) {
|
|
108
|
+
for (const k of MEDIA_FIELD_KEYS) {
|
|
109
|
+
const v = n.fields[k];
|
|
110
|
+
if (v == null || v === "" || (typeof v === "string" && MEDIA_URL_RE.test(v.trim()))) continue;
|
|
111
|
+
const shown = typeof v === "string"
|
|
112
|
+
? `"${v.length > 60 ? v.slice(0, 57) + "…" : v}"`
|
|
113
|
+
: Array.isArray(v) ? "an array" : typeof v === "object" ? "an object" : `a ${typeof v}`;
|
|
114
|
+
n.fields[k] = "";
|
|
115
|
+
warnings.push(
|
|
116
|
+
`node ${n.id} (${displayName(n)}): fields.${k} held ${shown} — not a data: or http(s) URL, so it was ` +
|
|
117
|
+
`treated as empty. Leave media fields "" in the graph and supply the ${k} at run time ` +
|
|
118
|
+
`(CLI: --input "<key>=@file", library: run({ "<key>": mediaFromFile(path) }), key from inspect/wf.inputs), ` +
|
|
119
|
+
`or inline a data: URL.`);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
95
123
|
/**
|
|
96
124
|
* Load raw parsed graph JSON into an executable graph (mirrors the app's applyGraphData):
|
|
97
125
|
* - `audio` type aliases to `tts` (legacy saves)
|
|
98
126
|
* - unknown node types are KEPT but flagged (`unknown: true`) + a warning; run() fails fast on them
|
|
127
|
+
* - media fields that aren't a data:/http(s) URL (prose placeholders, file paths) are blanked + a warning
|
|
99
128
|
* - links are kept only when both endpoints exist
|
|
100
129
|
* - links into music/tts port "text" migrate to "prompt"
|
|
101
130
|
* @returns {{ nodes, links, warnings: string[] }}
|
|
@@ -113,6 +142,8 @@ export function materialize(data) {
|
|
|
113
142
|
if (!NODE_TYPES[type]) {
|
|
114
143
|
n.unknown = true;
|
|
115
144
|
warnings.push(`unknown node type "${raw.type}" (node ${n.id}) — kept, but running this workflow will fail; you may need a newer nanoodle library`);
|
|
145
|
+
} else {
|
|
146
|
+
scrubMediaPlaceholders(n, warnings);
|
|
116
147
|
}
|
|
117
148
|
nodes.push(n);
|
|
118
149
|
}
|