@flaxia/node 0.6.1 → 0.7.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.
Files changed (37) hide show
  1. package/README.md +2 -0
  2. package/dist/assets/ai-inference.js +83 -183
  3. package/dist/assets/ai-model-registry.js +127 -0
  4. package/dist/assets/cc-extract.js +5166 -0
  5. package/dist/assets/decision.js +142 -0
  6. package/dist/assets/embed-gemma.js +97 -0
  7. package/dist/assets/transformers.web.js +2 -2
  8. package/dist/assets/vector-embed.js +136 -26
  9. package/dist/assets/webgpuProbe.js +83 -66
  10. package/dist/client/SignalingClient.d.ts.map +1 -1
  11. package/dist/client/light-preloader.d.ts +6 -1
  12. package/dist/client/light-preloader.d.ts.map +1 -1
  13. package/dist/consent/notice.d.ts +3 -1
  14. package/dist/consent/notice.d.ts.map +1 -1
  15. package/dist/executor/WorkerPool.d.ts +1 -0
  16. package/dist/executor/WorkerPool.d.ts.map +1 -1
  17. package/dist/index.js +371 -364
  18. package/dist/worker.js +129 -120
  19. package/dist/workloads/__tests__/cc-extract.test.d.ts +2 -0
  20. package/dist/workloads/__tests__/cc-extract.test.d.ts.map +1 -0
  21. package/dist/workloads/__tests__/decision.test.d.ts +2 -0
  22. package/dist/workloads/__tests__/decision.test.d.ts.map +1 -0
  23. package/dist/workloads/__tests__/embed-gemma.test.d.ts +2 -0
  24. package/dist/workloads/__tests__/embed-gemma.test.d.ts.map +1 -0
  25. package/dist/workloads/__tests__/wasm-threads.test.d.ts.map +1 -1
  26. package/dist/workloads/ai-inference.d.ts +21 -2
  27. package/dist/workloads/ai-inference.d.ts.map +1 -1
  28. package/dist/workloads/ai-model-registry.d.ts.map +1 -1
  29. package/dist/workloads/cc-extract.d.ts +11 -0
  30. package/dist/workloads/cc-extract.d.ts.map +1 -0
  31. package/dist/workloads/decision.d.ts +21 -0
  32. package/dist/workloads/decision.d.ts.map +1 -0
  33. package/dist/workloads/embed-gemma.d.ts +8 -0
  34. package/dist/workloads/embed-gemma.d.ts.map +1 -0
  35. package/dist/workloads/vector-embed.d.ts +10 -0
  36. package/dist/workloads/vector-embed.d.ts.map +1 -1
  37. package/package.json +4 -3
