@workglow/huggingface-transformers 0.2.35 → 0.2.37

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.
@@ -3,8 +3,8 @@
3
3
  * Copyright 2025 Steven Roussey <sroussey@gmail.com>
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- import { AiProvider } from "@workglow/ai/worker";
7
6
  import type { AiProviderPreviewRunFn, AiProviderRunFnRegistration, Capability, ModelConfig, ModelRecord } from "@workglow/ai/worker";
7
+ import { AiProvider } from "@workglow/ai/worker";
8
8
  import type { HfTransformersOnnxModelConfig } from "./common/HFT_ModelSchema";
9
9
  /**
10
10
  * AI provider for HuggingFace Transformers ONNX models.
@@ -1 +1 @@
1
- {"version":3,"file":"HuggingFaceTransformersProvider.d.ts","sourceRoot":"","sources":["../../src/ai/HuggingFaceTransformersProvider.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,KAAK,EACV,sBAAsB,EACtB,2BAA2B,EAC3B,UAAU,EACV,WAAW,EACX,WAAW,EACZ,MAAM,qBAAqB,CAAC;AAG7B,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,0BAA0B,CAAC;AAG9E;;;;;;GAMG;AACH,qBAAa,+BAAgC,SAAQ,UAAU,CAAC,6BAA6B,CAAC;IAC5F,QAAQ,CAAC,IAAI,0BAAwB;IACrC,QAAQ,CAAC,WAAW,sCAAsC;IAC1D,QAAQ,CAAC,OAAO,QAAQ;IACxB,QAAQ,CAAC,eAAe,QAAQ;IAEhC,YACE,aAAa,CAAC,EAAE,SAAS,2BAA2B,CAElD,GAAG,EAEH,GAAG,EACH,6BAA6B,CAC9B,EAAE,EACH,YAAY,CAAC,EAAE,MAAM,CACnB,MAAM,EAEN,sBAAsB,CAAC,GAAG,EAAE,GAAG,EAAE,6BAA6B,CAAC,CAChE,EAGF;IAEQ,iBAAiB,C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W,GAAG,MAAM,CAElD;IAEc,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE9D;CACF"}
@@ -3,8 +3,8 @@
3
3
  * Copyright 2025 Steven Roussey <sroussey@gmail.com>
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- import { QueuedAiProvider } from "@workglow/ai";
7
6
  import type { AiProviderPreviewRunFn, AiProviderRegisterOptions, AiProviderRunFnRegistration, Capability, IAiExecutionStrategy, ModelConfig, ModelRecord } from "@workglow/ai";
7
+ import { QueuedAiProvider } from "@workglow/ai";
8
8
  import type { HfTransformersOnnxModelConfig } from "./common/HFT_ModelSchema";
9
9
  /**
10
10
  * Main-thread registration (inline or worker-backed) for the HFT provider.
@@ -1 +1 @@
1
- {"version":3,"file":"HuggingFaceTransformersQueuedProvider.d.ts","sourceRoot":"","sources":["../../src/ai/HuggingFaceTransformersQueuedProvider.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EACV,sBAAsB,EACtB,yBAAyB,EAEzB,2BAA2B,EAC3B,UAAU,EACV,oBAAoB,EACpB,WAAW,EACX,WAAW,EACZ,MAAM,cAAc,CAAC;AAGtB,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,0BAA0B,CAAC;AAsC9E;;;;;GAKG;AACH,qBAAa,qCAAsC,SAAQ,gBAAgB,CAAC,6BAA6B,CAAC;IACxG,QAAQ,CAAC,IAAI,0BAAwB;IACrC,QAAQ,CAAC,WAAW,sCAAsC;IAC1D,QAAQ,CAAC,OAAO,QAAQ;IACxB,QAAQ,CAAC,eAAe,QAAQ;IAEhC,OAAO,CAAC,WAAW,CAAmC;IAEtD,YACE,aAAa,CAAC,EAAE,SAAS,2BAA2B,CAElD,GAAG,EAEH,GAAG,EACH,6BAA6B,CAC9B,EAAE,EACH,YAAY,CAAC,EAAE,MAAM,CACnB,MAAM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,YAAY,CAAC,EAAE,MAAM,CACnB,MAAM,EAEN,sBAAsB,CAAC,GAAG,EAAE,GAAG,EAAE,6BAA6B,CAAC,CAChE,EAGF;IAEQ,iBAAiB,CAAC,KAAK,EAAE,WAAW,GAAG,SAAS,UAAU,EAAE,CAEpE;IAED,UAAmB,gBAAgB,IAAI,SAAS;QAAE,MAAM,EAAE,SAAS,UAAU,EAAE,CAAA;KAAE,EAAE,CAElF;IAEQ,aAAa,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAElD;IAEc,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE9D;IAED,UAAyB,aAAa,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC,CAOxF;IAED,UAAmB,mBAAmB,CAAC,KAAK,EAAE,WAAW,GAAG,oBAAoB,CAM/E;CACF"}
@@ -5,7 +5,7 @@
5
5
  */
