@workglow/ai-provider 0.0.118 → 0.0.120

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.
@@ -35,8 +35,8 @@ import {
35
35
  clearPipelineCache,
36
36
  createToolCallMarkupFilter,
37
37
  parseToolCallsFromText
38
- } from "./index-tvb9nd5b.js";
39
- import"./index-m0r2hvfz.js";
38
+ } from "./index-j4g81r4k.js";
39
+ import"./index-zqq3kw0n.js";
40
40
  import"./index-6j5pq722.js";
41
41
  export {
42
42
  parseToolCallsFromText,
@@ -35,23 +35,23 @@ import {
35
35
  clearPipelineCache,
36
36
  createToolCallMarkupFilter,
37
37
  parseToolCallsFromText
38
- } from "../index-tvb9nd5b.js";
38
+ } from "../index-j4g81r4k.js";
39
39
  import {
40
- HfTransformersOnnxModelConfigSchema,
41
- HfTransformersOnnxModelRecordSchema,
42
- HfTransformersOnnxModelSchema,
43
40
  HuggingFaceTransformersProvider
44
- } from "../index-qett8dfp.js";
41
+ } from "../index-pkd79j8b.js";
45
42
  import {
46
43
  AudioPipelineUseCase,
47
44
  HF_TRANSFORMERS_ONNX,
48
45
  HTF_CACHE_NAME,
46
+ HfTransformersOnnxModelConfigSchema,
47
+ HfTransformersOnnxModelRecordSchema,
48
+ HfTransformersOnnxModelSchema,
49
49
  MultimodalPipelineUseCase,
50
50
  PipelineUseCase,
51
51
  QuantizationDataType,
52
52
  TextPipelineUseCase,
53
53
  VisionPipelineUseCase
54
- } from "../index-m0r2hvfz.js";
54
+ } from "../index-zqq3kw0n.js";
55
55
  import"../index-6j5pq722.js";
56
56
  // src/hf-transformers/HFT_Worker.ts
57
57
  import { getLogger, globalServiceRegistry, WORKER_SERVER } from "@workglow/util";
@@ -113,4 +113,4 @@ export {
113
113
  AudioPipelineUseCase
114
114
  };
115
115
 
116
- //# debugId=9271A781CE2A6F1C64756E2164756E21
116
+ //# debugId=4FF1AFD0A9706B2D64756E2164756E21
@@ -5,6 +5,6 @@
5
5
  "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { getLogger, globalServiceRegistry, WORKER_SERVER } from \"@workglow/util\";\nimport { HFT_REACTIVE_TASKS, HFT_STREAM_TASKS, HFT_TASKS } from \"./common/HFT_JobRunFns\";\nimport { HuggingFaceTransformersProvider } from \"./HuggingFaceTransformersProvider\";\n\nexport function HFT_WORKER_JOBRUN_REGISTER() {\n const workerServer = globalServiceRegistry.get(WORKER_SERVER);\n new HuggingFaceTransformersProvider(\n HFT_TASKS,\n HFT_STREAM_TASKS,\n HFT_REACTIVE_TASKS\n ).registerOnWorkerServer(workerServer);\n workerServer.sendReady();\n getLogger().info(\"HFT_WORKER_JOBRUN registered\");\n}\n"
6
6
  ],
7
7
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA;AAIO,SAAS,0BAA0B,GAAG;AAAA,EAC3C,MAAM,eAAe,sBAAsB,IAAI,aAAa;AAAA,EAC5D,IAAI,gCACF,WACA,kBACA,kBACF,EAAE,uBAAuB,YAAY;AAAA,EACrC,aAAa,UAAU;AAAA,EACvB,UAAU,EAAE,KAAK,8BAA8B;AAAA;",
8
- "debugId": "9271A781CE2A6F1C64756E2164756E21",
8
+ "debugId": "4FF1AFD0A9706B2D64756E2164756E21",
9
9
  "names": []
10
10
  }
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  HTF_CACHE_NAME
3
- } from "./index-m0r2hvfz.js";
3
+ } from "./index-zqq3kw0n.js";
4
4
  import {
5
5
  __require
6
6
  } from "./index-6j5pq722.js";