@@ -0,0 +1,142 @@
1
+ import { n as e } from "./egress-guard.js";
2
+ import { o as t } from "./ai-model-registry.js";
3
+ //#region src/workloads/decision.ts
4
+ var n = "LiquidAI/d1-omni-600M", r = 16e3, i = r * 30, a = 2e4, o = 8 * 1024 * 1024, s = 8 * 1024 * 1024, c = 2e4, l = null, u = null, d = () => {
5
+ l = null, u = null;
6
+ };
7
+ function f(e) {
8
+ let t = e.decision;
9
+ if (!t) throw Error("decision: payload.decision is required for d1-omni");
10
+ let n = t.questions;
11
+ if (!n || typeof n != "object") throw Error("decision: questions must be an object");
12
+ let r = Object.keys(n);
13
+ if (r.length === 0 || r.length > 8) throw Error("decision: questions must hold 1..8 entries");
14
+ for (let [e, t] of Object.entries(n)) {
15
+ if (!t || typeof t != "object") throw Error(`decision: question "${e}" must be an object`);
16
+ if (t.type !== "noul" && t.type !== "choice" && t.type !== "score") throw Error(`decision: question "${e}" has unknown type ${JSON.stringify(t.type)}`);
17
+ if (typeof t.instructions != "string" || !t.instructions) throw Error(`decision: question "${e}" needs instructions`);
18
+ if (t.type === "choice") {
19
+ let n = t.criteria;
20
+ if (!n || typeof n != "object" || Array.isArray(n)) throw Error(`decision: question "${e}" needs criteria object`);
21
+ let r = Object.keys(n);
22
+ if (r.length < 2 || r.length > 64) throw Error(`decision: question "${e}" needs 2..64 options`);
23
+ for (let t of r.map((e) => n[e])) if (typeof t != "string") throw Error(`decision: question "${e}" criteria must be strings`);
24
+ }
25
+ if (t.type === "score") {
26
+ let n = t.criteria;
27
+ if (!Array.isArray(n) || n.length < 2 || n.length > 10) throw Error(`decision: question "${e}" needs 2..10 score levels`);
28
+ for (let t of n) if (typeof t != "string") throw Error(`decision: question "${e}" levels must be strings`);
29
+ }
30
+ }
31
+ let i = t.state ?? null;
32
+ if (i !== null && typeof i != "string") throw Error("decision: state must be a string or null");
33
+ if (typeof i == "string" && i.length > 2e4) throw Error(`decision: state exceeds ${a} characters`);
34
+ let o = t.imageUrls ?? [];
35
+ if (!Array.isArray(o) || o.length > 8) throw Error("decision: imageUrls must hold 0..8 URLs");
36
+ for (let e of o) if (typeof e != "string" || !e.startsWith("https://")) throw Error("decision: imageUrls must be https:// URLs");
37
+ let s = t.audioUrl;
38
+ if (s !== void 0 && (typeof s != "string" || !s.startsWith("https://"))) throw Error("decision: audioUrl must be an https:// URL");
39
+ if (o.length > 0 && s) throw Error("decision: pass images or audio in one call, not both");
40
+ if ((i === null || i === "") && o.length === 0 && !s) throw Error("decision: null state needs at least one image or an audio clip");
41
+ return {
42
+ state: i,
43
+ questions: n,
44
+ imageUrls: [...o],
45
+ audioUrl: s
46
+ };
47
+ }
48
+ async function p(e) {
49
+ if (l) return l;
50
+ if (u) return u;
51
+ let n = performance.now();
52
+ return u = (async () => {
53
+ let r = t(e);
54
+ if (r.repo !== "LiquidAI/d1-omni-600M") throw Error(`decision: model ${e} is not a d1-omni decision model`);
55
+ let { AutoModel: i, env: a } = await import("./transformers.web.js").then((e) => e.i);
56
+ a?.backends?.onnx?.wasm && (a.backends.onnx.wasm.numThreads = 1, a.backends.onnx.wasm.proxy = !1);
57
+ let o = await i.from_pretrained(r.repo, {
58
+ trust_remote_code: !0,
59
+ dtype: "q8",
60
+ revision: r.revision
61
+ });
62
+ return l = o, console.log(`[flaxia-node] decision: model ready model=${r.repo} revision=${r.revision} loadMs=${Math.round(performance.now() - n)}`), o;
63
+ })().catch((e) => {
64
+ throw u = null, console.error(`[flaxia-node] decision: model load FAILED error=${e instanceof Error ? e.message : String(e)}`), e;
65
+ }), u;
66
+ }
67
+ function m(e) {
68
+ let t = {};
69
+ if (typeof e != "object" || !e) return t;
70
+ typeof e.noul == "number" && (t.noul = e.noul), typeof e.choice == "string" && (t.choice = e.choice), typeof e.confidence == "number" && (t.confidence = e.confidence), typeof e.score == "number" && (t.score = e.score);
71
+ let n = e.probabilities ?? e.probs;
72
+ if (n && typeof n == "object" && !Array.isArray(n)) {
73
+ let e = {};
74
+ for (let [t, r] of Object.entries(n)) typeof t == "string" && typeof r == "number" && Number.isFinite(r) && (e[t] = r);
75
+ Object.keys(e).length > 0 && (t.probabilities = e);
76
+ }
77
+ if (Array.isArray(e.levelProbabilities)) {
78
+ let n = e.levelProbabilities.filter((e) => typeof e == "number" && Number.isFinite(e));
79
+ n.length > 0 && (t.levelProbabilities = n);
80
+ }
81
+ if (Array.isArray(e.legend)) {
82
+ let n = e.legend.filter((e) => typeof e == "string");
83
+ n.length > 0 && (t.legend = n);
84
+ }
85
+ return t;
86
+ }
87
+ async function h(t) {
88
+ let a = performance.now();
89
+ if (t.model !== n) throw Error(`decision: model must be ${n} for decision payloads, got ${JSON.stringify(t.model)}`);
90
+ let { state: l, questions: u, imageUrls: d, audioUrl: h } = f(t), g = await p(t.model), _;
91
+ if (d.length > 0) {
92
+ let { loadImage: t } = await import("./transformers.web.js").then((e) => e.i);
93
+ _ = [];
94
+ for (let n of d) {
95
+ let r = await e({
96
+ url: n,
97
+ allowContentTypes: ["image/*", "application/octet-stream"],
98
+ maxBytes: o,
99
+ timeoutMs: c
100
+ });
101
+ if (!r.ok) throw Error(`decision: image fetch failed (${r.status}): ${n}`);
102
+ let i = new Blob([r.bytes], { type: r.contentType || "application/octet-stream" }), a = URL.createObjectURL(i);
103
+ try {
104
+ _.push(await t(a));
105
+ } finally {
106
+ URL.revokeObjectURL(a);
107
+ }
108
+ }
109
+ }
110
+ let v;
111
+ if (h) {
112
+ let t = await e({
113
+ url: h,
114
+ allowContentTypes: ["audio/*", "application/octet-stream"],
115
+ maxBytes: s,
116
+ timeoutMs: c
117
+ });
118
+ if (!t.ok) throw Error(`decision: audio fetch failed (${t.status}): ${h}`);
119
+ let n = t.bytes.buffer.slice(t.bytes.byteOffset, t.bytes.byteOffset + t.bytes.byteLength), a = globalThis.OfflineAudioContext ?? globalThis.webkitOfflineAudioContext;
120
+ if (a) {
121
+ let e = (await new a(1, r * 30, r).decodeAudioData(n.slice(0))).getChannelData(0), t = Math.min(e.length, i), o = new Float32Array(t);
122
+ o.set(e.subarray(0, t)), v = o;
123
+ } else {
124
+ let e = new Int16Array(n.slice(0));
125
+ v = e.subarray(0, Math.min(e.length, i));
126
+ }
127
+ }
128
+ let y = g.system_one(l, u, {
129
+ images: _?.length ? _ : void 0,
130
+ audio: v
131
+ }), b = Math.round(performance.now() - a), x = {}, S = y?.answers ?? {};
132
+ for (let [e, t] of Object.entries(S)) x[e] = m(t);
133
+ let C = typeof y?.usage?.input_tokens == "number" ? y.usage.input_tokens : void 0;
134
+ return console.log(`[flaxia-node] decision: done questions=${Object.keys(x).length} durationMs=${b}`), {
135
+ output: y,
136
+ answers: x,
137
+ inputTokens: C,
138
+ durationMs: b
139
+ };
140
+ }
141
+ //#endregion
142
+ export { h as handleDecision, d as releaseCache };
@@ -0,0 +1,97 @@
1
+ import { G as e, H as t, R as n, W as r, j as i } from "./webgpuProbe.js";
2
+ import { o as a } from "./ai-model-registry.js";
3
+ var o = null, s = () => {
4
+ o = null;
5
+ }, c = !1;
6
+ function l(e, t) {
7
+ if (c) return;
8
+ c = !0;
9
+ let n = typeof e.fetch == "function" ? e.fetch.bind(e) : globalThis.fetch.bind(globalThis);
10
+ e.fetch = async (e, r) => {
11
+ let i = new URL(String(e));
12
+ if (!/(^|\.)huggingface\.co$/.test(i.hostname) && !/(^|\.)hf\.co$/.test(i.hostname)) throw Error(`embed-gemma: model download blocked from ${i.hostname}`);
13
+ let a = await n(i, r), o = Number(a.headers.get("content-length"));
14
+ if (Number.isFinite(o) && o > t) throw Error(`embed-gemma: model file too large (${o} bytes > ${t})`);
15
+ return a;
16
+ };
17
+ }
18
+ function u(e) {
19
+ throw Error(`embed-gemma: ${e}`);
20
+ }
21
+ function d(n) {
22
+ (!n || typeof n != "object" || Array.isArray(n)) && u("payload must be an object");
23
+ let r = n.texts;
24
+ (!Array.isArray(r) || r.length === 0 || r.length > 32) && u("texts must contain 1..32 strings");
25
+ let a = 0;
26
+ for (let e of r) (typeof e != "string" || e.length === 0) && u("each text must be a non-empty string"), e.length > 4e3 && u(`each text must be at most ${i} characters`), a += e.length;
27
+ a > 1e5 && u(`texts exceed ${e} characters in total`);
28
+ let o = n.dimensions ?? 768;
29
+ return t(o) || u("dimensions must be one of 768, 512, 256, 128"), {
30
+ texts: r,
31
+ dimensions: o
32
+ };
33
+ }
34
+ function f() {
35
+ return typeof navigator < "u" && !!navigator.gpu;
36
+ }
37
+ async function p(e) {
38
+ let t = performance.now(), n = e === "webgpu" ? "q8" : "fp16", i = a(r);
39
+ console.log(`[flaxia-node] embed-gemma: loading model=${i.repo} revision=${i.revision} device=${e} dtype=${n}`);
40
+ let { AutoConfig: o, AutoModel: s, AutoProcessor: c, env: u } = await import("./transformers.web.js").then((e) => e.i);
41
+ u?.backends?.onnx?.wasm && (u.backends.onnx.wasm.numThreads = 1, u.backends.onnx.wasm.proxy = !1), l(u, i.maxBytes);
42
+ let d = await o.from_pretrained(i.repo, { revision: i.revision });
43
+ d.vision_config = null, d.audio_config = null;
44
+ let [f, p] = await Promise.all([c.from_pretrained(i.repo, { revision: i.revision }), s.from_pretrained(i.repo, {
45
+ config: d,
46
+ device: e,
47
+ dtype: n,
48
+ revision: i.revision
49
+ })]);
50
+ return console.log(`[flaxia-node] embed-gemma: model ready device=${e} dtype=${n} loadMs=${Math.round(performance.now() - t)}`), {
51
+ processor: f,
52
+ model: p,
53
+ device: e,
54
+ dtype: n
55
+ };
56
+ }
57
+ async function m() {
58
+ if (o) return o;
59
+ if (f()) try {
60
+ return o = await p("webgpu"), o;
61
+ } catch (e) {
62
+ console.warn(`[flaxia-node] embed-gemma: WebGPU load failed, falling back to WASM fp16: ${e instanceof Error ? e.message : String(e)}`);
63
+ }
64
+ return o = await p("wasm"), o;
65
+ }
66
+ function h(e, t) {
67
+ let n = e.slice(0, t), r = 0;
68
+ for (let e of n) r += e * e;
69
+ return r = Math.sqrt(r), r === 0 ? n : n.map((e) => e / r);
70
+ }
71
+ async function g(e, t, n) {
72
+ let r = await e.processor(t), i = (await e.model(r))?.sentence_embedding;
73
+ if (!i || !i.data) throw Error("embed-gemma: model did not return sentence_embedding");
74
+ let a = Array.from(i.data), o = t.length * 768;
75
+ if (a.length !== o) throw Error(`embed-gemma: expected ${o} embedding values, received ${a.length}`);
76
+ let s = [];
77
+ for (let e = 0; e < t.length; e += 1) {
78
+ let t = e * 768, r = a.slice(t, t + 768);
79
+ s.push(h(r, n));
80
+ }
81
+ return s;
82
+ }
83
+ async function _(e, t) {
84
+ let r = performance.now(), { texts: i, dimensions: a } = d(e), o = await m(), s = [];
85
+ for (let e = 0; e < i.length; e += 4) {
86
+ let n = i.slice(e, e + 4);
87
+ s.push(...await g(o, n, a)), await t?.();
88
+ }
89
+ return {
90
+ vectors: s,
91
+ model: n,
92
+ dimensions: a,
93
+ durationMs: Math.round(performance.now() - r)
94
+ };
95
+ }
96
+ //#endregion
97
+ export { _ as handleEmbedGemma, s as releaseCache };
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/dist/assets/transformers.web.js
3
- size: 63528578 bytes
4
- sha256: c4ea4c2cc11efabbcbd71ff8631ac3d08593a8cde1a4a2a64518ac81f837f4b0
3
+ size: 72351437 bytes
4
+ sha256: be4428c1a4f24bc4a1e71b3f4879d730cc560e68d30e19b7e34f209e3569bd53
@@ -1,31 +1,141 @@
1
+ import { n as e } from "./egress-guard.js";
2
+ import { o as t } from "./ai-model-registry.js";
1
3
  //#region src/workloads/vector-embed.ts