6
6
  import type { Capability, ModelRecord } from "@workglow/ai/worker";
7
7
  export declare const HFT_RUN_FN_SPECS: {
8
- serves: ["image.background-removal"] | ["image.classification"] | ["image.embedding"] | ["image.object-detection"] | ["image.segmentation"] | ["image.to-text"] | ["model.count-tokens"] | ["model.download"] | ["model.download-remove"] | ["model.info"] | ["model.search"] | ["text.classification"] | ["text.embedding"] | ["text.fill-mask"] | ["text.generation"] | ["text.language-detection"] | ["text.ner"] | ["text.question-answering"] | ["text.rewriter"] | ["text.summary"] | ["text.translation"] | ["text.generation", "json-mode"] | ["text.generation", "tool-use"];
8
+ serves: ["image.background-removal"] | ["image.classification"] | ["image.embedding"] | ["image.object-detection"] | ["image.segmentation"] | ["image.to-text"] | ["model.count-tokens"] | ["model.download"] | ["model.download-remove"] | ["model.info"] | ["model.search"] | ["text.classification"] | ["text.embedding"] | ["text.fill-mask"] | ["text.generation"] | ["text.language-detection"] | ["text.ner"] | ["text.question-answering"] | ["text.reranking"] | ["text.rewriter"] | ["text.summary"] | ["text.translation"] | ["text.generation", "json-mode"] | ["text.generation", "tool-use"];
9
9
  }[];