@@ -0,0 +1,58 @@
1
+ import {
2
+ HF_TRANSFORMERS_ONNX
3
+ } from "./index-zqq3kw0n.js";
4
+ import {
5
+ __require
6
+ } from "./index-6j5pq722.js";
7
+
8
+ // src/hf-transformers/HuggingFaceTransformersProvider.ts
9
+ import {
10
+ AiProvider
11
+ } from "@workglow/ai";
12
+ class HuggingFaceTransformersProvider extends AiProvider {
13
+ name = HF_TRANSFORMERS_ONNX;
14
+ isLocal = true;
15
+ supportsBrowser = true;
16
+ taskTypes = [
17
+ "DownloadModelTask",
18
+ "UnloadModelTask",
19
+ "ModelInfoTask",
20
+ "CountTokensTask",
21
+ "TextEmbeddingTask",
22
+ "TextGenerationTask",
23
+ "TextQuestionAnswerTask",
24
+ "TextLanguageDetectionTask",
25
+ "TextClassificationTask",
26
+ "TextFillMaskTask",
27
+ "TextNamedEntityRecognitionTask",
28
+ "TextRewriterTask",
29
+ "TextSummaryTask",
30
+ "TextTranslationTask",
31
+ "ImageSegmentationTask",
32
+ "ImageToTextTask",
33
+ "BackgroundRemovalTask",
34
+ "ImageEmbeddingTask",
35
+ "ImageClassificationTask",
36
+ "ObjectDetectionTask",
37
+ "ToolCallingTask"
38
+ ];
39
+ constructor(tasks, streamTasks, reactiveTasks) {
40
+ super(tasks, streamTasks, reactiveTasks);
41
+ }
42
+ async onInitialize(options) {
43
+ if (options.mode === "inline") {
44
+ const { env } = await import("@huggingface/transformers");
45
+ env.backends.onnx.wasm.proxy = true;
46
+ }
47
+ }
48
+ async dispose() {
49
+ if (this.tasks) {
50
+ const { clearPipelineCache } = await import("./HFT_JobRunFns-8hcpea4c.js");
51
+ clearPipelineCache();
52
+ }
53
+ }
54
+ }
55
+
56
+ export { HuggingFaceTransformersProvider };
57
+
58
+ //# debugId=E3338E20742D04D864756E2164756E21
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/hf-transformers/HuggingFaceTransformersProvider.ts"],
4
+ "sourcesContent": [
5
+ "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {\n AiProvider,\n type AiProviderReactiveRunFn,\n type AiProviderRegisterOptions,\n type AiProviderRunFn,\n type AiProviderStreamFn,\n} from \"@workglow/ai\";\nimport { HF_TRANSFORMERS_ONNX } from \"./common/HFT_Constants\";\nimport type { HfTransformersOnnxModelConfig } from \"./common/HFT_ModelSchema\";\n\n/**\n * AI provider for HuggingFace Transformers ONNX models.\n *\n * Supports text, vision, and multimodal tasks via the @huggingface/transformers library.\n *\n * Task run functions are injected via the constructor so that the heavy\n * `@huggingface/transformers` library is only imported where actually needed\n * (inline mode, worker server), not on the main thread in worker mode.\n *\n * @example\n * ```typescript\n * // Worker mode (main thread) -- lightweight, no heavy imports:\n * await new HuggingFaceTransformersProvider().register({\n * mode: \"worker\",\n * worker: new Worker(new URL(\"./worker_hft.ts\", import.meta.url), { type: \"module\" }),\n * });\n *\n * // Inline mode -- caller provides the tasks:\n * import { HFT_TASKS, HFT_STREAM_TASKS, HFT_REACTIVE_TASKS } from \"@workglow/ai-provider/hf-transformers\";\n * await new HuggingFaceTransformersProvider(HFT_TASKS, HFT_STREAM_TASKS, HFT_REACTIVE_TASKS).register({ mode: \"inline\" });\n *\n * // Worker side -- caller provides the tasks:\n * import { HFT_TASKS, HFT_STREAM_TASKS, HFT_REACTIVE_TASKS } from \"@workglow/ai-provider/hf-transformers\";\n * new HuggingFaceTransformersProvider(HFT_TASKS, HFT_STREAM_TASKS, HFT_REACTIVE_TASKS).registerOnWorkerServer(workerServer);\n * ```\n */\nexport class HuggingFaceTransformersProvider extends AiProvider<HfTransformersOnnxModelConfig> {\n readonly name = HF_TRANSFORMERS_ONNX;\n readonly isLocal = true;\n readonly supportsBrowser = true;\n\n readonly taskTypes = [\n \"DownloadModelTask\",\n \"UnloadModelTask\",\n \"ModelInfoTask\",\n \"CountTokensTask\",\n \"TextEmbeddingTask\",\n \"TextGenerationTask\",\n \"TextQuestionAnswerTask\",\n \"TextLanguageDetectionTask\",\n \"TextClassificationTask\",\n \"TextFillMaskTask\",\n \"TextNamedEntityRecognitionTask\",\n \"TextRewriterTask\",\n \"TextSummaryTask\",\n \"TextTranslationTask\",\n \"ImageSegmentationTask\",\n \"ImageToTextTask\",\n \"BackgroundRemovalTask\",\n \"ImageEmbeddingTask\",\n \"ImageClassificationTask\",\n \"ObjectDetectionTask\",\n \"ToolCallingTask\",\n ] as const;\n\n constructor(\n tasks?: Record<string, AiProviderRunFn<any, any, HfTransformersOnnxModelConfig>>,\n streamTasks?: Record<string, AiProviderStreamFn<any, any, HfTransformersOnnxModelConfig>>,\n reactiveTasks?: Record<string, AiProviderReactiveRunFn<any, any, HfTransformersOnnxModelConfig>>\n ) {\n super(tasks, streamTasks, reactiveTasks);\n }\n\n protected override async onInitialize(options: AiProviderRegisterOptions): Promise<void> {\n if (options.mode === \"inline\") {\n const { env } = await import(\"@huggingface/transformers\");\n // @ts-ignore -- backends.onnx.wasm.proxy is not fully typed\n env.backends.onnx.wasm.proxy = true;\n }\n }\n\n override async dispose(): Promise<void> {\n if (this.tasks) {\n const { clearPipelineCache } = await import(\"./common/HFT_JobRunFns\");\n clearPipelineCache();\n }\n }\n}\n"
6
+ ],
7
+ "mappings": ";;;;;;;;AAMA;AAAA;AAAA;AAoCO,MAAM,wCAAwC,WAA0C;AAAA,EACpF,OAAO;AAAA,EACP,UAAU;AAAA,EACV,kBAAkB;AAAA,EAElB,YAAY;AAAA,IACnB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EAEA,WAAW,CACT,OACA,aACA,eACA;AAAA,IACA,MAAM,OAAO,aAAa,aAAa;AAAA;AAAA,OAGhB,aAAY,CAAC,SAAmD;AAAA,IACvF,IAAI,QAAQ,SAAS,UAAU;AAAA,MAC7B,QAAQ,QAAQ,MAAa;AAAA,MAE7B,IAAI,SAAS,KAAK,KAAK,QAAQ;AAAA,IACjC;AAAA;AAAA,OAGa,QAAO,GAAkB;AAAA,IACtC,IAAI,KAAK,OAAO;AAAA,MACd,QAAQ,uBAAuB,MAAa;AAAA,MAC5C,mBAAmB;AAAA,IACrB;AAAA;AAEJ;",
8
+ "debugId": "E3338E20742D04D864756E2164756E21",
9
+ "names": []
10
+ }
@@ -1,11 +1,56 @@
1
- import {
2
- HF_TRANSFORMERS_ONNX,
3
- PipelineUseCase,
4
- QuantizationDataType
5
- } from "./index-m0r2hvfz.js";
6
- import {
7
- __require
8
- } from "./index-6j5pq722.js";
1
+ // src/hf-transformers/common/HFT_Constants.ts
2
+ var HF_TRANSFORMERS_ONNX = "HF_TRANSFORMERS_ONNX";
3
+ var HTF_CACHE_NAME = "transformers-cache";
4
+ var QuantizationDataType = {
5
+ auto: "auto",
6
+ fp32: "fp32",
7
+ fp16: "fp16",
8
+ q8: "q8",
9
+ int8: "int8",
10
+ uint8: "uint8",
11
+ q4: "q4",
12
+ bnb4: "bnb4",
13
+ q4f16: "q4f16"
14
+ };
15
+ var TextPipelineUseCase = {
16
+ "fill-mask": "fill-mask",
17
+ "token-classification": "token-classification",
18
+ "text-generation": "text-generation",
19
+ "text2text-generation": "text2text-generation",
20
+ "text-classification": "text-classification",
21
+ summarization: "summarization",
22
+ translation: "translation",
23
+ "feature-extraction": "feature-extraction",
24
+ "zero-shot-classification": "zero-shot-classification",
25
+ "question-answering": "question-answering"
26
+ };
27
+ var VisionPipelineUseCase = {
28
+ "background-removal": "background-removal",
29
+ "image-segmentation": "image-segmentation",
30
+ "depth-estimation": "depth-estimation",
31
+ "image-classification": "image-classification",
32
+ "image-to-image": "image-to-image",
33
+ "object-detection": "object-detection",
34
+ "image-feature-extraction": "image-feature-extraction"
35
+ };
36
+ var AudioPipelineUseCase = {
37
+ "audio-classification": "audio-classification",
38
+ "automatic-speech-recognition": "automatic-speech-recognition",
39
+ "text-to-speech": "text-to-speech"
40
+ };
41
+ var MultimodalPipelineUseCase = {
42
+ "document-question-answering": "document-question-answering",
43
+ "image-to-text": "image-to-text",
44
+ "zero-shot-audio-classification": "zero-shot-audio-classification",
45
+ "zero-shot-image-classification": "zero-shot-image-classification",
46
+ "zero-shot-object-detection": "zero-shot-object-detection"
47
+ };
48
+ var PipelineUseCase = {
49
+ ...TextPipelineUseCase,
50
+ ...VisionPipelineUseCase,
51
+ ...AudioPipelineUseCase,
52
+ ...MultimodalPipelineUseCase
53
+ };
9
54
 
10
55
  // src/hf-transformers/common/HFT_ModelSchema.ts
11
56
  import { ModelConfigSchema, ModelRecordSchema } from "@workglow/ai";
@@ -121,54 +166,6 @@ var HfTransformersOnnxModelConfigSchema = {
121
166
  additionalProperties: false
122
167
  };
123
168
 