2
- var e = null, t = () => {
3
- e = null;
4
- };
5
- async function n(t) {
6
- let n = performance.now();
7
- if (!e) {
8
- let t = performance.now();
9
- console.log("[flaxia-node] vector-embed: loading pipeline model=onnx-community/Qwen3-Embedding-0.6B-ONNX device=wasm");
10
- let { pipeline: n, env: r } = await import("./transformers.web.js").then((e) => e.i);
11
- r?.backends?.onnx?.wasm && (r.backends.onnx.wasm.numThreads = 1, r.backends.onnx.wasm.proxy = !1);
12
- try {
13
- e = await n("feature-extraction", "onnx-community/Qwen3-Embedding-0.6B-ONNX", { device: "wasm" });
14
- } catch (e) {
15
- throw console.error(`[flaxia-node] vector-embed: pipeline load FAILED error=${e instanceof Error ? e.message : String(e)}`), e;
16
- }
17
- console.log(`[flaxia-node] vector-embed: pipeline ready loadMs=${Math.round(performance.now() - t)}`);
4
+ var n = "onnx-community/embeddinggemma-2-ONNX", r = 768, i = 16e3, a = 5 * 1024 * 1024, o = 25 * 1024 * 1024, s = 50 * 1024 * 1024, c = 3e4, l = 1e5, u = null, d = null, f = () => {
5
+ u = null, d = null;
6
+ }, p = !1;
7
+ function m(e, t) {
8
+ if (p) return;
9
+ p = !0;
10
+ let n = typeof e.fetch == "function" ? e.fetch.bind(e) : globalThis.fetch.bind(globalThis);
11
+ e.fetch = async (e, r) => {
12
+ let i = new URL(String(e));
13
+ if (!/(^|\.)huggingface\.co$/.test(i.hostname) && !/(^|\.)hf\.co$/.test(i.hostname)) throw Error(`vector-embed: model download blocked from ${i.hostname}`);
14
+ let a = await n(i, r), o = Number(a.headers.get("content-length"));
15
+ if (Number.isFinite(o) && o > t) throw Error(`vector-embed: model file too large (${o} bytes > ${t})`);
16
+ return a;
17
+ };
18
+ }
19
+ async function h() {
20
+ if (u) return u;
21
+ if (d) return d;
22
+ let e = performance.now();
23
+ return d = (async () => {
24
+ let r = t(n);
25
+ console.log(`[flaxia-node] vector-embed: loading model=${r.repo} revision=${r.revision} device=wasm dtype=fp16`);
26
+ let { AutoModel: i, AutoProcessor: a, env: o } = await import("./transformers.web.js").then((e) => e.i);
27
+ o?.backends?.onnx?.wasm && (o.backends.onnx.wasm.numThreads = 1, o.backends.onnx.wasm.proxy = !1), m(o, r.maxBytes);
28
+ let [s, c] = await Promise.all([a.from_pretrained(r.repo, { revision: r.revision }), i.from_pretrained(r.repo, {
29
+ device: "wasm",
30
+ dtype: "fp16",
31
+ revision: r.revision
32
+ })]), l = {
33
+ processor: s,
34
+ model: c
35
+ };
36
+ return u = l, console.log(`[flaxia-node] vector-embed: model ready loadMs=${Math.round(performance.now() - e)}`), l;
37
+ })().catch((e) => {
38
+ throw d = null, console.error(`[flaxia-node] vector-embed: model load FAILED error=${e instanceof Error ? e.message : String(e)}`), e;
39
+ }), d;
40
+ }
41
+ function g(e) {
42
+ let t = typeof e.text == "string" ? e.text : "";
43
+ if (t.length > l) throw Error(`vector-embed: text exceeds ${l} characters`);
44
+ let n = e.imageUrls ?? [];
45
+ if (!Array.isArray(n) || n.length > 29) throw Error("vector-embed: imageUrls must hold 0..29 URLs");
46
+ for (let e of n) if (typeof e != "string" || !e.startsWith("https://")) throw Error("vector-embed: imageUrls must be https:// URLs");
47
+ let r = e.audioUrl;
48
+ if (r !== void 0 && (typeof r != "string" || !r.startsWith("https://"))) throw Error("vector-embed: audioUrl must be an https:// URL");
49
+ let i = e.videoUrl;
50
+ if (i !== void 0 && (typeof i != "string" || !i.startsWith("https://"))) throw Error("vector-embed: videoUrl must be an https:// URL");
51
+ if (!t && n.length === 0 && !r && !i) throw Error("vector-embed: need at least text or one media URL");
52
+ return {
53
+ text: t,
54
+ imageUrls: [...n],
55
+ audioUrl: r,
56
+ videoUrl: i
57
+ };
58
+ }
59
+ function _(e, t) {
60
+ let n = e, r = (e) => n.split(e).length - 1;
61
+ return t.images > r("<|image|>") && (n += " <|image|>".repeat(t.images - r("<|image|>"))), t.videos > r("<|video|>") && (n += " <|video|>".repeat(t.videos - r("<|video|>"))), t.audio > r("<|audio|>") && (n += " <|audio|>".repeat(t.audio - r("<|audio|>"))), n;
62
+ }
63
+ async function v(t) {
64
+ let n = await e({
65
+ url: t,
66
+ allowContentTypes: ["image/*", "application/octet-stream"],
67
+ maxBytes: a,
68
+ timeoutMs: c
69
+ });
70
+ if (!n.ok) throw Error(`vector-embed: image fetch failed (${n.status}): ${t}`);
71
+ let r = new Blob([n.bytes], { type: n.contentType || "application/octet-stream" }), i = URL.createObjectURL(r);
72
+ try {
73
+ let { loadImage: e } = await import("./transformers.web.js").then((e) => e.i);
74
+ return await e(i);
75
+ } finally {
76
+ URL.revokeObjectURL(i);
77
+ }
78
+ }
79
+ async function y(t) {
80
+ let n = await e({
81
+ url: t,
82
+ allowContentTypes: ["audio/*", "application/octet-stream"],
83
+ maxBytes: o,
84
+ timeoutMs: c
85
+ });
86
+ if (!n.ok) throw Error(`vector-embed: audio fetch failed (${n.status}): ${t}`);
87
+ let r = new Blob([n.bytes], { type: n.contentType || "application/octet-stream" }), a = URL.createObjectURL(r);
88
+ try {
89
+ let { loadAudio: e } = await import("./transformers.web.js").then((e) => e.i);
90
+ return await e(a, i);
91
+ } finally {
92
+ URL.revokeObjectURL(a);
93
+ }
94
+ }
95
+ async function b(t) {
96
+ let n = await e({
97
+ url: t,
98
+ allowContentTypes: ["video/*", "application/octet-stream"],
99
+ maxBytes: s,
100
+ timeoutMs: c
101
+ });
102
+ if (!n.ok) throw Error(`vector-embed: video fetch failed (${n.status}): ${t}`);
103
+ let r = new Blob([n.bytes], { type: n.contentType || "application/octet-stream" }), i = URL.createObjectURL(r);
104
+ try {
105
+ let { loadVideo: e } = await import("./transformers.web.js").then((e) => e.i);
106
+ return await e(i, { fps: 1 });
107
+ } finally {
108
+ URL.revokeObjectURL(i);
109
+ }
110
+ }
111
+ async function x(e) {
112
+ let t = performance.now(), { text: i, imageUrls: a, audioUrl: o, videoUrl: s } = g(e), c = await h(), l = performance.now();
113
+ if (!(a.length > 0 || o || s)) {
114
+ let e = await c.processor(i), a = (await c.model(e))?.sentence_embedding;
115
+ if (!a || !a.data) throw Error("vector-embed: model did not return sentence_embedding");
116
+ let o = Array.from(a.data), s = Math.round(performance.now() - t);
117
+ return console.log(`[flaxia-node] vector-embed: done dims=${o.length} modelMs=${Math.round(performance.now() - l)} totalMs=${s} textLen=${i.length}`), {
118
+ vector: o,
119
+ model: n,
120
+ dimensions: r,
121
+ durationMs: s
122
+ };
18
123
  }
19
- let r = performance.now(), i = await e(t.text, {
20
- pooling: "mean",
21
- normalize: !0
22
- }), a = Array.from(i.data), o = performance.now() - n;
23
- return console.log(`[flaxia-node] vector-embed: done dims=${a.length} modelMs=${Math.round(performance.now() - r)} totalMs=${Math.round(o)} textLen=${t.text.length}`), {
24
- vector: a,
25
- model: "Qwen/Qwen3-Embedding-0.6B",
26
- dimensions: 1024,
27
- durationMs: Math.round(o)
124
+ let u = [];
125
+ for (let e of a) u.push(await v(e));
126
+ let d = o ? await y(o) : null, f = s ? await b(s) : null, p = _(i || " ", {
127
+ images: u.length,
128
+ videos: +!!f,
129
+ audio: +!!d
130
+ }), m = u.length === 0 ? null : u.length === 1 ? u[0] : u, x = await c.processor(p, m, d, f), S = (await c.model(x))?.sentence_embedding;
131
+ if (!S || !S.data) throw Error("vector-embed: model did not return sentence_embedding");
132
+ let C = Array.from(S.data), w = Math.round(performance.now() - t);
133
+ return console.log(`[flaxia-node] vector-embed: done dims=${C.length} modelMs=${Math.round(performance.now() - l)} totalMs=${w} textLen=${i.length} images=${a.length} audio=${+!!o} video=${+!!s}`), {
134
+ vector: C,
135
+ model: n,
136
+ dimensions: r,
137
+ durationMs: w
28
138
  };
29
139
  }
30
140
  //#endregion
31
- export { n as handleVectorEmbed, t as releaseCache };
141
+ export { x as handleVectorEmbed, f as releaseCache };