@nodetool-ai/transformers-js-nodes 0.7.0-rc.11

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 (93) hide show
  1. package/dist/cache-scan.d.ts +26 -0
  2. package/dist/cache-scan.d.ts.map +1 -0
  3. package/dist/cache-scan.js +112 -0
  4. package/dist/cache-scan.js.map +1 -0
  5. package/dist/index.d.ts +28 -0
  6. package/dist/index.d.ts.map +1 -0
  7. package/dist/index.js +62 -0
  8. package/dist/index.js.map +1 -0
  9. package/dist/nodes/audio-classification.d.ts +22 -0
  10. package/dist/nodes/audio-classification.d.ts.map +1 -0
  11. package/dist/nodes/audio-classification.js +102 -0
  12. package/dist/nodes/audio-classification.js.map +1 -0
  13. package/dist/nodes/automatic-speech-recognition.d.ts +22 -0
  14. package/dist/nodes/automatic-speech-recognition.d.ts.map +1 -0
  15. package/dist/nodes/automatic-speech-recognition.js +129 -0
  16. package/dist/nodes/automatic-speech-recognition.js.map +1 -0
  17. package/dist/nodes/feature-extraction.d.ts +20 -0
  18. package/dist/nodes/feature-extraction.d.ts.map +1 -0
  19. package/dist/nodes/feature-extraction.js +153 -0
  20. package/dist/nodes/feature-extraction.js.map +1 -0
  21. package/dist/nodes/fill-mask.d.ts +19 -0
  22. package/dist/nodes/fill-mask.d.ts.map +1 -0
  23. package/dist/nodes/fill-mask.js +87 -0
  24. package/dist/nodes/fill-mask.js.map +1 -0
  25. package/dist/nodes/image-classification.d.ts +21 -0
  26. package/dist/nodes/image-classification.d.ts.map +1 -0
  27. package/dist/nodes/image-classification.js +90 -0
  28. package/dist/nodes/image-classification.js.map +1 -0
  29. package/dist/nodes/image-to-text.d.ts +19 -0
  30. package/dist/nodes/image-to-text.d.ts.map +1 -0
  31. package/dist/nodes/image-to-text.js +81 -0
  32. package/dist/nodes/image-to-text.js.map +1 -0
  33. package/dist/nodes/object-detection.d.ts +20 -0
  34. package/dist/nodes/object-detection.d.ts.map +1 -0
  35. package/dist/nodes/object-detection.js +93 -0
  36. package/dist/nodes/object-detection.js.map +1 -0
  37. package/dist/nodes/question-answering.d.ts +23 -0
  38. package/dist/nodes/question-answering.d.ts.map +1 -0
  39. package/dist/nodes/question-answering.js +108 -0
  40. package/dist/nodes/question-answering.js.map +1 -0
  41. package/dist/nodes/summarization.d.ts +20 -0
  42. package/dist/nodes/summarization.d.ts.map +1 -0
  43. package/dist/nodes/summarization.js +103 -0
  44. package/dist/nodes/summarization.js.map +1 -0
  45. package/dist/nodes/text-classification.d.ts +20 -0
  46. package/dist/nodes/text-classification.d.ts.map +1 -0
  47. package/dist/nodes/text-classification.js +93 -0
  48. package/dist/nodes/text-classification.js.map +1 -0
  49. package/dist/nodes/text-generation.d.ts +23 -0
  50. package/dist/nodes/text-generation.d.ts.map +1 -0
  51. package/dist/nodes/text-generation.js +150 -0
  52. package/dist/nodes/text-generation.js.map +1 -0
  53. package/dist/nodes/text-to-speech.d.ts +20 -0
  54. package/dist/nodes/text-to-speech.d.ts.map +1 -0
  55. package/dist/nodes/text-to-speech.js +122 -0
  56. package/dist/nodes/text-to-speech.js.map +1 -0
  57. package/dist/nodes/token-classification.d.ts +18 -0
  58. package/dist/nodes/token-classification.d.ts.map +1 -0
  59. package/dist/nodes/token-classification.js +88 -0
  60. package/dist/nodes/token-classification.js.map +1 -0
  61. package/dist/nodes/translation.d.ts +20 -0
  62. package/dist/nodes/translation.d.ts.map +1 -0
  63. package/dist/nodes/translation.js +106 -0
  64. package/dist/nodes/translation.js.map +1 -0
  65. package/dist/nodes/zero-shot-classification.d.ts +23 -0
  66. package/dist/nodes/zero-shot-classification.d.ts.map +1 -0
  67. package/dist/nodes/zero-shot-classification.js +128 -0
  68. package/dist/nodes/zero-shot-classification.js.map +1 -0
  69. package/dist/nodes/zero-shot-image-classification.d.ts +21 -0
  70. package/dist/nodes/zero-shot-image-classification.d.ts.map +1 -0
  71. package/dist/nodes/zero-shot-image-classification.js +101 -0
  72. package/dist/nodes/zero-shot-image-classification.js.map +1 -0
  73. package/dist/recommended-models.d.ts +32 -0
  74. package/dist/recommended-models.d.ts.map +1 -0
  75. package/dist/recommended-models.js +140 -0
  76. package/dist/recommended-models.js.map +1 -0
  77. package/dist/tjs-downloader.d.ts +44 -0
  78. package/dist/tjs-downloader.d.ts.map +1 -0
  79. package/dist/tjs-downloader.js +84 -0
  80. package/dist/tjs-downloader.js.map +1 -0
  81. package/dist/transformers-base.d.ts +156 -0
  82. package/dist/transformers-base.d.ts.map +1 -0
  83. package/dist/transformers-base.js +435 -0
  84. package/dist/transformers-base.js.map +1 -0
  85. package/dist/tts-shared.d.ts +16 -0
  86. package/dist/tts-shared.d.ts.map +1 -0
  87. package/dist/tts-shared.js +51 -0
  88. package/dist/tts-shared.js.map +1 -0
  89. package/dist/wav.d.ts +23 -0
  90. package/dist/wav.d.ts.map +1 -0
  91. package/dist/wav.js +115 -0
  92. package/dist/wav.js.map +1 -0
  93. package/package.json +50 -0