124
- // src/hf-transformers/HuggingFaceTransformersProvider.ts
125
- import {
126
- AiProvider
127
- } from "@workglow/ai";
128
- class HuggingFaceTransformersProvider extends AiProvider {
129
- name = HF_TRANSFORMERS_ONNX;
130
- isLocal = true;
131
- supportsBrowser = true;
132
- taskTypes = [
133
- "DownloadModelTask",
134
- "UnloadModelTask",
135
- "ModelInfoTask",
136
- "CountTokensTask",
137
- "TextEmbeddingTask",
138
- "TextGenerationTask",
139
- "TextQuestionAnswerTask",
140
- "TextLanguageDetectionTask",
141
- "TextClassificationTask",
142
- "TextFillMaskTask",
143
- "TextNamedEntityRecognitionTask",
144
- "TextRewriterTask",
145
- "TextSummaryTask",
146
- "TextTranslationTask",
147
- "ImageSegmentationTask",
148
- "ImageToTextTask",
149
- "BackgroundRemovalTask",
150
- "ImageEmbeddingTask",
151
- "ImageClassificationTask",
152
- "ObjectDetectionTask",
153
- "ToolCallingTask"
154
- ];
155
- constructor(tasks, streamTasks, reactiveTasks) {
156
- super(tasks, streamTasks, reactiveTasks);
157
- }
158
- async onInitialize(options) {
159
- if (options.mode === "inline") {
160
- const { env } = await import("@huggingface/transformers");
161
- env.backends.onnx.wasm.proxy = true;
162
- }
163
- }
164
- async dispose() {
165
- if (this.tasks) {
166
- const { clearPipelineCache } = await import("./HFT_JobRunFns-yx418d60.js");
167
- clearPipelineCache();
168
- }
169
- }
170
- }
171
-
172
- export { HfTransformersOnnxModelSchema, HfTransformersOnnxModelRecordSchema, HfTransformersOnnxModelConfigSchema, HuggingFaceTransformersProvider };
169
+ export { HF_TRANSFORMERS_ONNX, HTF_CACHE_NAME, QuantizationDataType, TextPipelineUseCase, VisionPipelineUseCase, AudioPipelineUseCase, MultimodalPipelineUseCase, PipelineUseCase, HfTransformersOnnxModelSchema, HfTransformersOnnxModelRecordSchema, HfTransformersOnnxModelConfigSchema };
173
170
 