10
10
  export declare function hftWorkerRunFnSpecs(): readonly {
11
11
  readonly serves: readonly Capability[];
@@ -21,6 +21,7 @@ export declare const HFT_TEXT_QUESTION_ANSWERING: ["text.question-answering"];
21
21
  export declare const HFT_TEXT_EMBEDDING: ["text.embedding"];
22
22
  export declare const HFT_TEXT_CLASSIFICATION: ["text.classification"];
23
23
  export declare const HFT_TEXT_LANGUAGE_DETECTION: ["text.language-detection"];
24
+ export declare const HFT_TEXT_RERANKING: ["text.reranking"];
24
25
  export declare const HFT_TEXT_FILL_MASK: ["text.fill-mask"];
25
26
  export declare const HFT_TEXT_NER: ["text.ner"];
26
27
  export declare const HFT_IMAGE_CLASSIFICATION: ["image.classification"];
@@ -35,5 +36,5 @@ export declare const HFT_MODEL_DOWNLOAD: ["model.download"];
35
36
  export declare const HFT_MODEL_SEARCH: ["model.search"];
36
37
  export declare const HFT_MODEL_INFO: ["model.info"];
37
38
  /** Aggregated list — for `workerRunFnSpecs()` derivation. Order MUST match `HFT_RUN_FNS`. */
38
- export declare const HFT_CAPABILITY_SETS: readonly [["text.generation"], ["text.generation", "tool-use"], ["text.generation", "json-mode"], ["text.rewriter"], ["text.summary"], ["text.translation"], ["text.question-answering"], ["text.embedding"], ["text.classification"], ["text.language-detection"], ["text.fill-mask"], ["text.ner"], ["image.classification"], ["image.embedding"], ["image.segmentation"], ["image.to-text"], ["image.background-removal"], ["image.object-detection"], ["model.count-tokens"], ["model.download-remove"], ["model.download"], ["model.search"], ["model.info"]];
39
+ export declare const HFT_CAPABILITY_SETS: readonly [["text.generation"], ["text.generation", "tool-use"], ["text.generation", "json-mode"], ["text.rewriter"], ["text.summary"], ["text.translation"], ["text.question-answering"], ["text.embedding"], ["text.classification"], ["text.language-detection"], ["text.reranking"], ["text.fill-mask"], ["text.ner"], ["image.classification"], ["image.embedding"], ["image.segmentation"], ["image.to-text"], ["image.background-removal"], ["image.object-detection"], ["model.count-tokens"], ["model.download-remove"], ["model.download"], ["model.search"], ["model.info"]];
39
40
  //# sourceMappingURL=HFT_CapabilitySets.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"HFT_CapabilitySets.d.ts","sourceRoot":"","sources":["../../../src/ai/common/HFT_CapabilitySets.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,qBAAsD,CAAC;AACvF,eAAO,MAAM,YAAY,iCAAkE,CAAC;AAC5F,eAAO,MAAM,aAAa,kCAAmE,CAAC;AAC9F,eAAO,MAAM,iBAAiB,mBAAoD,CAAC;AACnF,eAAO,MAAM,gBAAgB,kBAAmD,CAAC;AACjF,eAAO,MAAM,oBAAoB,sBAAuD,CAAC;AACzF,eAAO,MAAM,2BAA2B,6BAEP,CAAC;AAClC,eAAO,MAAM,kBAAkB,oBAAqD,CAAC;AACrF,eAAO,MAAM,uBAAuB,yBAA0D,CAAC;AAC/F,eAAO,MAAM,2BAA2B,6BAEP,CAAC;AAClC,eAAO,MAAM,kBAAkB,oBAAqD,CAAC;AACrF,eAAO,MAAM,YAAY,cAA+C,CAAC;AACzE,eAAO,MAAM,wBAAwB,0BAA2D,CAAC;AACjG,eAAO,MAAM,mBAAmB,qBAAsD,CAAC;AACvF,eAAO,MAAM,sBAAsB,wBAAyD,CAAC;AAC7F,eAAO,MAAM,iBAAiB,mBAAoD,CAAC;AACnF,eAAO,MAAM,4BAA4B,8BAER,CAAC;AAClC,eAAO,MAAM,0BAA0B,4BAEN,CAAC;AAClC,eAAO,MAAM,gBAAgB,wBAAyD,CAAC;AACvF,eAAO,MAAM,yBAAyB,2BAA4D,CAAC;AACnG,eAAO,MAAM,kBAAkB,oBAAqD,CAAC;AACrF,eAAO,MAAM,gBAAgB,kBAAmD,CAAC;AACjF,eAAO,MAAM,cAAc,gBAAiD,CAAC;AAE7E,6FAA6F;AAC7F,eAAO,MAAM,mBAAmB,oiBAwBtB,CAAC"}
1
+ {"version":3,"file":"HFT_CapabilitySets.d.ts","sourceRoot":"","sources":["../../../src/ai/common/HFT_CapabilitySets.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,qBAAsD,CAAC;AACvF,eAAO,MAAM,YAAY,iCAAkE,CAAC;AAC5F,eAAO,MAAM,aAAa,kCAAmE,CAAC;AAC9F,eAAO,MAAM,iBAAiB,mBAAoD,CAAC;AACnF,eAAO,MAAM,gBAAgB,kBAAmD,CAAC;AACjF,eAAO,MAAM,oBAAoB,sBAAuD,CAAC;AACzF,eAAO,MAAM,2BAA2B,6BAEP,CAAC;AAClC,eAAO,MAAM,kBAAkB,oBAAqD,CAAC;AACrF,eAAO,MAAM,uBAAuB,yBAA0D,CAAC;AAC/F,eAAO,MAAM,2BAA2B,6BAEP,CAAC;AAClC,eAAO,MAAM,kBAAkB,oBAAqD,CAAC;AACrF,eAAO,MAAM,kBAAkB,oBAAqD,CAAC;AACrF,eAAO,MAAM,YAAY,cAA+C,CAAC;AACzE,eAAO,MAAM,wBAAwB,0BAA2D,CAAC;AACjG,eAAO,MAAM,mBAAmB,qBAAsD,CAAC;AACvF,eAAO,MAAM,sBAAsB,wBAAyD,CAAC;AAC7F,eAAO,MAAM,iBAAiB,mBAAoD,CAAC;AACnF,eAAO,MAAM,4BAA4B,8BAER,CAAC;AAClC,eAAO,MAAM,0BAA0B,4BAEN,CAAC;AAClC,eAAO,MAAM,gBAAgB,wBAAyD,CAAC;AACvF,eAAO,MAAM,yBAAyB,2BAA4D,CAAC;AACnG,eAAO,MAAM,kBAAkB,oBAAqD,CAAC;AACrF,eAAO,MAAM,gBAAgB,kBAAmD,CAAC;AACjF,eAAO,MAAM,cAAc,gBAAiD,CAAC;AAE7E,6FAA6F;AAC7F,eAAO,MAAM,mBAAmB,wjBAyBtB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"HFT_Chat.d.ts","sourceRoot":"","sources":["../../../src/ai/common/HFT_Chat.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/F,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC;AA6IvE,eAAO,MAAM,QAAQ,EAAE,eAAe,CACpC,mBAAmB,EACnB,oBAAoB,EACpB,6BAA6B,CAM9B,CAAC"}
1
+ {"version":3,"file":"HFT_Chat.d.ts","sourceRoot":"","sources":["../../../src/ai/common/HFT_Chat.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/F,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC;AA4IvE,eAAO,MAAM,QAAQ,EAAE,eAAe,CACpC,mBAAmB,EACnB,oBAAoB,EACpB,6BAA6B,CAM9B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"HFT_ImageEmbedding.d.ts","sourceRoot":"","sources":["../../../src/ai/common/HFT_ImageEmbedding.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EACV,eAAe,EACf,uBAAuB,EACvB,wBAAwB,EACzB,MAAM,cAAc,CAAC;AAItB,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC;AAGvE;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,eAAe,CAC9C,uBAAuB,EACvB,wBAAwB,EACxB,6BAA6B,CAgC9B,CAAC"}
1
+ {"version":3,"file":"HFT_ImageEmbedding.d.ts","sourceRoot":"","sources":["../../../src/ai/common/HFT_ImageEmbedding.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EACV,eAAe,EACf,uBAAuB,EACvB,wBAAwB,EACzB,MAAM,cAAc,CAAC;AAGtB,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC;AAGvE;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,eAAe,CAC9C,uBAAuB,EACvB,wBAAwB,EACxB,6BAA6B,CAgC9B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"HFT_ImageSegmentation.d.ts","sourceRoot":"","sources":["../../../src/ai/common/HFT_ImageSegmentation.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EACV,eAAe,EACf,0BAA0B,EAC1B,2BAA2B,EAC5B,MAAM,cAAc,CAAC;AAGtB,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC;AAGvE;;GAEG;AACH,eAAO,MAAM,qBAAqB,EAAE,eAAe,CACjD,0BAA0B,EAC1B,2BAA2B,EAC3B,6BAA6B,CAyB9B,CAAC"}
1
+ {"version":3,"file":"HFT_ImageSegmentation.d.ts","sourceRoot":"","sources":["../../../src/ai/common/HFT_ImageSegmentation.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EACV,eAAe,EACf,0BAA0B,EAC1B,2BAA2B,EAC5B,MAAM,cAAc,CAAC;AAItB,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC;AAiCvE;;GAEG;AACH,eAAO,MAAM,qBAAqB,EAAE,eAAe,CACjD,0BAA0B,EAC1B,2BAA2B,EAC3B,6BAA6B,CAyB9B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"HFT_JobRunFns.d.ts","sourceRoot":"","sources":["../../../src/ai/common/HFT_JobRunFns.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,sBAAsB,EAEtB,2BAA2B,EAC5B,MAAM,cAAc,CAAC;AA0BtB,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC;AAiDvE;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW,EAAE,SAAS,2BAA2B,CAE5D,GAAG,EAEH,GAAG,EACH,6BAA6B,CAC9B,EAwBA,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,MAAM,CACpC,MAAM,EAEN,sBAAsB,CAAC,GAAG,EAAE,GAAG,EAAE,6BAA6B,CAAC,CAGhE,CAAC"}
1
+ {"version":3,"file":"HFT_JobRunFns.d.ts","sourceRoot":"","sources":["../../../src/ai/common/HFT_JobRunFns.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,sBAAsB,EAEtB,2BAA2B,EAC5B,MAAM,cAAc,CAAC;AA2BtB,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC;AAkDvE;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW,EAAE,SAAS,2BAA2B,CAE5D,GAAG,EAEH,GAAG,EACH,6BAA6B,CAC9B,EAyBA,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,MAAM,CACpC,MAAM,EAEN,sBAAsB,CAAC,GAAG,EAAE,GAAG,EAAE,6BAA6B,CAAC,CAGhE,CAAC"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Steven Roussey <sroussey@gmail.com>
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import type { AiProviderRunFn, TextRerankerTaskInput, TextRerankerTaskOutput } from "@workglow/ai";
7
+ import type { HfTransformersOnnxModelConfig } from "./HFT_ModelSchema";
8
+ /**
9
+ * Validate a transformers.js text-classification pipeline output and
10
+ * extract per-document scores. Each entry must be either a `{ score }`
11
+ * object or a non-empty array of such objects (transformers.js returns
12
+ * the array form when `top_k > 1`).
13
+ *
14
+ * Exported so the shape contract can be exercised in tests directly,
15
+ * without needing to spin up a real pipeline or mock the loader. Throws
16
+ * {@link KbRerankerOutputError} on mismatch — silently coercing to 0
17
+ * would hide real model config bugs.
18
+ *
19
+ * @param rawResults Whatever the pipeline call returned. Typed as
20
+ * `unknown` so the caller is forced through this validation.
21
+ * @param modelPath Used in the error message to point operators at the
22
+ * misconfigured model.
23
+ */
24
+ export declare function validateAndExtractRerankerScores(rawResults: unknown, modelPath: string | undefined): number[];
25
+ /**
26
+ * Cross-encoder reranker run-fn. Loads a `text-classification` pipeline
27
+ * (the way transformers.js exposes cross-encoder models like
28
+ * `Xenova/bge-reranker-base`) and scores each `[query, doc]` pair.
29
+ *
30
+ * Output `indices` is sorted best-first; `scores` is the per-document score
31
+ * in the original input order so callers can join back to their candidate
32
+ * list without re-sorting.
33
+ *
34
+ * Each pipeline result entry is validated at runtime via
35
+ * {@link validateAndExtractRerankerScores}: either a `{ score }` object or
36
+ * a non-empty array of such objects. On mismatch we throw
37
+ * {@link KbRerankerOutputError} with the model path and a truncated shape
38
+ * snippet — silently coercing missing scores to 0 would hide real model
39
+ * config bugs.
40
+ */
41
+ export declare const HFT_TextReranker: AiProviderRunFn<TextRerankerTaskInput, TextRerankerTaskOutput, HfTransformersOnnxModelConfig>;
42
+ //# sourceMappingURL=HFT_TextReranker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HFT_TextReranker.d.ts","sourceRoot":"","sources":["../../../src/ai/common/HFT_TextReranker.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAGnG,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC;AA8BvE;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,gCAAgC,CAC9C,UAAU,EAAE,OAAO,EACnB,SAAS,EAAE,MAAM,GAAG,SAAS,GAC5B,MAAM,EAAE,CAqBV;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,gBAAgB,EAAE,eAAe,CAC5C,qBAAqB,EACrB,sBAAsB,EACtB,6BAA6B,CAsC9B,CAAC"}
@@ -15,7 +15,7 @@ export * from "./registerHuggingFaceTransformers";
15
15
  */
16
16
  export declare const _testOnly: {
17
17
  readonly HFT_RUN_FN_SPECS: {
18
- serves: ["image.background-removal"] | ["image.classification"] | ["image.embedding"] | ["image.object-detection"] | ["image.segmentation"] | ["image.to-text"] | ["model.count-tokens"] | ["model.download"] | ["model.download-remove"] | ["model.info"] | ["model.search"] | ["text.classification"] | ["text.embedding"] | ["text.fill-mask"] | ["text.generation"] | ["text.language-detection"] | ["text.ner"] | ["text.question-answering"] | ["text.rewriter"] | ["text.summary"] | ["text.translation"] | ["text.generation", "json-mode"] | ["text.generation", "tool-use"];
18
+ serves: ["image.background-removal"] | ["image.classification"] | ["image.embedding"] | ["image.object-detection"] | ["image.segmentation"] | ["image.to-text"] | ["model.count-tokens"] | ["model.download"] | ["model.download-remove"] | ["model.info"] | ["model.search"] | ["text.classification"] | ["text.embedding"] | ["text.fill-mask"] | ["text.generation"] | ["text.language-detection"] | ["text.ner"] | ["text.question-answering"] | ["text.reranking"] | ["text.rewriter"] | ["text.summary"] | ["text.translation"] | ["text.generation", "json-mode"] | ["text.generation", "tool-use"];
19
19
  }[];
20
20
  readonly HFT_RUN_FNS: readonly import("@workglow/ai").AiProviderRunFnRegistration<any, any, {
21
21
  capabilities?: string[] | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"registerHuggingFaceTransformersWorker.d.ts","sourceRoot":"","sources":["../../src/ai/registerHuggingFaceTransformersWorker.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAaH,wBAAsB,qCAAqC,IAAI,OAAO,CAAC,IAAI,CAAC,CAY3E"}
1
+ {"version":3,"file":"registerHuggingFaceTransformersWorker.d.ts","sourceRoot":"","sources":["../../src/ai/registerHuggingFaceTransformersWorker.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAaH,wBAAsB,qCAAqC,IAAI,OAAO,CAAC,IAAI,CAAC,CAc3E"}
@@ -15,6 +15,7 @@ export * from "./common/HFT_Constants";
15
15
  export * from "./common/HFT_ModelSchema";
16
16
  export * from "./common/HFT_OnnxDtypes";
17
17
  export * from "./common/HFT_Pipeline";
18
+ export * from "./common/HFT_TextReranker";
18
19
  export * from "./common/HFT_ToolMarkup";
19
20
  export * from "./registerHuggingFaceTransformersInline";
20
21
  export * from "./registerHuggingFaceTransformersWorker";
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/ai/runtime.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;GAOG;AAIH,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yCAAyC,CAAC;AACxD,cAAc,yCAAyC,CAAC"}
1
+ {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/ai/runtime.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;GAOG;AAIH,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,yCAAyC,CAAC;AACxD,cAAc,yCAAyC,CAAC"}
@@ -656,6 +656,54 @@ function parseOnnxQuantizations(params) {
656
656
  });
657
657
  }
658
658
 
659
+ // src/ai/common/HFT_TextReranker.ts
660
+ init_HFT_Pipeline();
661
+ import { KbRerankerOutputError } from "@workglow/ai";
662
+ import { getLogger as getLogger2 } from "@workglow/util/worker";
663
+ function isScored(v) {
664
+ return typeof v === "object" && v !== null && typeof v.score === "number";
665
+ }
666
+ function truncateShape(value) {
667
+ try {
668
+ const json = JSON.stringify(value);
669
+ if (typeof json !== "string")
670
+ return String(value);
671
+ return json.length > 200 ? `${json.slice(0, 200)}…` : json;
672
+ } catch {
673
+ return String(value);
674
+ }
675
+ }
676
+ function validateAndExtractRerankerScores(rawResults, modelPath) {
677
+ if (!Array.isArray(rawResults)) {
678
+ throw new KbRerankerOutputError(`HFT_TextReranker: unexpected pipeline output shape for model ${modelPath}`, truncateShape(rawResults));
679
+ }
680
+ const scores = new Array(rawResults.length);
681
+ for (let i = 0;i < rawResults.length; i++) {
682
+ const entry = rawResults[i];
683
+ const candidate = Array.isArray(entry) ? entry[0] : entry;
684
+ if (!isScored(candidate)) {
685
+ throw new KbRerankerOutputError(`HFT_TextReranker: unexpected pipeline output shape for model ${modelPath}`, truncateShape(entry));
686
+ }
687
+ scores[i] = candidate.score;
688
+ }
689
+ return scores;
690
+ }
691
+ var HFT_TextReranker = async (input, model, signal, emit) => {
692
+ const logger = getLogger2();
693
+ const modelPath = model?.provider_config.model_path;
694
+ const timerLabel = `hft:TextReranker:${modelPath}`;
695
+ logger.time(timerLabel, { docs: input.documents.length });
696
+ const reranker = await getPipeline(model, emit, {}, signal);
697
+ const pairs = input.documents.map((doc) => ({ text: input.query, text_pair: doc }));
698
+ const callable = reranker;
699
+ const rawResults = await callable(pairs, { top_k: 1 });
700
+ const scores = validateAndExtractRerankerScores(rawResults, modelPath);
701
+ const indices = scores.map((score, idx) => ({ score, idx })).sort((a, b) => b.score - a.score).map((p) => p.idx);
702
+ const limited = typeof input.topK === "number" ? indices.slice(0, input.topK) : indices;
703
+ logger.timeEnd(timerLabel, { docs: input.documents.length });
704
+ emit({ type: "finish", data: { scores, indices: limited } });
705
+ };
706
+
659
707
  // src/ai/common/HFT_ToolMarkup.ts
660
708
  function createToolCallMarkupFilter(emit) {
661
709
  const OPEN_TAG = "<tool_call>";
@@ -746,6 +794,7 @@ var HFT_TEXT_CLASSIFICATION = ["text.classification"];
746
794
  var HFT_TEXT_LANGUAGE_DETECTION = [
747
795
  "text.language-detection"
748
796
  ];
797
+ var HFT_TEXT_RERANKING = ["text.reranking"];
749
798
  var HFT_TEXT_FILL_MASK = ["text.fill-mask"];
750
799
  var HFT_TEXT_NER = ["text.ner"];
751
800
  var HFT_IMAGE_CLASSIFICATION = ["image.classification"];
@@ -774,6 +823,7 @@ var HFT_CAPABILITY_SETS = [
774
823
  HFT_TEXT_EMBEDDING,
775
824
  HFT_TEXT_CLASSIFICATION,
776
825
  HFT_TEXT_LANGUAGE_DETECTION,
826
+ HFT_TEXT_RERANKING,
777
827
  HFT_TEXT_FILL_MASK,
778
828
  HFT_TEXT_NER,
779
829
  HFT_IMAGE_CLASSIFICATION,
@@ -816,21 +866,6 @@ var HFT_BackgroundRemoval = async (input, model, signal, emit) => {
816
866
  // src/ai/common/HFT_Chat.ts
817
867
  init_HFT_Pipeline();
818
868
 
819
- // src/ai/common/HFT_ToolCalling.ts
820
- init_HFT_Pipeline();
821
- import {
822
- buildToolDescription,
823
- filterValidToolCalls,
824
- toTextFlatMessages
825
- } from "@workglow/ai/worker";
826
- import {
827
- adaptParserResult,
828
- forcedToolSelection,
829
- getAvailableParsers,
830
- getGenerationPrefix,
831
- parseToolCalls
832
- } from "@workglow/ai/provider-utils";
833
-
834
869
  // src/ai/common/HFT_Streaming.ts
835
870
  function createStreamingTextStreamer(tokenizer, onText, textStreamer) {
836
871
  return new textStreamer(tokenizer, {
@@ -854,6 +889,19 @@ function createTextStreamer(tokenizer, updateProgress, textStreamer) {
854
889
  }
855
890
 
856
891
  // src/ai/common/HFT_ToolCalling.ts
892
+ init_HFT_Pipeline();
893
+ import {
894
+ adaptParserResult,
895
+ forcedToolSelection,
896
+ getAvailableParsers,
897
+ getGenerationPrefix,
898
+ parseToolCalls
899
+ } from "@workglow/ai/provider-utils";
900
+ import {
901
+ buildToolDescription,
902
+ filterValidToolCalls,
903
+ toTextFlatMessages
904
+ } from "@workglow/ai/worker";
857
905
  function getModelTextCandidates(model) {
858
906
  return [model.model_id, model.title, model.description, model.provider_config.model_path].filter((value) => typeof value === "string" && value.length > 0).map((value) => value.toLowerCase());
859
907
  }
@@ -1171,9 +1219,9 @@ var HFT_CountTokens_Preview = async (input, model) => {
1171
1219
 
1172
1220
  // src/ai/common/HFT_Download.ts
1173
1221
  init_HFT_Pipeline();
1174
- import { getLogger as getLogger2 } from "@workglow/util/worker";
1222
+ import { getLogger as getLogger3 } from "@workglow/util/worker";
1175
1223
  var HFT_Download = async (input, model, signal, emit) => {
1176
- const logger = getLogger2();
1224
+ const logger = getLogger3();
1177
1225
  const timerLabel = `hft:Download:${model?.provider_config.model_path}`;
1178
1226
  logger.time(timerLabel, { model: model?.provider_config.model_path });
1179
1227
  await getPipeline(model, emit, {}, signal, 100);
@@ -1273,10 +1321,10 @@ var HFT_ImageClassification = async (input, model, signal, emit) => {
1273
1321
 
1274
1322
  // src/ai/common/HFT_ImageEmbedding.ts
1275
1323
  init_HFT_Pipeline();
1276
- import { getLogger as getLogger3 } from "@workglow/util/worker";
1277
1324
  import { imageValueToBlob as imageValueToBlob3 } from "@workglow/ai/provider-utils";
1325
+ import { getLogger as getLogger4 } from "@workglow/util/worker";
1278
1326
  var HFT_ImageEmbedding = async (input, model, signal, emit) => {
1279
- const logger = getLogger3();
1327
+ const logger = getLogger4();
1280
1328
  const timerLabel = `hft:ImageEmbedding:${model?.provider_config.model_path}`;
1281
1329
  logger.time(timerLabel, { model: model?.provider_config.model_path });
1282
1330
  const embedder = await getPipeline(model, emit, {}, signal);
@@ -1306,6 +1354,29 @@ var HFT_ImageEmbedding = async (input, model, signal, emit) => {
1306
1354
  // src/ai/common/HFT_ImageSegmentation.ts
1307
1355
  init_HFT_Pipeline();
1308
1356
  import { imageValueToBlob as imageValueToBlob4 } from "@workglow/ai/provider-utils";
1357
+ import { imageValueFromBuffer } from "@workglow/util/media";
1358
+ function rawImageToImageValue(image) {
1359
+ const raw = image;
1360
+ const pixelCount = raw.width * raw.height;
1361
+ const rgba = new Uint8Array(pixelCount * 4);
1362
+ for (let pixel = 0;pixel < pixelCount; pixel++) {
1363
+ const sourceOffset = pixel * raw.channels;
1364
+ const targetOffset = pixel * 4;
1365
+ if (raw.channels === 1) {
1366
+ const value = raw.data[sourceOffset] ?? 0;
1367
+ rgba[targetOffset] = value;
1368
+ rgba[targetOffset + 1] = value;
1369
+ rgba[targetOffset + 2] = value;
1370
+ rgba[targetOffset + 3] = 255;
1371
+ } else {
1372
+ rgba[targetOffset] = raw.data[sourceOffset] ?? 0;
1373
+ rgba[targetOffset + 1] = raw.data[sourceOffset + 1] ?? raw.data[sourceOffset] ?? 0;
1374
+ rgba[targetOffset + 2] = raw.data[sourceOffset + 2] ?? raw.data[sourceOffset] ?? 0;
1375
+ rgba[targetOffset + 3] = raw.channels >= 4 ? raw.data[sourceOffset + 3] ?? 255 : 255;
1376
+ }
1377
+ }
1378
+ return imageValueFromBuffer(Buffer.from(rgba), "raw-rgba", raw.width, raw.height);
1379
+ }
1309
1380
  var HFT_ImageSegmentation = async (input, model, signal, emit) => {
1310
1381
  const segmenter = await getPipeline(model, emit, {}, signal);
1311
1382
  const imageArg = await imageValueToBlob4(input.image);
@@ -1314,11 +1385,13 @@ var HFT_ImageSegmentation = async (input, model, signal, emit) => {
1314
1385
  mask_threshold: input.maskThreshold
1315
1386
  });
1316
1387
  const masks = Array.isArray(result) ? result : [result];
1317
- const processedMasks = await Promise.all(masks.map(async (mask) => ({
1318
- label: mask.label || "",
1319
- score: mask.score || 0,
1320
- mask: {}
1321
- })));
1388
+ const processedMasks = masks.map((mask) => {
1389
+ return {
1390
+ label: mask.label || "",
1391
+ score: mask.score || 0,
1392
+ mask: rawImageToImageValue(mask.mask)
1393
+ };
1394
+ });
1322
1395
  emit({
1323
1396
  type: "finish",
1324
1397
  data: {
@@ -1346,7 +1419,7 @@ var HFT_ImageToText = async (input, model, signal, emit) => {
1346
1419
  };
1347
1420
 
1348
1421
  // src/ai/common/HFT_ModelInfo.ts
1349
- import { getLogger as getLogger4 } from "@workglow/util/worker";
1422
+ import { getLogger as getLogger5 } from "@workglow/util/worker";
1350
1423
  init_HFT_Pipeline();
1351
1424
  var HFT_ModelInfo = async (input, model, _signal, emit) => {
1352
1425
  if (input.detail === "dimensions") {
@@ -1383,7 +1456,7 @@ var HFT_ModelInfo = async (input, model, _signal, emit) => {
1383
1456
  });
1384
1457
  return;
1385
1458
  }
1386
- const logger = getLogger4();
1459
+ const logger = getLogger5();
1387
1460
  const { ModelRegistry } = await loadTransformersSDK();
1388
1461
  const timerLabel = `hft:ModelInfo:${model?.provider_config.model_path}`;
1389
1462
  logger.time(timerLabel, { model: model?.provider_config.model_path });
@@ -1445,7 +1518,7 @@ var HFT_ModelInfo = async (input, model, _signal, emit) => {
1445
1518
  };
1446
1519
 
1447
1520
  // src/ai/common/HFT_ModelSearch.ts
1448
- import { searchHfModels, mapHfModelResult } from "@workglow/ai/provider-utils";
1521
+ import { mapHfModelResult, searchHfModels } from "@workglow/ai/provider-utils";
1449
1522
  var HFT_ModelSearch = async (input, _model, signal, emit) => {
1450
1523
  const entries = await searchHfModels(input.query?.trim() ?? "", { filter: "onnx" }, ["siblings"], signal);
1451
1524
  const results = entries.map((entry) => {
@@ -1641,9 +1714,9 @@ var HFT_TextClassification = async (input, model, signal, emit) => {
1641
1714
 
1642
1715
  // src/ai/common/HFT_TextEmbedding.ts
1643
1716
  init_HFT_Pipeline();
1644
- import { getLogger as getLogger5 } from "@workglow/util/worker";
1717
+ import { getLogger as getLogger6 } from "@workglow/util/worker";
1645
1718
  var HFT_TextEmbedding = async (input, model, signal, emit) => {
1646
- const logger = getLogger5();
1719
+ const logger = getLogger6();
1647
1720
  const uuid = crypto.randomUUID();
1648
1721
  const timerLabel = `hft:TextEmbedding:${model?.provider_config.model_path}:${uuid}`;
1649
1722
  logger.time(timerLabel, { model: model?.provider_config.model_path });
@@ -1865,6 +1938,7 @@ var HFT_RUN_FNS = [
1865
1938
  { serves: HFT_TEXT_EMBEDDING, runFn: HFT_TextEmbedding },
1866
1939
  { serves: HFT_TEXT_CLASSIFICATION, runFn: HFT_TextClassification },
1867
1940
  { serves: HFT_TEXT_LANGUAGE_DETECTION, runFn: HFT_TextLanguageDetection },
1941
+ { serves: HFT_TEXT_RERANKING, runFn: HFT_TextReranker },
1868
1942
  { serves: HFT_TEXT_FILL_MASK, runFn: HFT_TextFillMask },
1869
1943
  { serves: HFT_TEXT_NER, runFn: HFT_TextNamedEntityRecognition },
1870
1944
  { serves: HFT_IMAGE_CLASSIFICATION, runFn: HFT_ImageClassification },
@@ -2054,6 +2128,7 @@ async function registerHuggingFaceTransformersInline(options) {
2054
2128
 
2055
2129
  // src/ai/registerHuggingFaceTransformersWorker.ts
2056
2130
  import { registerProviderWorker } from "@workglow/ai/provider-utils";
2131
+ init_HFT_Pipeline();
2057
2132
 
2058
2133
  // src/ai/HuggingFaceTransformersProvider.ts
2059
2134
  import { AiProvider } from "@workglow/ai/worker";
@@ -2082,7 +2157,6 @@ class HuggingFaceTransformersProvider extends AiProvider {
2082
2157
  }
2083
2158
 
2084
2159
  // src/ai/registerHuggingFaceTransformersWorker.ts
2085
- init_HFT_Pipeline();
2086
2160
  async function registerHuggingFaceTransformersWorker() {
2087
2161
  const sdk = await loadTransformersSDK();
2088
2162
  globalThis.__HFT__ = sdk;
@@ -2091,6 +2165,7 @@ async function registerHuggingFaceTransformersWorker() {
2091
2165
  await registerProviderWorker((ws) => new HuggingFaceTransformersProvider(HFT_RUN_FNS, HFT_PREVIEW_TASKS).registerOnWorkerServer(ws), "HuggingFaceTransformers");
2092
2166
  }
2093
2167
  export {
2168
+ validateAndExtractRerankerScores,
2094
2169
  setHftSession,
2095
2170
  setHftCacheDir,
2096
2171
  removeCachedPipeline,
@@ -2116,7 +2191,8 @@ export {
2116
2191
  HF_TRANSFORMERS_ONNX_GPU,
2117
2192
  HF_TRANSFORMERS_ONNX_CPU,
2118
2193
  HF_TRANSFORMERS_ONNX,
2194
+ HFT_TextReranker,
2119
2195
  HFT_NULL_PROCESSOR_PREFIX
2120
2196
  };
2121
2197
 
2122
- //# debugId=93CB8C37EE02941864756E2164756E21
2198
+ //# debugId=54B26D0D2015DF8E64756E2164756E21