@@ -0,0 +1,122 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { BaseNode, prop } from "@nodetool-ai/node-sdk";
8
+ import { DEVICE_VALUES, DTYPE_VALUES, asString, extractRepoId, getPipeline, tjsModelDefault, normalizeOption } from "../transformers-base.js";
9
+ import { defaultRepoFor } from "../recommended-models.js";
10
+ import { encodeWav } from "../wav.js";
11
+ import { KOKORO_VOICES, getKokoro, isKokoroRepo, isSpeechT5Repo } from "../tts-shared.js";
12
+ const TJS_TYPE = "tjs.text_to_speech";
13
+ export class TextToSpeechNode extends BaseNode {
14
+ static nodeType = "transformers.TextToSpeech";
15
+ static title = "Text to Speech";
16
+ static description = "Synthesize speech from text using a Transformers.js text-to-speech pipeline.\n" +
17
+ "audio, tts, speech, transformers, huggingface\n\n" +
18
+ "Use cases:\n" +
19
+ "- Add voice output to local agents\n" +
20
+ "- Generate narration without an external API\n" +
21
+ "- Build accessible interfaces";
22
+ static metadataOutputTypes = { output: "audio" };
23
+ static autoSaveAsset = true;
24
+ async process() {
25
+ const text = asString(this.text);
26
+ if (!text)
27
+ throw new Error("Text is required");
28
+ const repoId = extractRepoId(this.model) || undefined;
29
+ const dtype = normalizeOption(this.dtype);
30
+ const device = normalizeOption(this.device);
31
+ let samples;
32
+ let samplingRate = 16000;
33
+ if (isKokoroRepo(repoId)) {
34
+ const tts = await getKokoro(repoId, dtype, device);
35
+ const voice = asString(this.voice) || "af_heart";
36
+ const result = await tts.generate(text, { voice: voice });
37
+ samples = result.audio;
38
+ samplingRate = result.sampling_rate ?? samplingRate;
39
+ }
40
+ else {
41
+ const pipeline = (await getPipeline({
42
+ task: "text-to-speech",
43
+ model: repoId,
44
+ dtype,
45
+ device
46
+ }));
47
+ const opts = {};
48
+ if (isSpeechT5Repo(repoId)) {
49
+ const speakerEmbeddings = asString(this.speaker_embeddings);
50
+ if (speakerEmbeddings)
51
+ opts.speaker_embeddings = speakerEmbeddings;
52
+ }
53
+ const result = await pipeline(text, opts);
54
+ samples = result?.audio;
55
+ samplingRate = result?.sampling_rate ?? samplingRate;
56
+ }
57
+ if (!samples) {
58
+ throw new Error("Text-to-speech pipeline returned no audio data");
59
+ }
60
+ const wav = encodeWav(samples, samplingRate);
61
+ return {
62
+ output: {
63
+ type: "audio",
64
+ data: wav.toString("base64"),
65
+ content_type: "audio/wav"
66
+ }
67
+ };
68
+ }
69
+ }
70
+ __decorate([
71
+ prop({
72
+ type: "str",
73
+ default: "Hello, this is a test of text to speech.",
74
+ title: "Text",
75
+ description: "Text to synthesize."
76
+ })
77
+ ], TextToSpeechNode.prototype, "text", void 0);
78
+ __decorate([
79
+ prop({
80
+ type: TJS_TYPE,
81
+ default: tjsModelDefault(TJS_TYPE, defaultRepoFor(TJS_TYPE)),
82
+ title: "Model",
83
+ description: "Transformers.js model (ONNX-compatible)."
84
+ })
85
+ ], TextToSpeechNode.prototype, "model", void 0);
86
+ __decorate([
87
+ prop({
88
+ type: "str",
89
+ default: "https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/speaker_embeddings.bin",
90
+ title: "Speaker Embedding URL",
91
+ description: "Optional speaker embedding URL (required by SpeechT5; ignored by other models)."
92
+ })
93
+ ], TextToSpeechNode.prototype, "speaker_embeddings", void 0);
94
+ __decorate([
95
+ prop({
96
+ type: "enum",
97
+ default: "af_heart",
98
+ title: "Voice",
99
+ description: "Voice ID for Kokoro models (English only in kokoro-js v1.2.x). af_*=American female, am_*=American male, bf_*=British female, bm_*=British male. Ignored by other TTS models.",
100
+ values: [...KOKORO_VOICES]
101
+ })
102
+ ], TextToSpeechNode.prototype, "voice", void 0);
103
+ __decorate([
104
+ prop({
105
+ type: "enum",
106
+ default: "auto",
107
+ title: "Quantization",
108
+ description: "Model dtype / quantization level.",
109
+ values: DTYPE_VALUES
110
+ })
111
+ ], TextToSpeechNode.prototype, "dtype", void 0);
112
+ __decorate([
113
+ prop({
114
+ type: "enum",
115
+ default: "auto",
116
+ title: "Device",
117
+ description: "Inference device.",
118
+ values: DEVICE_VALUES
119
+ })
120
+ ], TextToSpeechNode.prototype, "device", void 0);
121
+ export const TEXT_TO_SPEECH_NODES = [TextToSpeechNode];
122
+ //# sourceMappingURL=text-to-speech.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text-to-speech.js","sourceRoot":"","sources":["../../src/nodes/text-to-speech.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,EACL,aAAa,EACb,YAAY,EACZ,QAAQ,EACR,aAA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IAAI,EAAE,KAAK;QACX,OAAO,EAAE,0CAA0C;QACnD,KAAK,EAAE,MAAM;QACb,WAAW,EAAE,qBAAqB;KACnC,CAAC;8CACgB;AAQV;IANP,IAAI,CAAC;QACJ,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,eAAe,CAAC,QAAQ,EAAE,cAAc,CAAC,QAAQ,CAAC,CAAC;QAC5D,KAAK,EAAE,OAAO;QACd,WAAW,EAAE,0CAA0C;KACxD,CAAC;+CACiB;AAUX;IARP,IAAI,CAAC;QACJ,IAAI,EAAE,KAAK;QACX,OAAO,EACL,iGAAiG;QACnG,KAAK,EAAE,uBAAuB;QAC9B,WAAW,EACT,iFAAiF;KACpF,CAAC;4DAC8B;AAUxB;IARP,IAAI,CAAC;QACJ,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,UAAU;QACnB,KAAK,EAAE,OAAO;QACd,WAAW,EACT,+KAA+K;QACjL,MAAM,EAAE,CAAC,GAAG,aAAa,CAAC;KAC3B,CAAC;+CACiB;AASX;IAPP,IAAI,CAAC;QACJ,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,MAAM;QACf,KAAK,EAAE,cAAc;QACrB,WAAW,EAAE,mCAAmC;QAChD,MAAM,EAAE,YAAY;KACrB,CAAC;+CACiB;AASX;IAPP,IAAI,CAAC;QACJ,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,MAAM;QACf,KAAK,EAAE,QAAQ;QACf,WAAW,EAAE,mBAAmB;QAChC,MAAM,EAAE,aAAa;KACtB,CAAC;gDACkB;AAwDtB,MAAM,CAAC,MAAM,oBAAoB,GAAyB,CAAC,gBAAgB,CAAC,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { BaseNode } from "@nodetool-ai/node-sdk";
2
+ import type { NodeClass } from "@nodetool-ai/node-sdk";
3
+ export declare class TokenClassificationNode extends BaseNode {
4
+ static readonly nodeType = "transformers.TokenClassification";
5
+ static readonly title = "Token Classification (NER)";
6
+ static readonly description: string;
7
+ static readonly metadataOutputTypes: {
8
+ entities: string;
9
+ };
10
+ text: any;
11
+ model: any;
12
+ aggregation_strategy: any;
13
+ dtype: any;
14
+ device: any;
15
+ process(): Promise<Record<string, unknown>>;
16
+ }
17
+ export declare const TOKEN_CLASSIFICATION_NODES: readonly NodeClass[];
18
+ //# sourceMappingURL=token-classification.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token-classification.d.ts","sourceRoot":"","sources":["../../src/nodes/token-classification.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAQ,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAwBvD,qBAAa,uBAAwB,SAAQ,QAAQ;IACnD,MAAM,CAAC,QAAQ,CAAC,QAAQ,sCAAsC;IAC9D,MAAM,CAAC,QAAQ,CAAC,KAAK,gCAAgC;IACrD,MAAM,CAAC,QAAQ,CAAC,WAAW,SAMyB;IACpD,MAAM,CAAC,QAAQ,CAAC,mBAAmB;;MAEjC;IAQM,IAAI,EAAE,GAAG,CAAC;IAQV,KAAK,EAAE,GAAG,CAAC;IASX,oBAAoB,EAAE,GAAG,CAAC;IAS1B,KAAK,EAAE,GAAG,CAAC;IASX,MAAM,EAAE,GAAG,CAAC;IAEd,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAuBlD;AAED,eAAO,MAAM,0BAA0B,EAAE,SAAS,SAAS,EAE1D,CAAC"}
@@ -0,0 +1,88 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { BaseNode, prop } from "@nodetool-ai/node-sdk";
8
+ import { DEVICE_VALUES, DTYPE_VALUES, asString, ensureArray, extractRepoId, getPipeline, tjsModelDefault, normalizeOption } from "../transformers-base.js";
9
+ import { defaultRepoFor } from "../recommended-models.js";
10
+ const TJS_TYPE = "tjs.token_classification";
11
+ export class TokenClassificationNode extends BaseNode {
12
+ static nodeType = "transformers.TokenClassification";
13
+ static title = "Token Classification (NER)";
14
+ static description = "Run named-entity recognition or token-tagging via a Transformers.js token-classification pipeline.\n" +
15
+ "nlp, ner, tokens, entities, transformers, huggingface\n\n" +
16
+ "Use cases:\n" +
17
+ "- Extract names, locations and organizations\n" +
18
+ "- Tag PII before storage or logging\n" +
19
+ "- Build knowledge graphs from unstructured text";
20
+ static metadataOutputTypes = {
21
+ entities: "list"
22
+ };
23
+ async process() {
24
+ const text = asString(this.text);
25
+ if (!text)
26
+ throw new Error("Text is required");
27
+ const pipeline = (await getPipeline({
28
+ task: "token-classification",
29
+ model: extractRepoId(this.model) || undefined,
30
+ dtype: normalizeOption(this.dtype),
31
+ device: normalizeOption(this.device)
32
+ }));
33
+ const opts = {};
34
+ const aggregation = asString(this.aggregation_strategy, "simple");
35
+ if (aggregation && aggregation !== "none") {
36
+ opts.aggregation_strategy = aggregation;
37
+ }
38
+ const raw = await pipeline(text, opts);
39
+ return { entities: ensureArray(raw) };
40
+ }
41
+ }
42
+ __decorate([
43
+ prop({
44
+ type: "str",
45
+ default: "My name is Sarah and I live in London.",
46
+ title: "Text",
47
+ description: "Text to extract entities from."
48
+ })
49
+ ], TokenClassificationNode.prototype, "text", void 0);
50
+ __decorate([
51
+ prop({
52
+ type: TJS_TYPE,
53
+ default: tjsModelDefault(TJS_TYPE, defaultRepoFor(TJS_TYPE)),
54
+ title: "Model",
55
+ description: "Transformers.js model (ONNX-compatible)."
56
+ })
57
+ ], TokenClassificationNode.prototype, "model", void 0);
58
+ __decorate([
59
+ prop({
60
+ type: "enum",
61
+ default: "simple",
62
+ title: "Aggregation Strategy",
63
+ description: "How to merge subword tokens into entity spans.",
64
+ values: ["none", "simple", "first", "average", "max"]
65
+ })
66
+ ], TokenClassificationNode.prototype, "aggregation_strategy", void 0);
67
+ __decorate([
68
+ prop({
69
+ type: "enum",
70
+ default: "auto",
71
+ title: "Quantization",
72
+ description: "Model dtype / quantization level.",
73
+ values: DTYPE_VALUES
74
+ })
75
+ ], TokenClassificationNode.prototype, "dtype", void 0);
76
+ __decorate([
77
+ prop({
78
+ type: "enum",
79
+ default: "auto",
80
+ title: "Device",
81
+ description: "Inference device.",
82
+ values: DEVICE_VALUES
83
+ })
84
+ ], TokenClassificationNode.prototype, "device", void 0);
85
+ export const TOKEN_CLASSIFICATION_NODES = [
86
+ TokenClassificationNode
87
+ ];
88
+ //# sourceMappingURL=token-classification.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token-classification.js","sourceRoot":"","sources":["../../src/nodes/token-classification.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,EACL,aAAa,EACb,YAAY,EACZ,QAAQ,EACR,WAAW,EACX,aAAa,EACb,WAAW,EACX,eAAe,EACf,eAAe,EAChB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1D,MAAM,QAAQ,GAAG,0BAA0B,CAAC;AAW5C,MAAM,OAAO,uBAAwB,SAAQ,QAAQ;IACnD,MAAM,CAAU,QAAQ,GAAG,kCAAkC,CAAC;IAC9D,MAAM,CAAU,KAAK,GAAG,4BAA4B,CAAC;IACrD,MAAM,CAAU,WAAW,GACzB,sGAAsG;QACtG,2DAA2D;QAC3D,cAAc;QACd,gDAAgD;QAChD,uCAAuC;QACvC,iDAAiD,CAAC;IACpD,MAAM,CAAU,mBAAmB,GAAG;QACpC,QAAQ,EAA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M;QACZ,OAAO,EAAE,QAAQ;QACjB,KAAK,EAAE,sBAAsB;QAC7B,WAAW,EAAE,gDAAgD;QAC7D,MAAM,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,CAAC;KACtD,CAAC;qEACgC;AAS1B;IAPP,IAAI,CAAC;QACJ,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,MAAM;QACf,KAAK,EAAE,cAAc;QACrB,WAAW,EAAE,mCAAmC;QAChD,MAAM,EAAE,YAAY;KACrB,CAAC;sDACiB;AASX;IAPP,IAAI,CAAC;QACJ,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,MAAM;QACf,KAAK,EAAE,QAAQ;QACf,WAAW,EAAE,mBAAmB;QAChC,MAAM,EAAE,aAAa;KACtB,CAAC;uDACkB;AA2BtB,MAAM,CAAC,MAAM,0BAA0B,GAAyB;IAC9D,uBAAuB;CACxB,CAAC"}
@@ -0,0 +1,20 @@
1
+ import { BaseNode } from "@nodetool-ai/node-sdk";
2
+ import type { NodeClass } from "@nodetool-ai/node-sdk";
3
+ export declare class TranslationNode extends BaseNode {
4
+ static readonly nodeType = "transformers.Translation";
5
+ static readonly title = "Translation";
6
+ static readonly description: string;
7
+ static readonly metadataOutputTypes: {
8
+ translation: string;
9
+ };
10
+ text: any;
11
+ model: any;
12
+ src_lang: any;
13
+ tgt_lang: any;
14
+ max_length: any;
15
+ dtype: any;
16
+ device: any;
17
+ process(): Promise<Record<string, unknown>>;
18
+ }
19
+ export declare const TRANSLATION_NODES: readonly NodeClass[];
20
+ //# sourceMappingURL=translation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"translation.d.ts","sourceRoot":"","sources":["../../src/nodes/translation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAQ,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAkBvD,qBAAa,eAAgB,SAAQ,QAAQ;IAC3C,MAAM,CAAC,QAAQ,CAAC,QAAQ,8BAA8B;IACtD,MAAM,CAAC,QAAQ,CAAC,KAAK,iBAAiB;IACtC,MAAM,CAAC,QAAQ,CAAC,WAAW,SAMqB;IAChD,MAAM,CAAC,QAAQ,CAAC,mBAAmB;;MAA0B;IAQrD,IAAI,EAAE,GAAG,CAAC;IAQV,KAAK,EAAE,GAAG,CAAC;IASX,QAAQ,EAAE,GAAG,CAAC;IAQd,QAAQ,EAAE,GAAG,CAAC;IAUd,UAAU,EAAE,GAAG,CAAC;IAShB,KAAK,EAAE,GAAG,CAAC;IASX,MAAM,EAAE,GAAG,CAAC;IAEd,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CA0BlD;AAED,eAAO,MAAM,iBAAiB,EAAE,SAAS,SAAS,EAAsB,CAAC"}
@@ -0,0 +1,106 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { BaseNode, prop } from "@nodetool-ai/node-sdk";
8
+ import { DEVICE_VALUES, DTYPE_VALUES, asNumber, asString, ensureArray, extractRepoId, getPipeline, tjsModelDefault, normalizeOption } from "../transformers-base.js";
9
+ import { defaultRepoFor } from "../recommended-models.js";
10
+ const TJS_TYPE = "tjs.translation";
11
+ export class TranslationNode extends BaseNode {
12
+ static nodeType = "transformers.Translation";
13
+ static title = "Translation";
14
+ static description = "Translate text between languages using a Transformers.js translation pipeline.\n" +
15
+ "nlp, translation, transformers, huggingface, multilingual\n\n" +
16
+ "Use cases:\n" +
17
+ "- Translate user content for localization\n" +
18
+ "- Build multilingual chat or search\n" +
19
+ "- Pre-process inputs for monolingual models";
20
+ static metadataOutputTypes = { translation: "str" };
21
+ async process() {
22
+ const text = asString(this.text);
23
+ if (!text)
24
+ throw new Error("Text is required");
25
+ const pipeline = (await getPipeline({
26
+ task: "translation",
27
+ model: extractRepoId(this.model) || undefined,
28
+ dtype: normalizeOption(this.dtype),
29
+ device: normalizeOption(this.device)
30
+ }));
31
+ const opts = {
32
+ max_length: asNumber(this.max_length, 256)
33
+ };
34
+ const srcLang = asString(this.src_lang);
35
+ const tgtLang = asString(this.tgt_lang);
36
+ if (srcLang)
37
+ opts.src_lang = srcLang;
38
+ if (tgtLang)
39
+ opts.tgt_lang = tgtLang;
40
+ const raw = await pipeline(text, opts);
41
+ const first = ensureArray(raw)[0];
42
+ return { translation: first?.translation_text ?? "" };
43
+ }
44
+ }
45
+ __decorate([
46
+ prop({
47
+ type: "str",
48
+ default: "Hello, how are you?",
49
+ title: "Text",
50
+ description: "Source text to translate."
51
+ })
52
+ ], TranslationNode.prototype, "text", void 0);
53
+ __decorate([
54
+ prop({
55
+ type: TJS_TYPE,
56
+ default: tjsModelDefault(TJS_TYPE, defaultRepoFor(TJS_TYPE)),
57
+ title: "Model",
58
+ description: "Transformers.js model (ONNX-compatible)."
59
+ })
60
+ ], TranslationNode.prototype, "model", void 0);
61
+ __decorate([
62
+ prop({
63
+ type: "str",
64
+ default: "eng_Latn",
65
+ title: "Source Language",
66
+ description: "Source language code understood by the model (e.g. NLLB BCP-47 codes)."
67
+ })
68
+ ], TranslationNode.prototype, "src_lang", void 0);
69
+ __decorate([
70
+ prop({
71
+ type: "str",
72
+ default: "fra_Latn",
73
+ title: "Target Language",
74
+ description: "Target language code understood by the model."
75
+ })
76
+ ], TranslationNode.prototype, "tgt_lang", void 0);
77
+ __decorate([
78
+ prop({
79
+ type: "int",
80
+ default: 256,
81
+ title: "Max Length",
82
+ description: "Maximum number of tokens in the translation.",
83
+ min: 1,
84
+ max: 4096
85
+ })
86
+ ], TranslationNode.prototype, "max_length", void 0);
87
+ __decorate([
88
+ prop({
89
+ type: "enum",
90
+ default: "auto",
91
+ title: "Quantization",
92
+ description: "Model dtype / quantization level.",
93
+ values: DTYPE_VALUES
94
+ })
95
+ ], TranslationNode.prototype, "dtype", void 0);
96
+ __decorate([
97
+ prop({
98
+ type: "enum",
99
+ default: "auto",
100
+ title: "Device",
101
+ description: "Inference device.",
102
+ values: DEVICE_VALUES
103
+ })
104
+ ], TranslationNode.prototype, "device", void 0);
105
+ export const TRANSLATION_NODES = [TranslationNode];
106
+ //# sourceMappingURL=translation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"translation.js","sourceRoot":"","sources":["../../src/nodes/translation.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,EACL,aAAa,EACb,YAAY,EACZ,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,aAAa,EACb,WAAW,EACX,eAAe,EACf,eAAe,EAChB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1D,MAAM,QAAQ,GAAG,iBAAiB,CAAC;AAInC,MAAM,OAAO,eAAgB,SAAQ,QAAQ;IAC3C,MAAM,CAAU,QAAQ,GAAG,0BAA0B,CAAC;IACtD,MAAM,CAAU,KAAK,GAAG,aAAa,CAAC;IACtC,MAAM,CAAU,WAAW,GACzB,kFAAkF;QAClF,+DAA+D;QAC/D,cAAc;QACd,6CAA6C;QAC7C,uCAAuC;QACvC,6CAA6C,CAAC;IAChD,MAAM,CAAU,mBAAmB,GAAG,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC;IA+D7D,KAAK,CAAC,OAAO;QACX,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI,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,WAAW,EAAE,0CAA0C;KACxD,CAAC;8CACiB;AASX;IAPP,IAAI,CAAC;QACJ,IAAI,EAAE,KAAK;QACX,OAAO,EAAE,UAAU;QACnB,KAAK,EAAE,iBAAiB;QACxB,WAAW,EACT,wEAAwE;KAC3E,CAAC;iDACoB;AAQd;IANP,IAAI,CAAC;QACJ,IAAI,EAAE,KAAK;QACX,OAAO,EAAE,UAAU;QACnB,KAAK,EAAE,iBAAiB;QACxB,WAAW,EAAE,+CAA+C;KAC7D,CAAC;iDACoB;AAUd;IARP,IAAI,CAAC;QACJ,IAAI,EAAE,KAAK;QACX,OAAO,EAAE,GAAG;QACZ,KAAK,EAAE,YAAY;QACnB,WAAW,EAAE,8CAA8C;QAC3D,GAAG,EAAE,CAAC;QACN,GAAG,EAAE,IAAI;KACV,CAAC;mDACsB;AAShB;IAPP,IAAI,CAAC;QACJ,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,MAAM;QACf,KAAK,EAAE,cAAc;QACrB,WAAW,EAAE,mCAAmC;QAChD,MAAM,EAAE,YAAY;KACrB,CAAC;8CACiB;AASX;IAPP,IAAI,CAAC;QACJ,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,MAAM;QACf,KAAK,EAAE,QAAQ;QACf,WAAW,EAAE,mBAAmB;QAChC,MAAM,EAAE,aAAa;KACtB,CAAC;+CACkB;AA8BtB,MAAM,CAAC,MAAM,iBAAiB,GAAyB,CAAC,eAAe,CAAC,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { BaseNode } from "@nodetool-ai/node-sdk";
2
+ import type { NodeClass } from "@nodetool-ai/node-sdk";
3
+ export declare class ZeroShotClassificationNode extends BaseNode {
4
+ static readonly nodeType = "transformers.ZeroShotClassification";
5
+ static readonly title = "Zero-Shot Classification";
6
+ static readonly description: string;
7
+ static readonly metadataOutputTypes: {
8
+ label: string;
9
+ score: string;
10
+ labels: string;
11
+ scores: string;
12
+ };
13
+ text: any;
14
+ candidate_labels: any;
15
+ multi_label: any;
16
+ model: any;
17
+ hypothesis_template: any;
18
+ dtype: any;
19
+ device: any;
20
+ process(): Promise<Record<string, unknown>>;
21
+ }
22
+ export declare const ZERO_SHOT_CLASSIFICATION_NODES: readonly NodeClass[];
23
+ //# sourceMappingURL=zero-shot-classification.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zero-shot-classification.d.ts","sourceRoot":"","sources":["../../src/nodes/zero-shot-classification.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAQ,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AA8BvD,qBAAa,0BAA2B,SAAQ,QAAQ;IACtD,MAAM,CAAC,QAAQ,CAAC,QAAQ,yCAAyC;IACjE,MAAM,CAAC,QAAQ,CAAC,KAAK,8BAA8B;IACnD,MAAM,CAAC,QAAQ,CAAC,WAAW,SAMmB;IAC9C,MAAM,CAAC,QAAQ,CAAC,mBAAmB;;;;;MAKjC;IAQM,IAAI,EAAE,GAAG,CAAC;IAQV,gBAAgB,EAAE,GAAG,CAAC;IAQtB,WAAW,EAAE,GAAG,CAAC;IAQjB,KAAK,EAAE,GAAG,CAAC;IAQX,mBAAmB,EAAE,GAAG,CAAC;IASzB,KAAK,EAAE,GAAG,CAAC;IASX,MAAM,EAAE,GAAG,CAAC;IAEd,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAqClD;AAED,eAAO,MAAM,8BAA8B,EAAE,SAAS,SAAS,EAE9D,CAAC"}
@@ -0,0 +1,128 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { BaseNode, prop } from "@nodetool-ai/node-sdk";
8
+ import { DEVICE_VALUES, DTYPE_VALUES, asString, extractRepoId, getPipeline, tjsModelDefault, normalizeOption } from "../transformers-base.js";
9
+ import { defaultRepoFor } from "../recommended-models.js";
10
+ const TJS_TYPE = "tjs.zero_shot_classification";
11
+ function parseLabels(value) {
12
+ if (Array.isArray(value)) {
13
+ return value.map((v) => String(v).trim()).filter(Boolean);
14
+ }
15
+ return String(value ?? "")
16
+ .split(",")
17
+ .map((s) => s.trim())
18
+ .filter(Boolean);
19
+ }
20
+ export class ZeroShotClassificationNode extends BaseNode {
21
+ static nodeType = "transformers.ZeroShotClassification";
22
+ static title = "Zero-Shot Classification";
23
+ static description = "Classify text into arbitrary user-supplied labels using a Transformers.js zero-shot pipeline.\n" +
24
+ "nlp, zero-shot, classification, transformers, huggingface\n\n" +
25
+ "Use cases:\n" +
26
+ "- Tag content without training data\n" +
27
+ "- Route messages to topics or teams\n" +
28
+ "- Score relevance of documents to a query";
29
+ static metadataOutputTypes = {
30
+ label: "str",
31
+ score: "float",
32
+ labels: "list",
33
+ scores: "list"
34
+ };
35
+ async process() {
36
+ const text = asString(this.text);
37
+ if (!text)
38
+ throw new Error("Text is required");
39
+ const labels = parseLabels(this.candidate_labels);
40
+ if (labels.length === 0) {
41
+ throw new Error("At least one candidate label is required");
42
+ }
43
+ const pipeline = (await getPipeline({
44
+ task: "zero-shot-classification",
45
+ model: extractRepoId(this.model) || undefined,
46
+ dtype: normalizeOption(this.dtype),
47
+ device: normalizeOption(this.device)
48
+ }));
49
+ const opts = {
50
+ multi_label: Boolean(this.multi_label)
51
+ };
52
+ const hypothesis = asString(this.hypothesis_template);
53
+ if (hypothesis)
54
+ opts.hypothesis_template = hypothesis;
55
+ const raw = await pipeline(text, labels, opts);
56
+ const result = Array.isArray(raw) ? raw[0] : raw;
57
+ const outLabels = result?.labels ?? [];
58
+ const scores = result?.scores ?? [];
59
+ return {
60
+ label: outLabels[0] ?? "",
61
+ score: scores[0] ?? 0,
62
+ labels: outLabels,
63
+ scores
64
+ };
65
+ }
66
+ }
67
+ __decorate([
68
+ prop({
69
+ type: "str",
70
+ default: "I have a problem with my iphone that needs to be resolved asap.",
71
+ title: "Text",
72
+ description: "Text to classify."
73
+ })
74
+ ], ZeroShotClassificationNode.prototype, "text", void 0);
75
+ __decorate([
76
+ prop({
77
+ type: "str",
78
+ default: "urgent, not urgent, phone, tablet, computer",
79
+ title: "Candidate Labels",
80
+ description: "Comma-separated list of candidate labels."
81
+ })
82
+ ], ZeroShotClassificationNode.prototype, "candidate_labels", void 0);
83
+ __decorate([
84
+ prop({
85
+ type: "bool",
86
+ default: false,
87
+ title: "Multi-label",
88
+ description: "Allow multiple labels to be true simultaneously."
89
+ })
90
+ ], ZeroShotClassificationNode.prototype, "multi_label", void 0);
91
+ __decorate([
92
+ prop({
93
+ type: TJS_TYPE,
94
+ default: tjsModelDefault(TJS_TYPE, defaultRepoFor(TJS_TYPE)),
95
+ title: "Model",
96
+ description: "Transformers.js model (ONNX-compatible)."
97
+ })
98
+ ], ZeroShotClassificationNode.prototype, "model", void 0);
99
+ __decorate([
100
+ prop({
101
+ type: "str",
102
+ default: "This example is {}.",
103
+ title: "Hypothesis Template",
104
+ description: "Template used to construct the entailment hypothesis."
105
+ })
106
+ ], ZeroShotClassificationNode.prototype, "hypothesis_template", void 0);
107
+ __decorate([
108
+ prop({
109
+ type: "enum",
110
+ default: "auto",
111
+ title: "Quantization",
112
+ description: "Model dtype / quantization level.",
113
+ values: DTYPE_VALUES
114
+ })
115
+ ], ZeroShotClassificationNode.prototype, "dtype", void 0);
116
+ __decorate([
117
+ prop({
118
+ type: "enum",
119
+ default: "auto",
120
+ title: "Device",
121
+ description: "Inference device.",
122
+ values: DEVICE_VALUES
123
+ })
124
+ ], ZeroShotClassificationNode.prototype, "device", void 0);
125
+ export const ZERO_SHOT_CLASSIFICATION_NODES = [
126
+ ZeroShotClassificationNode
127
+ ];
128
+ //# sourceMappingURL=zero-shot-classification.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zero-shot-classification.js","sourceRoot":"","sources":["../../src/nodes/zero-shot-classification.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,EACL,aAAa,EACb,YAAY,EACZ,QAAQ,EACR,aAAa,EACb,WAAW,EACX,eAAe,EACf,eAAe,EAChB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1D,MAAM,QAAQ,GAAG,8BAA8B,CAAC;AAQhD,SAAS,WAAW,CAAC,KAAc;IACjC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC5D,CAAC;IACD,OAAO,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC;SACvB,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;SACpB,MAAM,CAAC,OAAO,CAAC,CAAC;AACrB,CAAC;AAED,MAAM,OAAO,0BAA2B,SAAQ,QAAQ;IACtD,MAAM,CAAU,QAAQ,GAAG,qCAAqC,CAAC;IACjE,MAAM,CAAU,KAAK,GAAG,0BAA0B,CAAC;IACnD,MAAM,CAAU,WAAW,GACzB,iGAAiG;QACjG,+DAA+D;QAC/D,cAAc;QACd,uCAAuC;QACvC,uCAAuC;QACvC,2CAA2C,CAAC;IAC9C,MAAM,CAAU,mBAAmB,GAAG;QACpC,KAAK,E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,MAAM;QACf,KAAK,EAAE,QAAQ;QACf,WAAW,EAAE,mBAAmB;QAChC,MAAM,EAAE,aAAa;KACtB,CAAC;0DACkB;AAyCtB,MAAM,CAAC,MAAM,8BAA8B,GAAyB;IAClE,0BAA0B;CAC3B,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { BaseNode } from "@nodetool-ai/node-sdk";
2
+ import type { NodeClass } from "@nodetool-ai/node-sdk";
3
+ import type { ProcessingContext } from "@nodetool-ai/runtime";
4
+ export declare class ZeroShotImageClassificationNode extends BaseNode {
5
+ static readonly nodeType = "transformers.ZeroShotImageClassification";
6
+ static readonly title = "Zero-Shot Image Classification";
7
+ static readonly description: string;
8
+ static readonly metadataOutputTypes: {
9
+ label: string;
10
+ score: string;
11
+ results: string;
12
+ };
13
+ image: any;
14
+ candidate_labels: any;
15
+ model: any;
16
+ dtype: any;
17
+ device: any;
18
+ process(context?: ProcessingContext): Promise<Record<string, unknown>>;
19
+ }
20
+ export declare const ZERO_SHOT_IMAGE_CLASSIFICATION_NODES: readonly NodeClass[];
21
+ //# sourceMappingURL=zero-shot-image-classification.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zero-shot-image-classification.d.ts","sourceRoot":"","sources":["../../src/nodes/zero-shot-image-classification.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAQ,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AA2B9D,qBAAa,+BAAgC,SAAQ,QAAQ;IAC3D,MAAM,CAAC,QAAQ,CAAC,QAAQ,8CAA8C;IACtE,MAAM,CAAC,QAAQ,CAAC,KAAK,oCAAoC;IACzD,MAAM,CAAC,QAAQ,CAAC,WAAW,SAMmB;IAC9C,MAAM,CAAC,QAAQ,CAAC,mBAAmB;;;;MAIjC;IAQM,KAAK,EAAE,GAAG,CAAC;IAQX,gBAAgB,EAAE,GAAG,CAAC;IAQtB,KAAK,EAAE,GAAG,CAAC;IASX,KAAK,EAAE,GAAG,CAAC;IASX,MAAM,EAAE,GAAG,CAAC;IAEd,OAAO,CACX,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CA4BpC;AAED,eAAO,MAAM,oCAAoC,EAAE,SAAS,SAAS,EAEpE,CAAC"}