174
- //# debugId=47194B552DCD4CBC64756E2164756E21
171
+ //# debugId=633B1866FC05294D64756E2164756E21
@@ -0,0 +1,11 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/hf-transformers/common/HFT_Constants.ts", "../src/hf-transformers/common/HFT_ModelSchema.ts"],
4
+ "sourcesContent": [
5
+ "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nexport const HF_TRANSFORMERS_ONNX = \"HF_TRANSFORMERS_ONNX\";\nexport const HTF_CACHE_NAME = \"transformers-cache\";\n\nexport type QuantizationDataType =\n | \"auto\" // Auto-detect based on environment\n | \"fp32\"\n | \"fp16\"\n | \"q8\"\n | \"int8\"\n | \"uint8\"\n | \"q4\"\n | \"bnb4\"\n | \"q4f16\"; // fp16 model with int4 block weight quantization\n\nexport const QuantizationDataType = {\n auto: \"auto\",\n fp32: \"fp32\",\n fp16: \"fp16\",\n q8: \"q8\",\n int8: \"int8\",\n uint8: \"uint8\",\n q4: \"q4\",\n bnb4: \"bnb4\",\n q4f16: \"q4f16\",\n} as const satisfies Record<QuantizationDataType, QuantizationDataType>;\n\nexport type TextPipelineUseCase =\n | \"fill-mask\" // https://huggingface.co/tasks/fill-mask\n | \"token-classification\" // https://huggingface.co/tasks/token-classification\n | \"text-generation\" // https://huggingface.co/tasks/text-generation#completion-generation-models\n | \"text2text-generation\" // https://huggingface.co/tasks/text-generation#text-to-text-generation-models\n | \"text-classification\" // https://huggingface.co/tasks/text-classification\n | \"summarization\" // https://huggingface.co/tasks/sentence-similarity\n | \"translation\" // https://huggingface.co/tasks/translation\n | \"feature-extraction\" // https://huggingface.co/tasks/feature-extraction\n | \"zero-shot-classification\" // https://huggingface.co/tasks/zero-shot-classification\n | \"question-answering\"; // https://huggingface.co/tasks/question-answering\n\nexport const TextPipelineUseCase = {\n \"fill-mask\": \"fill-mask\",\n \"token-classification\": \"token-classification\",\n \"text-generation\": \"text-generation\",\n \"text2text-generation\": \"text2text-generation\",\n \"text-classification\": \"text-classification\",\n summarization: \"summarization\",\n translation: \"translation\",\n \"feature-extraction\": \"feature-extraction\",\n \"zero-shot-classification\": \"zero-shot-classification\",\n \"question-answering\": \"question-answering\",\n} as const satisfies Record<TextPipelineUseCase, TextPipelineUseCase>;\n\nexport type VisionPipelineUseCase =\n | \"background-removal\" // https://huggingface.co/tasks/image-segmentation#background-removal\n | \"image-segmentation\" // https://huggingface.co/tasks/image-segmentation\n | \"depth-estimation\" // https://huggingface.co/tasks/depth-estimation\n | \"image-classification\" // https://huggingface.co/tasks/image-classification\n | \"image-to-image\" // https://huggingface.co/tasks/image-to-image\n | \"object-detection\" // https://huggingface.co/tasks/object-detection\n | \"image-feature-extraction\"; // https://huggingface.co/tasks/image-feature-extraction\n\nexport const VisionPipelineUseCase = {\n \"background-removal\": \"background-removal\",\n \"image-segmentation\": \"image-segmentation\",\n \"depth-estimation\": \"depth-estimation\",\n \"image-classification\": \"image-classification\",\n \"image-to-image\": \"image-to-image\",\n \"object-detection\": \"object-detection\",\n \"image-feature-extraction\": \"image-feature-extraction\",\n} as const satisfies Record<VisionPipelineUseCase, VisionPipelineUseCase>;\n\nexport type AudioPipelineUseCase =\n | \"audio-classification\" // https://huggingface.co/tasks/audio-classification\n | \"automatic-speech-recognition\" // https://huggingface.co/tasks/automatic-speech-recognition\n | \"text-to-speech\"; // https://huggingface.co/tasks/text-to-speech\n\nexport const AudioPipelineUseCase = {\n \"audio-classification\": \"audio-classification\",\n \"automatic-speech-recognition\": \"automatic-speech-recognition\",\n \"text-to-speech\": \"text-to-speech\",\n} as const satisfies Record<AudioPipelineUseCase, AudioPipelineUseCase>;\n\nexport type MultimodalPipelineUseCase =\n | \"document-question-answering\" // https://huggingface.co/tasks/document-question-answering\n | \"image-to-text\" // https://huggingface.co/tasks/image-to-text\n | \"zero-shot-audio-classification\" // https://huggingface.co/tasks/zero-shot-audio-classification\n | \"zero-shot-image-classification\" // https://huggingface.co/tasks/zero-shot-image-classification\n | \"zero-shot-object-detection\"; // https://huggingface.co/tasks/zero-shot-object-detection\n\nexport const MultimodalPipelineUseCase = {\n \"document-question-answering\": \"document-question-answering\",\n \"image-to-text\": \"image-to-text\",\n \"zero-shot-audio-classification\": \"zero-shot-audio-classification\",\n \"zero-shot-image-classification\": \"zero-shot-image-classification\",\n \"zero-shot-object-detection\": \"zero-shot-object-detection\",\n} as const satisfies Record<MultimodalPipelineUseCase, MultimodalPipelineUseCase>;\n\nexport type PipelineUseCase =\n | TextPipelineUseCase\n | VisionPipelineUseCase\n | AudioPipelineUseCase\n | MultimodalPipelineUseCase;\n\nexport const PipelineUseCase = {\n ...TextPipelineUseCase,\n ...VisionPipelineUseCase,\n ...AudioPipelineUseCase,\n ...MultimodalPipelineUseCase,\n} as const satisfies Record<PipelineUseCase, PipelineUseCase>;\n",
6
+ "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { ModelConfigSchema, ModelRecordSchema } from \"@workglow/ai\";\nimport { DataPortSchemaObject, FromSchema } from \"@workglow/util\";\nimport { HF_TRANSFORMERS_ONNX, PipelineUseCase, QuantizationDataType } from \"./HFT_Constants\";\n\nexport const HfTransformersOnnxModelSchema = {\n type: \"object\",\n properties: {\n provider: {\n const: HF_TRANSFORMERS_ONNX,\n description: \"Discriminator: ONNX runtime backend.\",\n },\n provider_config: {\n type: \"object\",\n description: \"ONNX runtime-specific options.\",\n properties: {\n pipeline: {\n type: \"string\",\n enum: Object.values(PipelineUseCase),\n description: \"Pipeline type for the ONNX model.\",\n default: \"text-generation\",\n },\n model_path: {\n type: \"string\",\n description: \"Filesystem path or URI for the ONNX model.\",\n },\n dtype: {\n type: \"string\",\n enum: Object.values(QuantizationDataType),\n description: \"Data type for the ONNX model.\",\n default: \"auto\",\n },\n device: {\n type: \"string\",\n enum: [\"cpu\", \"gpu\", \"webgpu\", \"wasm\", \"metal\"],\n description: \"High-level device selection.\",\n default: \"webgpu\",\n },\n execution_providers: {\n type: \"array\",\n items: { type: \"string\" },\n description: \"Raw ONNX Runtime execution provider identifiers.\",\n \"x-ui-hidden\": true,\n },\n intra_op_num_threads: {\n type: \"integer\",\n minimum: 1,\n },\n inter_op_num_threads: {\n type: \"integer\",\n minimum: 1,\n },\n use_external_data_format: {\n type: \"boolean\",\n description: \"Whether the model uses external data format.\",\n },\n native_dimensions: {\n type: \"integer\",\n description: \"The native dimensions of the model.\",\n },\n pooling: {\n type: \"string\",\n enum: [\"mean\", \"last_token\", \"cls\"],\n description: \"The pooling strategy to use for the model.\",\n default: \"mean\",\n },\n normalize: {\n type: \"boolean\",\n description: \"Whether the model uses normalization.\",\n default: true,\n },\n language_style: {\n type: \"string\",\n description: \"The language style of the model.\",\n },\n mrl: {\n type: \"boolean\",\n description: \"Whether the model uses matryoshka.\",\n default: false,\n },\n },\n required: [\"model_path\", \"pipeline\"],\n additionalProperties: false,\n if: {\n properties: {\n pipeline: {\n const: \"feature-extraction\",\n },\n },\n },\n then: {\n required: [\"native_dimensions\"],\n },\n },\n },\n required: [\"provider\", \"provider_config\"],\n additionalProperties: true,\n} as const satisfies DataPortSchemaObject;\n\nexport const HfTransformersOnnxModelRecordSchema = {\n type: \"object\",\n properties: {\n ...ModelRecordSchema.properties,\n ...HfTransformersOnnxModelSchema.properties,\n },\n required: [...ModelRecordSchema.required, ...HfTransformersOnnxModelSchema.required],\n additionalProperties: false,\n} as const satisfies DataPortSchemaObject;\n\nexport type HfTransformersOnnxModelRecord = FromSchema<typeof HfTransformersOnnxModelRecordSchema>;\n\nexport const HfTransformersOnnxModelConfigSchema = {\n type: \"object\",\n properties: {\n ...ModelConfigSchema.properties,\n ...HfTransformersOnnxModelSchema.properties,\n },\n required: [...ModelConfigSchema.required, ...HfTransformersOnnxModelSchema.required],\n additionalProperties: false,\n} as const satisfies DataPortSchemaObject;\n\nexport type HfTransformersOnnxModelConfig = FromSchema<typeof HfTransformersOnnxModelConfigSchema>;\n"
7
+ ],
8
+ "mappings": ";AAMO,IAAM,uBAAuB;AAC7B,IAAM,iBAAiB;AAavB,IAAM,uBAAuB;AAAA,EAClC,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AAAA,EACN,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,OAAO;AAAA,EACP,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,OAAO;AACT;AAcO,IAAM,sBAAsB;AAAA,EACjC,aAAa;AAAA,EACb,wBAAwB;AAAA,EACxB,mBAAmB;AAAA,EACnB,wBAAwB;AAAA,EACxB,uBAAuB;AAAA,EACvB,eAAe;AAAA,EACf,aAAa;AAAA,EACb,sBAAsB;AAAA,EACtB,4BAA4B;AAAA,EAC5B,sBAAsB;AACxB;AAWO,IAAM,wBAAwB;AAAA,EACnC,sBAAsB;AAAA,EACtB,sBAAsB;AAAA,EACtB,oBAAoB;AAAA,EACpB,wBAAwB;AAAA,EACxB,kBAAkB;AAAA,EAClB,oBAAoB;AAAA,EACpB,4BAA4B;AAC9B;AAOO,IAAM,uBAAuB;AAAA,EAClC,wBAAwB;AAAA,EACxB,gCAAgC;AAAA,EAChC,kBAAkB;AACpB;AASO,IAAM,4BAA4B;AAAA,EACvC,+BAA+B;AAAA,EAC/B,iBAAiB;AAAA,EACjB,kCAAkC;AAAA,EAClC,kCAAkC;AAAA,EAClC,8BAA8B;AAChC;AAQO,IAAM,kBAAkB;AAAA,KAC1B;AAAA,KACA;AAAA,KACA;AAAA,KACA;AACL;;;AC3GA;AAIO,IAAM,gC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;AAAA,QACf;AAAA,QACA,KAAK;AAAA,UACH,MAAM;AAAA,UACN,aAAa;AAAA,UACb,SAAS;AAAA,QACX;AAAA,MACF;AAAA,MACA,UAAU,CAAC,cAAc,UAAU;AAAA,MACnC,sBAAsB;AAAA,MACtB,IAAI;AAAA,QACF,YAAY;AAAA,UACV,UAAU;AAAA,YACR,OAAO;AAAA,UACT;AAAA,QACF;AAAA,MACF;AAAA,MACA,MAAM;AAAA,QACJ,UAAU,CAAC,mBAAmB;AAAA,MAChC;AAAA,IACF;AAAA,EACF;AAAA,EACA,UAAU,CAAC,YAAY,iBAAiB;AAAA,EACxC,sBAAsB;AACxB;AAEO,IAAM,sCAAsC;AAAA,EACjD,MAAM;AAAA,EACN,YAAY;AAAA,OACP,kBAAkB;AAAA,OAClB,8BAA8B;AAAA,EACnC;AAAA,EACA,UAAU,CAAC,GAAG,kBAAkB,UAAU,GAAG,8BAA8B,QAAQ;AAAA,EACnF,sBAAsB;AACxB;AAIO,IAAM,sCAAsC;AAAA,EACjD,MAAM;AAAA,EACN,YAAY;AAAA,OACP,kBAAkB;AAAA,OAClB,8BAA8B;AAAA,EACnC;AAAA,EACA,UAAU,CAAC,GAAG,kBAAkB,UAAU,GAAG,8BAA8B,QAAQ;AAAA,EACnF,sBAAsB;AACxB;",
9
+ "debugId": "633B1866FC05294D64756E2164756E21",
10
+ "names": []
11
+ }
package/dist/index.js CHANGED
@@ -13,21 +13,21 @@ import {
13
13
  GoogleGeminiProvider
14
14
  } from "./index-8651nz8y.js";
15
15
  import {
16
- HfTransformersOnnxModelConfigSchema,
17
- HfTransformersOnnxModelRecordSchema,
18
- HfTransformersOnnxModelSchema,
19
16
  HuggingFaceTransformersProvider
20
- } from "./index-qett8dfp.js";
17
+ } from "./index-pkd79j8b.js";
21
18
  import {
22
19
  AudioPipelineUseCase,
23
20
  HF_TRANSFORMERS_ONNX,
24
21
  HTF_CACHE_NAME,
22
+ HfTransformersOnnxModelConfigSchema,
23
+ HfTransformersOnnxModelRecordSchema,
24
+ HfTransformersOnnxModelSchema,
25
25
  MultimodalPipelineUseCase,
26
26
  PipelineUseCase,
27
27
  QuantizationDataType,
28
28
  TextPipelineUseCase,
29
29
  VisionPipelineUseCase
30
- } from "./index-m0r2hvfz.js";
30
+ } from "./index-zqq3kw0n.js";
31
31
  import {
32
32
  LLAMACPP_DEFAULT_MODELS_DIR,
33
33
  LOCAL_LLAMACPP,
@@ -313,4 +313,4 @@ export {
313
313
  ANTHROPIC
314
314
  };
315
315
 
316
- //# debugId=4ADAB0FC0AAA2E9564756E2164756E21
316
+ //# debugId=DA4C6EECCF0011FD64756E2164756E21
package/dist/index.js.map CHANGED
@@ -10,6 +10,6 @@
10
10
  "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {\n AiProvider,\n type AiProviderReactiveRunFn,\n type AiProviderRunFn,\n type AiProviderStreamFn,\n} from \"@workglow/ai\";\nimport { WEB_BROWSER } from \"./common/WebBrowser_Constants\";\nimport type { WebBrowserModelConfig } from \"./common/WebBrowser_ModelSchema\";\n\n/**\n * AI provider for Chrome Built-in AI APIs (Gemini Nano on-device).\n *\n * Browser-only provider — no external SDK needed, the APIs are browser globals.\n *\n * Supports summarization, language detection, translation, text generation\n * (Prompt API), and text rewriting via Chrome's Built-in AI APIs.\n *\n * Task run functions are injected via the constructor so that the provider\n * class itself has no runtime dependency on Chrome globals (it can be\n * instantiated on the main thread in worker mode without errors).\n *\n * @example\n * ```typescript\n * // Worker mode (main thread) -- lightweight, no heavy imports:\n * await new WebBrowserProvider().register({\n * mode: \"worker\",\n * worker: new Worker(new URL(\"./worker_web_browser.ts\", import.meta.url), { type: \"module\" }),\n * });\n *\n * // Inline mode -- caller provides the tasks:\n * import { WEB_BROWSER_TASKS, WEB_BROWSER_STREAM_TASKS } from \"@workglow/ai-provider/web-browser\";\n * await new WebBrowserProvider(WEB_BROWSER_TASKS, WEB_BROWSER_STREAM_TASKS).register({ mode: \"inline\" });\n * ```\n */\nexport class WebBrowserProvider extends AiProvider<WebBrowserModelConfig> {\n readonly name = WEB_BROWSER;\n readonly isLocal = true;\n readonly supportsBrowser = true;\n\n readonly taskTypes = [\n \"ModelInfoTask\",\n \"TextSummaryTask\",\n \"TextLanguageDetectionTask\",\n \"TextTranslationTask\",\n \"TextGenerationTask\",\n \"TextRewriterTask\",\n ] as const;\n\n constructor(\n tasks?: Record<string, AiProviderRunFn<any, any, WebBrowserModelConfig>>,\n streamTasks?: Record<string, AiProviderStreamFn<any, any, WebBrowserModelConfig>>,\n reactiveTasks?: Record<string, AiProviderReactiveRunFn<any, any, WebBrowserModelConfig>>\n ) {\n super(tasks, streamTasks, reactiveTasks);\n }\n}\n"
11
11
  ],
12
12
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMO,IAAM,uBAAuB;AAsB7B,IAAM,mBAAmB;AAAA,EAC9B,iBAAiB;AAAA,EACjB,mBAAmB;AAAA,EACnB,0BAA0B;AAAA,EAC1B,cAAc;AAAA,EACd,oBAAoB;AAAA,EACpB,kBAAkB;AAAA,EAClB,wBAAwB;AAAA,EACxB,0BAA0B;AAAA,EAC1B,wBAAwB;AAAA,EACxB,6BAA6B;AAAA,EAC7B,0BAA0B;AAAA,EAC1B,8BAA8B;AAAA,EAC9B,2BAA2B;AAAA,EAC3B,yBAAyB;AAAA,EACzB,0BAA0B;AAAA,EAC1B,sCAAsC;AAAA,EACtC,0BAA0B;AAAA,EAC1B,0BAA0B;AAC5B;;ACzCO,IAAM,cAAc;AASpB,IAAM,yBAAyB;AAAA,EACpC,YAAY;AAAA,EACZ,qBAAqB;AAAA,EACrB,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,UAAU;AACZ;;ACfA;AAIO,IAAM,kBAAkB;AAAA,EAC7B,MAAM;AAAA,EACN,YAAY;AAAA,IACV,UAAU;AAAA,MACR,OAAO;AAAA,M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AAA,IACA;AAAA,EACF;AAAA,EAEA,WAAW,CACT,OACA,eACA;AAAA,IACA,MAAM,OAAO,WAAW,aAAa;AAAA;AAEzC;;AC3DA;AAAA,gBACE;AAAA;AAiCK,MAAM,2BAA2B,YAAkC;AAAA,EAC/D,OAAO;AAAA,EACP,UAAU;AAAA,EACV,kBAAkB;AAAA,EAElB,YAAY;AAAA,IACnB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EAEA,WAAW,CACT,OACA,aACA,eACA;AAAA,IACA,MAAM,OAAO,aAAa,aAAa;AAAA;AAE3C;",
13
- "debugId": "4ADAB0FC0AAA2E9564756E2164756E21",
13
+ "debugId": "DA4C6EECCF0011FD64756E2164756E21",
14
14
  "names": []
15
15
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@workglow/ai-provider",
3
3
  "type": "module",
4
4
  "sideEffects": false,
5
- "version": "0.0.118",
5
+ "version": "0.0.120",
6
6
  "description": "AI provider integrations for Workglow, supporting OpenAI, Hugging Face Transformers, MediaPipe, and GGML models.",
7
7
  "scripts": {
8
8
  "watch": "concurrently -c 'auto' 'bun:watch-*'",
@@ -78,21 +78,21 @@
78
78
  "access": "public"
79
79
  },
80
80
  "peerDependencies": {
81
- "@workglow/ai": "0.0.118",
82
- "@workglow/job-queue": "0.0.118",
83
- "@workglow/storage": "0.0.118",
84
- "@workglow/task-graph": "0.0.118",
85
- "@workglow/util": "0.0.118",
81
+ "@workglow/ai": "0.0.120",
82
+ "@workglow/job-queue": "0.0.120",
83
+ "@workglow/storage": "0.0.120",
84
+ "@workglow/task-graph": "0.0.120",
85
+ "@workglow/util": "0.0.120",
86
86
  "@huggingface/transformers": "4.0.0-next.7",
87
87
  "@mediapipe/tasks-text": "^0.10.32",
88
88
  "@mediapipe/tasks-vision": "^0.10.32",
89
89
  "@mediapipe/tasks-audio": "^0.10.32",
90
90
  "@mediapipe/tasks-genai": "^0.10.26",
91
- "openai": "^6.27.0",
91
+ "openai": "^6.32.0",
92
92
  "tiktoken": "^1.0.22",
93
- "@anthropic-ai/sdk": "^0.78.0",
93
+ "@anthropic-ai/sdk": "^0.80.0",
94
94
  "@google/generative-ai": "^0.24.1",
95
- "node-llama-cpp": "^3.17.1",
95
+ "node-llama-cpp": "^3.18.1",
96
96
  "@huggingface/inference": "^4.13.15",
97
97
  "ollama": "^0.6.3"
98
98
  },
@@ -150,7 +150,7 @@
150
150
  }
151
151
  },
152
152
  "devDependencies": {
153
- "@anthropic-ai/sdk": "^0.78.0",
153
+ "@anthropic-ai/sdk": "^0.80.0",
154
154
  "@google/generative-ai": "^0.24.1",
155
155
  "@huggingface/inference": "^4.13.15",
156
156
  "@mediapipe/tasks-audio": "^0.10.32",
@@ -158,14 +158,14 @@
158
158
  "@mediapipe/tasks-text": "^0.10.32",
159
159
  "@mediapipe/tasks-vision": "^0.10.32",
160
160
  "@huggingface/transformers": "4.0.0-next.7",
161
- "@workglow/ai": "0.0.118",
162
- "@workglow/job-queue": "0.0.118",
163
- "@workglow/storage": "0.0.118",
164
- "@workglow/task-graph": "0.0.118",
165
- "@workglow/util": "0.0.118",
166
- "node-llama-cpp": "^3.17.1",
161
+ "@workglow/ai": "0.0.120",
162
+ "@workglow/job-queue": "0.0.120",
163
+ "@workglow/storage": "0.0.120",
164
+ "@workglow/task-graph": "0.0.120",
165
+ "@workglow/util": "0.0.120",
166
+ "node-llama-cpp": "^3.18.1",
167
167
  "ollama": "^0.6.3",
168
- "openai": "^6.27.0",
168
+ "openai": "^6.32.0",
169
169
  "tiktoken": "^1.0.22"
170
170
  }
171
171
  }
@@ -1,57 +0,0 @@
1
- // src/hf-transformers/common/HFT_Constants.ts
2
- var HF_TRANSFORMERS_ONNX = "HF_TRANSFORMERS_ONNX";
3
- var HTF_CACHE_NAME = "transformers-cache";
4
- var QuantizationDataType = {
5
- auto: "auto",
6
- fp32: "fp32",
7
- fp16: "fp16",
8
- q8: "q8",
9
- int8: "int8",
10
- uint8: "uint8",
11
- q4: "q4",
12
- bnb4: "bnb4",
13
- q4f16: "q4f16"
14
- };
15
- var TextPipelineUseCase = {
16
- "fill-mask": "fill-mask",
17
- "token-classification": "token-classification",
18
- "text-generation": "text-generation",
19
- "text2text-generation": "text2text-generation",
20
- "text-classification": "text-classification",
21
- summarization: "summarization",
22
- translation: "translation",
23
- "feature-extraction": "feature-extraction",
24
- "zero-shot-classification": "zero-shot-classification",
25
- "question-answering": "question-answering"
26
- };
27
- var VisionPipelineUseCase = {
28
- "background-removal": "background-removal",
29
- "image-segmentation": "image-segmentation",
30
- "depth-estimation": "depth-estimation",
31
- "image-classification": "image-classification",
32
- "image-to-image": "image-to-image",
33
- "object-detection": "object-detection",
34
- "image-feature-extraction": "image-feature-extraction"
35
- };
36
- var AudioPipelineUseCase = {
37
- "audio-classification": "audio-classification",
38
- "automatic-speech-recognition": "automatic-speech-recognition",
39
- "text-to-speech": "text-to-speech"
40
- };
41
- var MultimodalPipelineUseCase = {
42
- "document-question-answering": "document-question-answering",
43
- "image-to-text": "image-to-text",
44
- "zero-shot-audio-classification": "zero-shot-audio-classification",
45
- "zero-shot-image-classification": "zero-shot-image-classification",
46
- "zero-shot-object-detection": "zero-shot-object-detection"
47
- };
48
- var PipelineUseCase = {
49
- ...TextPipelineUseCase,
50
- ...VisionPipelineUseCase,
51
- ...AudioPipelineUseCase,
52
- ...MultimodalPipelineUseCase
53
- };
54
-
55
- export { HF_TRANSFORMERS_ONNX, HTF_CACHE_NAME, QuantizationDataType, TextPipelineUseCase, VisionPipelineUseCase, AudioPipelineUseCase, MultimodalPipelineUseCase, PipelineUseCase };
56
-
57
- //# debugId=297B2C0A21F958E264756E2164756E21
@@ -1,10 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/hf-transformers/common/HFT_Constants.ts"],
4
- "sourcesContent": [
5
- "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nexport const HF_TRANSFORMERS_ONNX = \"HF_TRANSFORMERS_ONNX\";\nexport const HTF_CACHE_NAME = \"transformers-cache\";\n\nexport type QuantizationDataType =\n | \"auto\" // Auto-detect based on environment\n | \"fp32\"\n | \"fp16\"\n | \"q8\"\n | \"int8\"\n | \"uint8\"\n | \"q4\"\n | \"bnb4\"\n | \"q4f16\"; // fp16 model with int4 block weight quantization\n\nexport const QuantizationDataType = {\n auto: \"auto\",\n fp32: \"fp32\",\n fp16: \"fp16\",\n q8: \"q8\",\n int8: \"int8\",\n uint8: \"uint8\",\n q4: \"q4\",\n bnb4: \"bnb4\",\n q4f16: \"q4f16\",\n} as const satisfies Record<QuantizationDataType, QuantizationDataType>;\n\nexport type TextPipelineUseCase =\n | \"fill-mask\" // https://huggingface.co/tasks/fill-mask\n | \"token-classification\" // https://huggingface.co/tasks/token-classification\n | \"text-generation\" // https://huggingface.co/tasks/text-generation#completion-generation-models\n | \"text2text-generation\" // https://huggingface.co/tasks/text-generation#text-to-text-generation-models\n | \"text-classification\" // https://huggingface.co/tasks/text-classification\n | \"summarization\" // https://huggingface.co/tasks/sentence-similarity\n | \"translation\" // https://huggingface.co/tasks/translation\n | \"feature-extraction\" // https://huggingface.co/tasks/feature-extraction\n | \"zero-shot-classification\" // https://huggingface.co/tasks/zero-shot-classification\n | \"question-answering\"; // https://huggingface.co/tasks/question-answering\n\nexport const TextPipelineUseCase = {\n \"fill-mask\": \"fill-mask\",\n \"token-classification\": \"token-classification\",\n \"text-generation\": \"text-generation\",\n \"text2text-generation\": \"text2text-generation\",\n \"text-classification\": \"text-classification\",\n summarization: \"summarization\",\n translation: \"translation\",\n \"feature-extraction\": \"feature-extraction\",\n \"zero-shot-classification\": \"zero-shot-classification\",\n \"question-answering\": \"question-answering\",\n} as const satisfies Record<TextPipelineUseCase, TextPipelineUseCase>;\n\nexport type VisionPipelineUseCase =\n | \"background-removal\" // https://huggingface.co/tasks/image-segmentation#background-removal\n | \"image-segmentation\" // https://huggingface.co/tasks/image-segmentation\n | \"depth-estimation\" // https://huggingface.co/tasks/depth-estimation\n | \"image-classification\" // https://huggingface.co/tasks/image-classification\n | \"image-to-image\" // https://huggingface.co/tasks/image-to-image\n | \"object-detection\" // https://huggingface.co/tasks/object-detection\n | \"image-feature-extraction\"; // https://huggingface.co/tasks/image-feature-extraction\n\nexport const VisionPipelineUseCase = {\n \"background-removal\": \"background-removal\",\n \"image-segmentation\": \"image-segmentation\",\n \"depth-estimation\": \"depth-estimation\",\n \"image-classification\": \"image-classification\",\n \"image-to-image\": \"image-to-image\",\n \"object-detection\": \"object-detection\",\n \"image-feature-extraction\": \"image-feature-extraction\",\n} as const satisfies Record<VisionPipelineUseCase, VisionPipelineUseCase>;\n\nexport type AudioPipelineUseCase =\n | \"audio-classification\" // https://huggingface.co/tasks/audio-classification\n | \"automatic-speech-recognition\" // https://huggingface.co/tasks/automatic-speech-recognition\n | \"text-to-speech\"; // https://huggingface.co/tasks/text-to-speech\n\nexport const AudioPipelineUseCase = {\n \"audio-classification\": \"audio-classification\",\n \"automatic-speech-recognition\": \"automatic-speech-recognition\",\n \"text-to-speech\": \"text-to-speech\",\n} as const satisfies Record<AudioPipelineUseCase, AudioPipelineUseCase>;\n\nexport type MultimodalPipelineUseCase =\n | \"document-question-answering\" // https://huggingface.co/tasks/document-question-answering\n | \"image-to-text\" // https://huggingface.co/tasks/image-to-text\n | \"zero-shot-audio-classification\" // https://huggingface.co/tasks/zero-shot-audio-classification\n | \"zero-shot-image-classification\" // https://huggingface.co/tasks/zero-shot-image-classification\n | \"zero-shot-object-detection\"; // https://huggingface.co/tasks/zero-shot-object-detection\n\nexport const MultimodalPipelineUseCase = {\n \"document-question-answering\": \"document-question-answering\",\n \"image-to-text\": \"image-to-text\",\n \"zero-shot-audio-classification\": \"zero-shot-audio-classification\",\n \"zero-shot-image-classification\": \"zero-shot-image-classification\",\n \"zero-shot-object-detection\": \"zero-shot-object-detection\",\n} as const satisfies Record<MultimodalPipelineUseCase, MultimodalPipelineUseCase>;\n\nexport type PipelineUseCase =\n | TextPipelineUseCase\n | VisionPipelineUseCase\n | AudioPipelineUseCase\n | MultimodalPipelineUseCase;\n\nexport const PipelineUseCase = {\n ...TextPipelineUseCase,\n ...VisionPipelineUseCase,\n ...AudioPipelineUseCase,\n ...MultimodalPipelineUseCase,\n} as const satisfies Record<PipelineUseCase, PipelineUseCase>;\n"
6
- ],
7
- "mappings": ";AAMO,IAAM,uBAAuB;AAC7B,IAAM,iBAAiB;AAavB,IAAM,uBAAuB;AAAA,EAClC,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AAAA,EACN,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,OAAO;AAAA,EACP,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,OAAO;AACT;AAcO,IAAM,sBAAsB;AAAA,EACjC,aAAa;AAAA,EACb,wBAAwB;AAAA,EACxB,mBAAmB;AAAA,EACnB,wBAAwB;AAAA,EACxB,uBAAuB;AAAA,EACvB,eAAe;AAAA,EACf,aAAa;AAAA,EACb,sBAAsB;AAAA,EACtB,4BAA4B;AAAA,EAC5B,sBAAsB;AACxB;AAWO,IAAM,wBAAwB;AAAA,EACnC,sBAAsB;AAAA,EACtB,sBAAsB;AAAA,EACtB,oBAAoB;AAAA,EACpB,wBAAwB;AAAA,EACxB,kBAAkB;AAAA,EAClB,oBAAoB;AAAA,EACpB,4BAA4B;AAC9B;AAOO,IAAM,uBAAuB;AAAA,EAClC,wBAAwB;AAAA,EACxB,gCAAgC;AAAA,EAChC,kBAAkB;AACpB;AASO,IAAM,4BAA4B;AAAA,EACvC,+BAA+B;AAAA,EAC/B,iBAAiB;AAAA,EACjB,kCAAkC;AAAA,EAClC,kCAAkC;AAAA,EAClC,8BAA8B;AAChC;AAQO,IAAM,kBAAkB;AAAA,KAC1B;AAAA,KACA;AAAA,KACA;AAAA,KACA;AACL;",
8
- "debugId": "297B2C0A21F958E264756E2164756E21",
9
- "names": []
10
- }
@@ -1,11 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/hf-transformers/common/HFT_ModelSchema.ts", "../src/hf-transformers/HuggingFaceTransformersProvider.ts"],
4
- "sourcesContent": [
5
- "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { ModelConfigSchema, ModelRecordSchema } from \"@workglow/ai\";\nimport { DataPortSchemaObject, FromSchema } from \"@workglow/util\";\nimport { HF_TRANSFORMERS_ONNX, PipelineUseCase, QuantizationDataType } from \"./HFT_Constants\";\n\nexport const HfTransformersOnnxModelSchema = {\n type: \"object\",\n properties: {\n provider: {\n const: HF_TRANSFORMERS_ONNX,\n description: \"Discriminator: ONNX runtime backend.\",\n },\n provider_config: {\n type: \"object\",\n description: \"ONNX runtime-specific options.\",\n properties: {\n pipeline: {\n type: \"string\",\n enum: Object.values(PipelineUseCase),\n description: \"Pipeline type for the ONNX model.\",\n default: \"text-generation\",\n },\n model_path: {\n type: \"string\",\n description: \"Filesystem path or URI for the ONNX model.\",\n },\n dtype: {\n type: \"string\",\n enum: Object.values(QuantizationDataType),\n description: \"Data type for the ONNX model.\",\n default: \"auto\",\n },\n device: {\n type: \"string\",\n enum: [\"cpu\", \"gpu\", \"webgpu\", \"wasm\", \"metal\"],\n description: \"High-level device selection.\",\n default: \"webgpu\",\n },\n execution_providers: {\n type: \"array\",\n items: { type: \"string\" },\n description: \"Raw ONNX Runtime execution provider identifiers.\",\n \"x-ui-hidden\": true,\n },\n intra_op_num_threads: {\n type: \"integer\",\n minimum: 1,\n },\n inter_op_num_threads: {\n type: \"integer\",\n minimum: 1,\n },\n use_external_data_format: {\n type: \"boolean\",\n description: \"Whether the model uses external data format.\",\n },\n native_dimensions: {\n type: \"integer\",\n description: \"The native dimensions of the model.\",\n },\n pooling: {\n type: \"string\",\n enum: [\"mean\", \"last_token\", \"cls\"],\n description: \"The pooling strategy to use for the model.\",\n default: \"mean\",\n },\n normalize: {\n type: \"boolean\",\n description: \"Whether the model uses normalization.\",\n default: true,\n },\n language_style: {\n type: \"string\",\n description: \"The language style of the model.\",\n },\n mrl: {\n type: \"boolean\",\n description: \"Whether the model uses matryoshka.\",\n default: false,\n },\n },\n required: [\"model_path\", \"pipeline\"],\n additionalProperties: false,\n if: {\n properties: {\n pipeline: {\n const: \"feature-extraction\",\n },\n },\n },\n then: {\n required: [\"native_dimensions\"],\n },\n },\n },\n required: [\"provider\", \"provider_config\"],\n additionalProperties: true,\n} as const satisfies DataPortSchemaObject;\n\nexport const HfTransformersOnnxModelRecordSchema = {\n type: \"object\",\n properties: {\n ...ModelRecordSchema.properties,\n ...HfTransformersOnnxModelSchema.properties,\n },\n required: [...ModelRecordSchema.required, ...HfTransformersOnnxModelSchema.required],\n additionalProperties: false,\n} as const satisfies DataPortSchemaObject;\n\nexport type HfTransformersOnnxModelRecord = FromSchema<typeof HfTransformersOnnxModelRecordSchema>;\n\nexport const HfTransformersOnnxModelConfigSchema = {\n type: \"object\",\n properties: {\n ...ModelConfigSchema.properties,\n ...HfTransformersOnnxModelSchema.properties,\n },\n required: [...ModelConfigSchema.required, ...HfTransformersOnnxModelSchema.required],\n additionalProperties: false,\n} as const satisfies DataPortSchemaObject;\n\nexport type HfTransformersOnnxModelConfig = FromSchema<typeof HfTransformersOnnxModelConfigSchema>;\n",
6
- "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {\n AiProvider,\n type AiProviderReactiveRunFn,\n type AiProviderRegisterOptions,\n type AiProviderRunFn,\n type AiProviderStreamFn,\n} from \"@workglow/ai\";\nimport { HF_TRANSFORMERS_ONNX } from \"./common/HFT_Constants\";\nimport type { HfTransformersOnnxModelConfig } from \"./common/HFT_ModelSchema\";\n\n/**\n * AI provider for HuggingFace Transformers ONNX models.\n *\n * Supports text, vision, and multimodal tasks via the @huggingface/transformers library.\n *\n * Task run functions are injected via the constructor so that the heavy\n * `@huggingface/transformers` library is only imported where actually needed\n * (inline mode, worker server), not on the main thread in worker mode.\n *\n * @example\n * ```typescript\n * // Worker mode (main thread) -- lightweight, no heavy imports:\n * await new HuggingFaceTransformersProvider().register({\n * mode: \"worker\",\n * worker: new Worker(new URL(\"./worker_hft.ts\", import.meta.url), { type: \"module\" }),\n * });\n *\n * // Inline mode -- caller provides the tasks:\n * import { HFT_TASKS, HFT_STREAM_TASKS, HFT_REACTIVE_TASKS } from \"@workglow/ai-provider/hf-transformers\";\n * await new HuggingFaceTransformersProvider(HFT_TASKS, HFT_STREAM_TASKS, HFT_REACTIVE_TASKS).register({ mode: \"inline\" });\n *\n * // Worker side -- caller provides the tasks:\n * import { HFT_TASKS, HFT_STREAM_TASKS, HFT_REACTIVE_TASKS } from \"@workglow/ai-provider/hf-transformers\";\n * new HuggingFaceTransformersProvider(HFT_TASKS, HFT_STREAM_TASKS, HFT_REACTIVE_TASKS).registerOnWorkerServer(workerServer);\n * ```\n */\nexport class HuggingFaceTransformersProvider extends AiProvider<HfTransformersOnnxModelConfig> {\n readonly name = HF_TRANSFORMERS_ONNX;\n readonly isLocal = true;\n readonly supportsBrowser = true;\n\n readonly taskTypes = [\n \"DownloadModelTask\",\n \"UnloadModelTask\",\n \"ModelInfoTask\",\n \"CountTokensTask\",\n \"TextEmbeddingTask\",\n \"TextGenerationTask\",\n \"TextQuestionAnswerTask\",\n \"TextLanguageDetectionTask\",\n \"TextClassificationTask\",\n \"TextFillMaskTask\",\n \"TextNamedEntityRecognitionTask\",\n \"TextRewriterTask\",\n \"TextSummaryTask\",\n \"TextTranslationTask\",\n \"ImageSegmentationTask\",\n \"ImageToTextTask\",\n \"BackgroundRemovalTask\",\n \"ImageEmbeddingTask\",\n \"ImageClassificationTask\",\n \"ObjectDetectionTask\",\n \"ToolCallingTask\",\n ] as const;\n\n constructor(\n tasks?: Record<string, AiProviderRunFn<any, any, HfTransformersOnnxModelConfig>>,\n streamTasks?: Record<string, AiProviderStreamFn<any, any, HfTransformersOnnxModelConfig>>,\n reactiveTasks?: Record<string, AiProviderReactiveRunFn<any, any, HfTransformersOnnxModelConfig>>\n ) {\n super(tasks, streamTasks, reactiveTasks);\n }\n\n protected override async onInitialize(options: AiProviderRegisterOptions): Promise<void> {\n if (options.mode === \"inline\") {\n const { env } = await import(\"@huggingface/transformers\");\n // @ts-ignore -- backends.onnx.wasm.proxy is not fully typed\n env.backends.onnx.wasm.proxy = true;\n }\n }\n\n override async dispose(): Promise<void> {\n if (this.tasks) {\n const { clearPipelineCache } = await import(\"./common/HFT_JobRunFns\");\n clearPipelineCache();\n }\n }\n}\n"
7
- ],
8
- "mappings": ";;;;;;;;;;AAMA;AAIO,IAAM,gCAAgC;AAAA,EAC3C,MAAM;AAAA,EACN,YAAY;AAAA,IACV,UAAU;AAAA,MACR,OAAO;AAAA,MACP,aAAa;AAAA,IACf;AAAA,IACA,iBAAiB;AAAA,MACf,MAAM;AAAA,MACN,aAAa;AAAA,MACb,YAAY;AAAA,QACV,UAAU;AAAA,UACR,MAAM;AAAA,UACN,MAAM,OAAO,OAAO,eAAe;AAAA,UACnC,aAAa;AAAA,UACb,SAAS;AAAA,QACX;AAAA,QACA,YAAY;AAAA,UACV,MAAM;AAAA,UACN,aAAa;AAAA,QACf;AAAA,QACA,OAAO;AAAA,UACL,MAAM;AAAA,UACN,MAAM,OAAO,OAAO,oBAAoB;AAAA,UACxC,aAAa;AAAA,UACb,SAAS;AAAA,QACX;AAAA,QACA,QAAQ;AAAA,UACN,MAAM;AAAA,UACN,MAAM,CAAC,OAAO,OAAO,UAAU,QAAQ,OAAO;AAAA,UAC9C,aAAa;AAAA,UACb,SAAS;AAAA,QACX;AAAA,QACA,qBAAqB;AAAA,UACnB,MAAM;AAAA,UACN,OAAO,EAAE,MAAM,SAAS;AAAA,UACxB,aAAa;AAAA,UACb,eAAe;AAAA,QACjB;AAAA,QACA,sBAAsB;AAAA,UACpB,MAAM;AAAA,UACN,SAAS;AAAA,QACX;AAAA,QACA,sBAAsB;AAAA,UACpB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