@workglow/ai-provider 0.0.97 → 0.0.99
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/HFT_JobRunFns-ajak33q5.js +60 -0
- package/dist/HFT_JobRunFns-ajak33q5.js.map +9 -0
- package/dist/anthropic/index.js +11 -92
- package/dist/anthropic/index.js.map +4 -7
- package/dist/google-gemini/index.js +11 -103
- package/dist/google-gemini/index.js.map +4 -7
- package/dist/hf-transformers/common/HFT_JobRunFns.d.ts.map +1 -1
- package/dist/hf-transformers/index.js +46 -1080
- package/dist/hf-transformers/index.js.map +4 -9
- package/dist/index-2pvfsjyx.js +857 -0
- package/dist/index-2pvfsjyx.js.map +10 -0
- package/dist/index-34rcjm0y.js +78 -0
- package/dist/index-34rcjm0y.js.map +12 -0
- package/dist/index-9w5hs4zc.js +73 -0
- package/dist/index-9w5hs4zc.js.map +12 -0
- package/dist/index-jd3bbc2x.js +11 -0
- package/dist/index-jd3bbc2x.js.map +9 -0
- package/dist/index-kctzvn3c.js +75 -0
- package/dist/index-kctzvn3c.js.map +12 -0
- package/dist/index-m0r2hvfz.js +57 -0
- package/dist/index-m0r2hvfz.js.map +10 -0
- package/dist/index-rmbnv0rw.js +169 -0
- package/dist/index-rmbnv0rw.js.map +11 -0
- package/dist/index-tn88s0ke.js +71 -0
- package/dist/index-tn88s0ke.js.map +12 -0
- package/dist/index-wnmajxg6.js +86 -0
- package/dist/index-wnmajxg6.js.map +12 -0
- package/dist/index-xyavfrb8.js +97 -0
- package/dist/index-xyavfrb8.js.map +12 -0
- package/dist/index.browser-jd3bbc2x.js +11 -0
- package/dist/index.browser-jd3bbc2x.js.map +9 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +80 -1369
- package/dist/index.js.map +3 -20
- package/dist/provider-hf-inference/HFI_Worker.d.ts +7 -0
- package/dist/provider-hf-inference/HFI_Worker.d.ts.map +1 -0
- package/dist/provider-hf-inference/HfInferenceProvider.d.ts +40 -0
- package/dist/provider-hf-inference/HfInferenceProvider.d.ts.map +1 -0
- package/dist/provider-hf-inference/common/HFI_Constants.d.ts +7 -0
- package/dist/provider-hf-inference/common/HFI_Constants.d.ts.map +1 -0
- package/dist/provider-hf-inference/common/HFI_JobRunFns.d.ts +17 -0
- package/dist/provider-hf-inference/common/HFI_JobRunFns.d.ts.map +1 -0
- package/dist/provider-hf-inference/common/HFI_ModelSchema.d.ts +146 -0
- package/dist/provider-hf-inference/common/HFI_ModelSchema.d.ts.map +1 -0
- package/dist/provider-hf-inference/index.d.ts +11 -0
- package/dist/provider-hf-inference/index.d.ts.map +1 -0
- package/dist/provider-hf-inference/index.js +209 -0
- package/dist/provider-hf-inference/index.js.map +11 -0
- package/dist/provider-llamacpp/LlamaCppProvider.d.ts +38 -0
- package/dist/provider-llamacpp/LlamaCppProvider.d.ts.map +1 -0
- package/dist/provider-llamacpp/LlamaCpp_Worker.d.ts +7 -0
- package/dist/provider-llamacpp/LlamaCpp_Worker.d.ts.map +1 -0
- package/dist/provider-llamacpp/common/LlamaCpp_Constants.d.ts +8 -0
- package/dist/provider-llamacpp/common/LlamaCpp_Constants.d.ts.map +1 -0
- package/dist/provider-llamacpp/common/LlamaCpp_JobRunFns.d.ts +20 -0
- package/dist/provider-llamacpp/common/LlamaCpp_JobRunFns.d.ts.map +1 -0
- package/dist/provider-llamacpp/common/LlamaCpp_ModelSchema.d.ts +209 -0
- package/dist/provider-llamacpp/common/LlamaCpp_ModelSchema.d.ts.map +1 -0
- package/dist/provider-llamacpp/index.d.ts +11 -0
- package/dist/provider-llamacpp/index.d.ts.map +1 -0
- package/dist/provider-llamacpp/index.js +365 -0
- package/dist/provider-llamacpp/index.js.map +11 -0
- package/dist/provider-ollama/index.browser.js +4 -8
- package/dist/provider-ollama/index.browser.js.map +2 -2
- package/dist/provider-ollama/index.js +12 -88
- package/dist/provider-ollama/index.js.map +4 -7
- package/dist/provider-openai/index.js +11 -95
- package/dist/provider-openai/index.js.map +4 -7
- package/dist/tf-mediapipe/index.js +4 -8
- package/dist/tf-mediapipe/index.js.map +2 -2
- package/package.json +39 -18
- package/dist/ggml/server.d.ts +0 -2
- package/dist/ggml/server.d.ts.map +0 -1
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import {
|
|
2
|
+
HF_TRANSFORMERS_ONNX,
|
|
3
|
+
PipelineUseCase,
|
|
4
|
+
QuantizationDataType
|
|
5
|
+
} from "./index-m0r2hvfz.js";
|
|
6
|
+
import {
|
|
7
|
+
__require
|
|
8
|
+
} from "./index-jd3bbc2x.js";
|
|
9
|
+
|
|
10
|
+
// src/hf-transformers/common/HFT_ModelSchema.ts
|
|
11
|
+
import { ModelConfigSchema, ModelRecordSchema } from "@workglow/ai";
|
|
12
|
+
var HfTransformersOnnxModelSchema = {
|
|
13
|
+
type: "object",
|
|
14
|
+
properties: {
|
|
15
|
+
provider: {
|
|
16
|
+
const: HF_TRANSFORMERS_ONNX,
|
|
17
|
+
description: "Discriminator: ONNX runtime backend."
|
|
18
|
+
},
|
|
19
|
+
provider_config: {
|
|
20
|
+
type: "object",
|
|
21
|
+
description: "ONNX runtime-specific options.",
|
|
22
|
+
properties: {
|
|
23
|
+
pipeline: {
|
|
24
|
+
type: "string",
|
|
25
|
+
enum: Object.values(PipelineUseCase),
|
|
26
|
+
description: "Pipeline type for the ONNX model.",
|
|
27
|
+
default: "text-generation"
|
|
28
|
+
},
|
|
29
|
+
model_path: {
|
|
30
|
+
type: "string",
|
|
31
|
+
description: "Filesystem path or URI for the ONNX model."
|
|
32
|
+
},
|
|
33
|
+
dtype: {
|
|
34
|
+
type: "string",
|
|
35
|
+
enum: Object.values(QuantizationDataType),
|
|
36
|
+
description: "Data type for the ONNX model.",
|
|
37
|
+
default: "auto"
|
|
38
|
+
},
|
|
39
|
+
device: {
|
|
40
|
+
type: "string",
|
|
41
|
+
enum: ["cpu", "gpu", "webgpu", "wasm", "metal"],
|
|
42
|
+
description: "High-level device selection.",
|
|
43
|
+
default: "webgpu"
|
|
44
|
+
},
|
|
45
|
+
execution_providers: {
|
|
46
|
+
type: "array",
|
|
47
|
+
items: { type: "string" },
|
|
48
|
+
description: "Raw ONNX Runtime execution provider identifiers.",
|
|
49
|
+
"x-ui-hidden": true
|
|
50
|
+
},
|
|
51
|
+
intra_op_num_threads: {
|
|
52
|
+
type: "integer",
|
|
53
|
+
minimum: 1
|
|
54
|
+
},
|
|
55
|
+
inter_op_num_threads: {
|
|
56
|
+
type: "integer",
|
|
57
|
+
minimum: 1
|
|
58
|
+
},
|
|
59
|
+
use_external_data_format: {
|
|
60
|
+
type: "boolean",
|
|
61
|
+
description: "Whether the model uses external data format."
|
|
62
|
+
},
|
|
63
|
+
native_dimensions: {
|
|
64
|
+
type: "integer",
|
|
65
|
+
description: "The native dimensions of the model."
|
|
66
|
+
},
|
|
67
|
+
pooling: {
|
|
68
|
+
type: "string",
|
|
69
|
+
enum: ["mean", "last_token", "cls"],
|
|
70
|
+
description: "The pooling strategy to use for the model.",
|
|
71
|
+
default: "mean"
|
|
72
|
+
},
|
|
73
|
+
normalize: {
|
|
74
|
+
type: "boolean",
|
|
75
|
+
description: "Whether the model uses normalization.",
|
|
76
|
+
default: true
|
|
77
|
+
},
|
|
78
|
+
language_style: {
|
|
79
|
+
type: "string",
|
|
80
|
+
description: "The language style of the model."
|
|
81
|
+
},
|
|
82
|
+
mrl: {
|
|
83
|
+
type: "boolean",
|
|
84
|
+
description: "Whether the model uses matryoshka.",
|
|
85
|
+
default: false
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
required: ["model_path", "pipeline"],
|
|
89
|
+
additionalProperties: false,
|
|
90
|
+
if: {
|
|
91
|
+
properties: {
|
|
92
|
+
pipeline: {
|
|
93
|
+
const: "feature-extraction"
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
then: {
|
|
98
|
+
required: ["native_dimensions"]
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
required: ["provider", "provider_config"],
|
|
103
|
+
additionalProperties: true
|
|
104
|
+
};
|
|
105
|
+
var HfTransformersOnnxModelRecordSchema = {
|
|
106
|
+
type: "object",
|
|
107
|
+
properties: {
|
|
108
|
+
...ModelRecordSchema.properties,
|
|
109
|
+
...HfTransformersOnnxModelSchema.properties
|
|
110
|
+
},
|
|
111
|
+
required: [...ModelRecordSchema.required, ...HfTransformersOnnxModelSchema.required],
|
|
112
|
+
additionalProperties: false
|
|
113
|
+
};
|
|
114
|
+
var HfTransformersOnnxModelConfigSchema = {
|
|
115
|
+
type: "object",
|
|
116
|
+
properties: {
|
|
117
|
+
...ModelConfigSchema.properties,
|
|
118
|
+
...HfTransformersOnnxModelSchema.properties
|
|
119
|
+
},
|
|
120
|
+
required: [...ModelConfigSchema.required, ...HfTransformersOnnxModelSchema.required],
|
|
121
|
+
additionalProperties: false
|
|
122
|
+
};
|
|
123
|
+
|
|
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
|
+
taskTypes = [
|
|
131
|
+
"DownloadModelTask",
|
|
132
|
+
"UnloadModelTask",
|
|
133
|
+
"TextEmbeddingTask",
|
|
134
|
+
"TextGenerationTask",
|
|
135
|
+
"TextQuestionAnswerTask",
|
|
136
|
+
"TextLanguageDetectionTask",
|
|
137
|
+
"TextClassificationTask",
|
|
138
|
+
"TextFillMaskTask",
|
|
139
|
+
"TextNamedEntityRecognitionTask",
|
|
140
|
+
"TextRewriterTask",
|
|
141
|
+
"TextSummaryTask",
|
|
142
|
+
"TextTranslationTask",
|
|
143
|
+
"ImageSegmentationTask",
|
|
144
|
+
"ImageToTextTask",
|
|
145
|
+
"BackgroundRemovalTask",
|
|
146
|
+
"ImageEmbeddingTask",
|
|
147
|
+
"ImageClassificationTask",
|
|
148
|
+
"ObjectDetectionTask"
|
|
149
|
+
];
|
|
150
|
+
constructor(tasks, streamTasks) {
|
|
151
|
+
super(tasks, streamTasks);
|
|
152
|
+
}
|
|
153
|
+
async onInitialize(options) {
|
|
154
|
+
if (options.mode === "inline") {
|
|
155
|
+
const { env } = await import("@sroussey/transformers");
|
|
156
|
+
env.backends.onnx.wasm.proxy = true;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
async dispose() {
|
|
160
|
+
if (this.tasks) {
|
|
161
|
+
const { clearPipelineCache } = await import("./HFT_JobRunFns-ajak33q5.js");
|
|
162
|
+
clearPipelineCache();
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export { HfTransformersOnnxModelSchema, HfTransformersOnnxModelRecordSchema, HfTransformersOnnxModelConfigSchema, HuggingFaceTransformersProvider };
|
|
168
|
+
|
|
169
|
+
//# debugId=508C1EE533DEBB7264756E2164756E21
|
|
@@ -0,0 +1,11 @@
|
|
|
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 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 @sroussey/transformers library.\n *\n * Task run functions are injected via the constructor so that the heavy\n * `@sroussey/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 } from \"@workglow/ai-provider/hf-transformers\";\n * await new HuggingFaceTransformersProvider(HFT_TASKS).register({ mode: \"inline\" });\n *\n * // Worker side -- caller provides the tasks:\n * import { HFT_TASKS } from \"@workglow/ai-provider/hf-transformers\";\n * new HuggingFaceTransformersProvider(HFT_TASKS).registerOnWorkerServer(workerServer);\n * ```\n */\nexport class HuggingFaceTransformersProvider extends AiProvider<HfTransformersOnnxModelConfig> {\n readonly name = HF_TRANSFORMERS_ONNX;\n\n readonly taskTypes = [\n \"DownloadModelTask\",\n \"UnloadModelTask\",\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 ] as const;\n\n constructor(\n tasks?: Record<string, AiProviderRunFn<any, any, HfTransformersOnnxModelConfig>>,\n streamTasks?: Record<string, AiProviderStreamFn<any, any, HfTransformersOnnxModelConfig>>\n ) {\n super(tasks, streamTasks);\n }\n\n protected override async onInitialize(options: AiProviderRegisterOptions): Promise<void> {\n if (options.mode === \"inline\") {\n const { env } = await import(\"@sroussey/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,oBA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
|
+
var OLLAMA_DEFAULT_BASE_URL = "http://localhost:11434";
|
|
4
|
+
|
|
5
|
+
// src/provider-ollama/common/Ollama_ModelSchema.ts
|
|
6
|
+
import { ModelConfigSchema, ModelRecordSchema } from "@workglow/ai";
|
|
7
|
+
var OllamaModelSchema = {
|
|
8
|
+
type: "object",
|
|
9
|
+
properties: {
|
|
10
|
+
provider: {
|
|
11
|
+
const: OLLAMA,
|
|
12
|
+
description: "Discriminator: Ollama local LLM server."
|
|
13
|
+
},
|
|
14
|
+
provider_config: {
|
|
15
|
+
type: "object",
|
|
16
|
+
description: "Ollama-specific configuration.",
|
|
17
|
+
properties: {
|
|
18
|
+
model_name: {
|
|
19
|
+
type: "string",
|
|
20
|
+
description: "The Ollama model identifier (e.g., 'llama3.2', 'nomic-embed-text')."
|
|
21
|
+
},
|
|
22
|
+
base_url: {
|
|
23
|
+
type: "string",
|
|
24
|
+
description: "Base URL for the Ollama server.",
|
|
25
|
+
default: OLLAMA_DEFAULT_BASE_URL
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
required: ["model_name"],
|
|
29
|
+
additionalProperties: false
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
required: ["provider", "provider_config"],
|
|
33
|
+
additionalProperties: true
|
|
34
|
+
};
|
|
35
|
+
var OllamaModelRecordSchema = {
|
|
36
|
+
type: "object",
|
|
37
|
+
properties: {
|
|
38
|
+
...ModelRecordSchema.properties,
|
|
39
|
+
...OllamaModelSchema.properties
|
|
40
|
+
},
|
|
41
|
+
required: [...ModelRecordSchema.required, ...OllamaModelSchema.required],
|
|
42
|
+
additionalProperties: false
|
|
43
|
+
};
|
|
44
|
+
var OllamaModelConfigSchema = {
|
|
45
|
+
type: "object",
|
|
46
|
+
properties: {
|
|
47
|
+
...ModelConfigSchema.properties,
|
|
48
|
+
...OllamaModelSchema.properties
|
|
49
|
+
},
|
|
50
|
+
required: [...ModelConfigSchema.required, ...OllamaModelSchema.required],
|
|
51
|
+
additionalProperties: false
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// src/provider-ollama/OllamaProvider.ts
|
|
55
|
+
import { AiProvider } from "@workglow/ai";
|
|
56
|
+
class OllamaProvider extends AiProvider {
|
|
57
|
+
name = OLLAMA;
|
|
58
|
+
taskTypes = [
|
|
59
|
+
"TextGenerationTask",
|
|
60
|
+
"TextEmbeddingTask",
|
|
61
|
+
"TextRewriterTask",
|
|
62
|
+
"TextSummaryTask"
|
|
63
|
+
];
|
|
64
|
+
constructor(tasks, streamTasks) {
|
|
65
|
+
super(tasks, streamTasks);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export { OLLAMA, OLLAMA_DEFAULT_BASE_URL, OllamaModelSchema, OllamaModelRecordSchema, OllamaModelConfigSchema, OllamaProvider };
|
|
70
|
+
|
|
71
|
+
//# debugId=ABC147728ECB0D5864756E2164756E21
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/provider-ollama/common/Ollama_Constants.ts", "../src/provider-ollama/common/Ollama_ModelSchema.ts", "../src/provider-ollama/OllamaProvider.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 OLLAMA = \"OLLAMA\";\nexport const OLLAMA_DEFAULT_BASE_URL = \"http://localhost:11434\";\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 { OLLAMA, OLLAMA_DEFAULT_BASE_URL } from \"./Ollama_Constants\";\n\nexport const OllamaModelSchema = {\n type: \"object\",\n properties: {\n provider: {\n const: OLLAMA,\n description: \"Discriminator: Ollama local LLM server.\",\n },\n provider_config: {\n type: \"object\",\n description: \"Ollama-specific configuration.\",\n properties: {\n model_name: {\n type: \"string\",\n description: \"The Ollama model identifier (e.g., 'llama3.2', 'nomic-embed-text').\",\n },\n base_url: {\n type: \"string\",\n description: \"Base URL for the Ollama server.\",\n default: OLLAMA_DEFAULT_BASE_URL,\n },\n },\n required: [\"model_name\"],\n additionalProperties: false,\n },\n },\n required: [\"provider\", \"provider_config\"],\n additionalProperties: true,\n} as const satisfies DataPortSchemaObject;\n\nexport const OllamaModelRecordSchema = {\n type: \"object\",\n properties: {\n ...ModelRecordSchema.properties,\n ...OllamaModelSchema.properties,\n },\n required: [...ModelRecordSchema.required, ...OllamaModelSchema.required],\n additionalProperties: false,\n} as const satisfies DataPortSchemaObject;\n\nexport type OllamaModelRecord = FromSchema<typeof OllamaModelRecordSchema>;\n\nexport const OllamaModelConfigSchema = {\n type: \"object\",\n properties: {\n ...ModelConfigSchema.properties,\n ...OllamaModelSchema.properties,\n },\n required: [...ModelConfigSchema.required, ...OllamaModelSchema.required],\n additionalProperties: false,\n} as const satisfies DataPortSchemaObject;\n\nexport type OllamaModelConfig = FromSchema<typeof OllamaModelConfigSchema>;\n",
|
|
7
|
+
"/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { AiProvider, type AiProviderRunFn, type AiProviderStreamFn } from \"@workglow/ai\";\nimport { OLLAMA } from \"./common/Ollama_Constants\";\nimport type { OllamaModelConfig } from \"./common/Ollama_ModelSchema\";\n\n/**\n * AI provider for Ollama local LLM server.\n *\n * Supports text generation, text embedding, text rewriting, and text summarization\n * via the Ollama API using the `ollama` SDK.\n *\n * Ollama runs locally and does not require an API key -- only a `base_url`\n * (defaults to `http://localhost:11434`).\n *\n * Task run functions are injected via the constructor so that the `ollama` SDK\n * is only imported where actually needed (inline mode, worker server), not on\n * the main thread in worker mode.\n *\n * @example\n * ```typescript\n * // Worker mode (main thread) -- lightweight, no SDK import:\n * await new OllamaProvider().register({\n * mode: \"worker\",\n * worker: new Worker(new URL(\"./worker_ollama.ts\", import.meta.url), { type: \"module\" }),\n * });\n *\n * // Inline mode -- caller provides the tasks:\n * import { OLLAMA_TASKS } from \"@workglow/ai-provider/ollama\";\n * await new OllamaProvider(OLLAMA_TASKS).register({ mode: \"inline\" });\n * ```\n */\nexport class OllamaProvider extends AiProvider<OllamaModelConfig> {\n readonly name = OLLAMA;\n\n readonly taskTypes = [\n \"TextGenerationTask\",\n \"TextEmbeddingTask\",\n \"TextRewriterTask\",\n \"TextSummaryTask\",\n ] as const;\n\n constructor(\n tasks?: Record<string, AiProviderRunFn<any, any, OllamaModelConfig>>,\n streamTasks?: Record<string, AiProviderStreamFn<any, any, OllamaModelConfig>>\n ) {\n super(tasks, streamTasks);\n }\n}\n"
|
|
8
|
+
],
|
|
9
|
+
"mappings": ";AAMO,IAAM,SAAS;AACf,IAAM,0BAA0B;;;ACDvC;AAIO,IAAM,oBAAoB;AAAA,EAC/B,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,YAAY;AAAA,UACV,MAAM;AAAA,UACN,aAAa;AAAA,QACf;AAAA,QACA,UAAU;AAAA,UACR,MAAM;AAAA,UACN,aAAa;AAAA,UACb,SAAS;AAAA,QACX;AAAA,MACF;AAAA,MACA,UAAU,CAAC,YAAY;AAAA,MACvB,sBAAsB;AAAA,IACxB;AAAA,EACF;AAAA,EACA,UAAU,CAAC,YAAY,iBAAiB;AAAA,EACxC,sBAAsB;AACxB;AAEO,IAAM,0BAA0B;AAAA,EACrC,MAAM;AAAA,EACN,YAAY;AAAA,OACP,kBAAkB;AAAA,OAClB,kBAAkB;AAAA,EACvB;AAAA,EACA,UAAU,CAAC,GAAG,kBAAkB,UAAU,GAAG,kBAAkB,QAAQ;AAAA,EACvE,sBAAsB;AACxB;AAIO,IAAM,0BAA0B;AAAA,EACrC,MAAM;AAAA,EACN,YAAY;AAAA,OACP,kBAAkB;AAAA,OAClB,kBAAkB;AAAA,EACvB;AAAA,EACA,UAAU,CAAC,GAAG,kBAAkB,UAAU,GAAG,kBAAkB,QAAQ;AAAA,EACvE,sBAAsB;AACxB;;;ACrDA;AA8BO,MAAM,uBAAuB,WAA8B;AAAA,EACvD,OAAO;AAAA,EAEP,YAAY;AAAA,IACnB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EAEA,WAAW,CACT,OACA,aACA;AAAA,IACA,MAAM,OAAO,WAAW;AAAA;AAE5B;",
|
|
10
|
+
"debugId": "ABC147728ECB0D5864756E2164756E21",
|
|
11
|
+
"names": []
|
|
12
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// src/google-gemini/common/Gemini_Constants.ts
|
|
2
|
+
var GOOGLE_GEMINI = "GOOGLE_GEMINI";
|
|
3
|
+
|
|
4
|
+
// src/google-gemini/common/Gemini_ModelSchema.ts
|
|
5
|
+
import { ModelConfigSchema, ModelRecordSchema } from "@workglow/ai";
|
|
6
|
+
var GeminiModelSchema = {
|
|
7
|
+
type: "object",
|
|
8
|
+
properties: {
|
|
9
|
+
provider: {
|
|
10
|
+
const: GOOGLE_GEMINI,
|
|
11
|
+
description: "Discriminator: Google Gemini cloud provider."
|
|
12
|
+
},
|
|
13
|
+
provider_config: {
|
|
14
|
+
type: "object",
|
|
15
|
+
description: "Google Gemini-specific configuration.",
|
|
16
|
+
properties: {
|
|
17
|
+
model_name: {
|
|
18
|
+
type: "string",
|
|
19
|
+
description: "The Gemini model identifier (e.g., 'gemini-2.0-flash', 'text-embedding-004')."
|
|
20
|
+
},
|
|
21
|
+
api_key: {
|
|
22
|
+
type: "string",
|
|
23
|
+
description: "Google AI API key. Falls back to default API key if not set."
|
|
24
|
+
},
|
|
25
|
+
embedding_task_type: {
|
|
26
|
+
oneOf: [
|
|
27
|
+
{ type: "null" },
|
|
28
|
+
{
|
|
29
|
+
type: "string",
|
|
30
|
+
enum: [
|
|
31
|
+
"RETRIEVAL_QUERY",
|
|
32
|
+
"RETRIEVAL_DOCUMENT",
|
|
33
|
+
"SEMANTIC_SIMILARITY",
|
|
34
|
+
"CLASSIFICATION",
|
|
35
|
+
"CLUSTERING"
|
|
36
|
+
]
|
|
37
|
+
}
|
|
38
|
+
],
|
|
39
|
+
description: "Task type hint for embedding models.",
|
|
40
|
+
default: null
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
required: ["model_name"],
|
|
44
|
+
additionalProperties: false
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
required: ["provider", "provider_config"],
|
|
48
|
+
additionalProperties: true
|
|
49
|
+
};
|
|
50
|
+
var GeminiModelRecordSchema = {
|
|
51
|
+
type: "object",
|
|
52
|
+
properties: {
|
|
53
|
+
...ModelRecordSchema.properties,
|
|
54
|
+
...GeminiModelSchema.properties
|
|
55
|
+
},
|
|
56
|
+
required: [...ModelRecordSchema.required, ...GeminiModelSchema.required],
|
|
57
|
+
additionalProperties: false
|
|
58
|
+
};
|
|
59
|
+
var GeminiModelConfigSchema = {
|
|
60
|
+
type: "object",
|
|
61
|
+
properties: {
|
|
62
|
+
...ModelConfigSchema.properties,
|
|
63
|
+
...GeminiModelSchema.properties
|
|
64
|
+
},
|
|
65
|
+
required: [...ModelConfigSchema.required, ...GeminiModelSchema.required],
|
|
66
|
+
additionalProperties: false
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
// src/google-gemini/GoogleGeminiProvider.ts
|
|
70
|
+
import { AiProvider } from "@workglow/ai";
|
|
71
|
+
class GoogleGeminiProvider extends AiProvider {
|
|
72
|
+
name = GOOGLE_GEMINI;
|
|
73
|
+
taskTypes = [
|
|
74
|
+
"TextGenerationTask",
|
|
75
|
+
"TextEmbeddingTask",
|
|
76
|
+
"TextRewriterTask",
|
|
77
|
+
"TextSummaryTask"
|
|
78
|
+
];
|
|
79
|
+
constructor(tasks, streamTasks) {
|
|
80
|
+
super(tasks, streamTasks);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export { GOOGLE_GEMINI, GeminiModelSchema, GeminiModelRecordSchema, GeminiModelConfigSchema, GoogleGeminiProvider };
|
|
85
|
+
|
|
86
|
+
//# debugId=8437AF0C520B878F64756E2164756E21
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/google-gemini/common/Gemini_Constants.ts", "../src/google-gemini/common/Gemini_ModelSchema.ts", "../src/google-gemini/GoogleGeminiProvider.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 GOOGLE_GEMINI = \"GOOGLE_GEMINI\";\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 { GOOGLE_GEMINI } from \"./Gemini_Constants\";\n\nexport const GeminiModelSchema = {\n type: \"object\",\n properties: {\n provider: {\n const: GOOGLE_GEMINI,\n description: \"Discriminator: Google Gemini cloud provider.\",\n },\n provider_config: {\n type: \"object\",\n description: \"Google Gemini-specific configuration.\",\n properties: {\n model_name: {\n type: \"string\",\n description:\n \"The Gemini model identifier (e.g., 'gemini-2.0-flash', 'text-embedding-004').\",\n },\n api_key: {\n type: \"string\",\n description: \"Google AI API key. Falls back to default API key if not set.\",\n },\n embedding_task_type: {\n oneOf: [\n { type: \"null\" },\n {\n type: \"string\",\n enum: [\n \"RETRIEVAL_QUERY\",\n \"RETRIEVAL_DOCUMENT\",\n \"SEMANTIC_SIMILARITY\",\n \"CLASSIFICATION\",\n \"CLUSTERING\",\n ],\n },\n ],\n description: \"Task type hint for embedding models.\",\n default: null,\n },\n },\n required: [\"model_name\"],\n additionalProperties: false,\n },\n },\n required: [\"provider\", \"provider_config\"],\n additionalProperties: true,\n} as const satisfies DataPortSchemaObject;\n\nexport const GeminiModelRecordSchema = {\n type: \"object\",\n properties: {\n ...ModelRecordSchema.properties,\n ...GeminiModelSchema.properties,\n },\n required: [...ModelRecordSchema.required, ...GeminiModelSchema.required],\n additionalProperties: false,\n} as const satisfies DataPortSchemaObject;\n\nexport type GeminiModelRecord = FromSchema<typeof GeminiModelRecordSchema>;\n\nexport const GeminiModelConfigSchema = {\n type: \"object\",\n properties: {\n ...ModelConfigSchema.properties,\n ...GeminiModelSchema.properties,\n },\n required: [...ModelConfigSchema.required, ...GeminiModelSchema.required],\n additionalProperties: false,\n} as const satisfies DataPortSchemaObject;\n\nexport type GeminiModelConfig = FromSchema<typeof GeminiModelConfigSchema>;\n",
|
|
7
|
+
"/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { AiProvider, type AiProviderRunFn, type AiProviderStreamFn } from \"@workglow/ai\";\nimport { GOOGLE_GEMINI } from \"./common/Gemini_Constants\";\nimport type { GeminiModelConfig } from \"./common/Gemini_ModelSchema\";\n\n/**\n * AI provider for Google Gemini cloud models.\n *\n * Supports text generation, text embedding, text rewriting, and text summarization\n * via the Google Generative AI API using the `@google/generative-ai` SDK.\n *\n * Task run functions are injected via the constructor so that the SDK\n * is only imported where actually needed (inline mode, worker server), not on\n * the main thread in worker mode.\n *\n * @example\n * ```typescript\n * // Worker mode (main thread) -- lightweight, no SDK import:\n * await new GoogleGeminiProvider().register({\n * mode: \"worker\",\n * worker: new Worker(new URL(\"./worker_gemini.ts\", import.meta.url), { type: \"module\" }),\n * });\n *\n * // Inline mode -- caller provides the tasks:\n * import { GEMINI_TASKS } from \"@workglow/ai-provider/google-gemini\";\n * await new GoogleGeminiProvider(GEMINI_TASKS).register({ mode: \"inline\" });\n * ```\n */\nexport class GoogleGeminiProvider extends AiProvider<GeminiModelConfig> {\n readonly name = GOOGLE_GEMINI;\n\n readonly taskTypes = [\n \"TextGenerationTask\",\n \"TextEmbeddingTask\",\n \"TextRewriterTask\",\n \"TextSummaryTask\",\n ] as const;\n\n constructor(\n tasks?: Record<string, AiProviderRunFn<any, any, GeminiModelConfig>>,\n streamTasks?: Record<string, AiProviderStreamFn<any, any, GeminiModelConfig>>\n ) {\n super(tasks, streamTasks);\n }\n}\n"
|
|
8
|
+
],
|
|
9
|
+
"mappings": ";AAMO,IAAM,gBAAgB;;;ACA7B;AAIO,IAAM,oBAAoB;AAAA,EAC/B,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,YAAY;AAAA,UACV,MAAM;AAAA,UACN,aACE;AAAA,QACJ;AAAA,QACA,SAAS;AAAA,UACP,MAAM;AAAA,UACN,aAAa;AAAA,QACf;AAAA,QACA,qBAAqB;AAAA,UACnB,OAAO;AAAA,YACL,EAAE,MAAM,OAAO;AAAA,YACf;AAAA,cACE,MAAM;AAAA,cACN,MAAM;AAAA,gBACJ;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,cACF;AAAA,YACF;AAAA,UACF;AAAA,UACA,aAAa;AAAA,UACb,SAAS;AAAA,QACX;AAAA,MACF;AAAA,MACA,UAAU,CAAC,YAAY;AAAA,MACvB,sBAAsB;AAAA,IACxB;AAAA,EACF;AAAA,EACA,UAAU,CAAC,YAAY,iBAAiB;AAAA,EACxC,sBAAsB;AACxB;AAEO,IAAM,0BAA0B;AAAA,EACrC,MAAM;AAAA,EACN,YAAY;AAAA,OACP,kBAAkB;AAAA,OAClB,kBAAkB;AAAA,EACvB;AAAA,EACA,UAAU,CAAC,GAAG,kBAAkB,UAAU,GAAG,kBAAkB,QAAQ;AAAA,EACvE,sBAAsB;AACxB;AAIO,IAAM,0BAA0B;AAAA,EACrC,MAAM;AAAA,EACN,YAAY;AAAA,OACP,kBAAkB;AAAA,OAClB,kBAAkB;AAAA,EACvB;AAAA,EACA,UAAU,CAAC,GAAG,kBAAkB,UAAU,GAAG,kBAAkB,QAAQ;AAAA,EACvE,sBAAsB;AACxB;;;ACtEA;AA2BO,MAAM,6BAA6B,WAA8B;AAAA,EAC7D,OAAO;AAAA,EAEP,YAAY;AAAA,IACnB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EAEA,WAAW,CACT,OACA,aACA;AAAA,IACA,MAAM,OAAO,WAAW;AAAA;AAE5B;",
|
|
10
|
+
"debugId": "8437AF0C520B878F64756E2164756E21",
|
|
11
|
+
"names": []
|
|
12
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// src/provider-llamacpp/common/LlamaCpp_Constants.ts
|
|
2
|
+
var LOCAL_LLAMACPP = "LOCAL_LLAMACPP";
|
|
3
|
+
var LLAMACPP_DEFAULT_MODELS_DIR = "./models";
|
|
4
|
+
|
|
5
|
+
// src/provider-llamacpp/common/LlamaCpp_ModelSchema.ts
|
|
6
|
+
import { ModelConfigSchema, ModelRecordSchema } from "@workglow/ai";
|
|
7
|
+
var LlamaCppModelSchema = {
|
|
8
|
+
type: "object",
|
|
9
|
+
properties: {
|
|
10
|
+
provider: {
|
|
11
|
+
const: LOCAL_LLAMACPP,
|
|
12
|
+
description: "Discriminator: local node-llama-cpp (GGUF) model."
|
|
13
|
+
},
|
|
14
|
+
provider_config: {
|
|
15
|
+
type: "object",
|
|
16
|
+
description: "node-llama-cpp specific configuration.",
|
|
17
|
+
properties: {
|
|
18
|
+
model_path: {
|
|
19
|
+
type: "string",
|
|
20
|
+
description: "Filesystem path to the .gguf model file."
|
|
21
|
+
},
|
|
22
|
+
model_url: {
|
|
23
|
+
type: "string",
|
|
24
|
+
description: "URI or URL to download the model from (e.g. 'hf:user/repo:quant' or an https URL). Used by DownloadModelTask."
|
|
25
|
+
},
|
|
26
|
+
models_dir: {
|
|
27
|
+
type: "string",
|
|
28
|
+
description: "Directory to download models into.",
|
|
29
|
+
default: LLAMACPP_DEFAULT_MODELS_DIR
|
|
30
|
+
},
|
|
31
|
+
gpu_layers: {
|
|
32
|
+
type: "integer",
|
|
33
|
+
description: "Number of model layers to offload to GPU. Use -1 for auto-detection.",
|
|
34
|
+
minimum: -1
|
|
35
|
+
},
|
|
36
|
+
context_size: {
|
|
37
|
+
type: "integer",
|
|
38
|
+
description: "Context window size in tokens.",
|
|
39
|
+
minimum: 1
|
|
40
|
+
},
|
|
41
|
+
flash_attention: {
|
|
42
|
+
type: "boolean",
|
|
43
|
+
description: "Enable flash attention for improved performance where supported.",
|
|
44
|
+
default: true
|
|
45
|
+
},
|
|
46
|
+
embedding: {
|
|
47
|
+
type: "boolean",
|
|
48
|
+
description: "Whether this model is used for text embedding (vs text generation).",
|
|
49
|
+
default: false
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
required: ["model_path"],
|
|
53
|
+
additionalProperties: false
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
required: ["provider", "provider_config"],
|
|
57
|
+
additionalProperties: true
|
|
58
|
+
};
|
|
59
|
+
var LlamaCppModelRecordSchema = {
|
|
60
|
+
type: "object",
|
|
61
|
+
properties: {
|
|
62
|
+
...ModelRecordSchema.properties,
|
|
63
|
+
...LlamaCppModelSchema.properties
|
|
64
|
+
},
|
|
65
|
+
required: [...ModelRecordSchema.required, ...LlamaCppModelSchema.required],
|
|
66
|
+
additionalProperties: false
|
|
67
|
+
};
|
|
68
|
+
var LlamaCppModelConfigSchema = {
|
|
69
|
+
type: "object",
|
|
70
|
+
properties: {
|
|
71
|
+
...ModelConfigSchema.properties,
|
|
72
|
+
...LlamaCppModelSchema.properties
|
|
73
|
+
},
|
|
74
|
+
required: [...ModelConfigSchema.required, ...LlamaCppModelSchema.required],
|
|
75
|
+
additionalProperties: false
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
// src/provider-llamacpp/LlamaCppProvider.ts
|
|
79
|
+
import { AiProvider } from "@workglow/ai";
|
|
80
|
+
class LlamaCppProvider extends AiProvider {
|
|
81
|
+
name = LOCAL_LLAMACPP;
|
|
82
|
+
taskTypes = [
|
|
83
|
+
"DownloadModelTask",
|
|
84
|
+
"UnloadModelTask",
|
|
85
|
+
"TextGenerationTask",
|
|
86
|
+
"TextEmbeddingTask",
|
|
87
|
+
"TextRewriterTask",
|
|
88
|
+
"TextSummaryTask"
|
|
89
|
+
];
|
|
90
|
+
constructor(tasks, streamTasks) {
|
|
91
|
+
super(tasks, streamTasks);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export { LOCAL_LLAMACPP, LLAMACPP_DEFAULT_MODELS_DIR, LlamaCppModelSchema, LlamaCppModelRecordSchema, LlamaCppModelConfigSchema, LlamaCppProvider };
|
|
96
|
+
|
|
97
|
+
//# debugId=244314DF75484BAF64756E2164756E21
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/provider-llamacpp/common/LlamaCpp_Constants.ts", "../src/provider-llamacpp/common/LlamaCpp_ModelSchema.ts", "../src/provider-llamacpp/LlamaCppProvider.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 LOCAL_LLAMACPP = \"LOCAL_LLAMACPP\";\nexport const LLAMACPP_DEFAULT_MODELS_DIR = \"./models\";\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 { LLAMACPP_DEFAULT_MODELS_DIR, LOCAL_LLAMACPP } from \"./LlamaCpp_Constants\";\n\nexport const LlamaCppModelSchema = {\n type: \"object\",\n properties: {\n provider: {\n const: LOCAL_LLAMACPP,\n description: \"Discriminator: local node-llama-cpp (GGUF) model.\",\n },\n provider_config: {\n type: \"object\",\n description: \"node-llama-cpp specific configuration.\",\n properties: {\n model_path: {\n type: \"string\",\n description: \"Filesystem path to the .gguf model file.\",\n },\n model_url: {\n type: \"string\",\n description:\n \"URI or URL to download the model from (e.g. 'hf:user/repo:quant' or an https URL). Used by DownloadModelTask.\",\n },\n models_dir: {\n type: \"string\",\n description: \"Directory to download models into.\",\n default: LLAMACPP_DEFAULT_MODELS_DIR,\n },\n gpu_layers: {\n type: \"integer\",\n description: \"Number of model layers to offload to GPU. Use -1 for auto-detection.\",\n minimum: -1,\n },\n context_size: {\n type: \"integer\",\n description: \"Context window size in tokens.\",\n minimum: 1,\n },\n flash_attention: {\n type: \"boolean\",\n description: \"Enable flash attention for improved performance where supported.\",\n default: true,\n },\n embedding: {\n type: \"boolean\",\n description: \"Whether this model is used for text embedding (vs text generation).\",\n default: false,\n },\n },\n required: [\"model_path\"],\n additionalProperties: false,\n },\n },\n required: [\"provider\", \"provider_config\"],\n additionalProperties: true,\n} as const satisfies DataPortSchemaObject;\n\nexport const LlamaCppModelRecordSchema = {\n type: \"object\",\n properties: {\n ...ModelRecordSchema.properties,\n ...LlamaCppModelSchema.properties,\n },\n required: [...ModelRecordSchema.required, ...LlamaCppModelSchema.required],\n additionalProperties: false,\n} as const satisfies DataPortSchemaObject;\n\nexport type LlamaCppModelRecord = FromSchema<typeof LlamaCppModelRecordSchema>;\n\nexport const LlamaCppModelConfigSchema = {\n type: \"object\",\n properties: {\n ...ModelConfigSchema.properties,\n ...LlamaCppModelSchema.properties,\n },\n required: [...ModelConfigSchema.required, ...LlamaCppModelSchema.required],\n additionalProperties: false,\n} as const satisfies DataPortSchemaObject;\n\nexport type LlamaCppModelConfig = FromSchema<typeof LlamaCppModelConfigSchema>;\n",
|
|
7
|
+
"/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { AiProvider, type AiProviderRunFn, type AiProviderStreamFn } from \"@workglow/ai\";\nimport { LOCAL_LLAMACPP } from \"./common/LlamaCpp_Constants\";\nimport type { LlamaCppModelConfig } from \"./common/LlamaCpp_ModelSchema\";\n\n/**\n * AI provider for running GGUF models locally via node-llama-cpp.\n *\n * Supports model downloading, unloading, text generation, text embedding,\n * text rewriting, and text summarization using llama.cpp under the hood.\n *\n * This provider is server-side only (Node.js/Bun) — it requires native binaries\n * and cannot run in the browser.\n *\n * Models are cached in memory after the first load. Use UnloadModelTask to\n * release memory when a model is no longer needed.\n *\n * @example\n * ```typescript\n * // Inline mode:\n * import { LLAMACPP_TASKS, LLAMACPP_STREAM_TASKS } from \"@workglow/ai-provider/llamacpp\";\n * await new LlamaCppProvider(LLAMACPP_TASKS, LLAMACPP_STREAM_TASKS).register({ mode: \"inline\" });\n *\n * // Worker mode (main thread) -- lightweight, no SDK import:\n * await new LlamaCppProvider().register({\n * mode: \"worker\",\n * worker: new Worker(new URL(\"./worker_llamacpp.ts\", import.meta.url), { type: \"module\" }),\n * });\n * ```\n */\nexport class LlamaCppProvider extends AiProvider<LlamaCppModelConfig> {\n readonly name = LOCAL_LLAMACPP;\n\n readonly taskTypes = [\n \"DownloadModelTask\",\n \"UnloadModelTask\",\n \"TextGenerationTask\",\n \"TextEmbeddingTask\",\n \"TextRewriterTask\",\n \"TextSummaryTask\",\n ] as const;\n\n constructor(\n tasks?: Record<string, AiProviderRunFn<any, any, LlamaCppModelConfig>>,\n streamTasks?: Record<string, AiProviderStreamFn<any, any, LlamaCppModelConfig>>\n ) {\n super(tasks, streamTasks);\n }\n}\n"
|
|
8
|
+
],
|
|
9
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AAU,CAAC,GAAG,kBAAkB,UAAU,GAAG,oBAAoB,QAAQ;AAAA,EACzE,sBAAsB;AACxB;;;AC9EA;AA6BO,MAAM,yBAAyB,WAAgC;AAAA,EAC3D,OAAO;AAAA,EAEP,YAAY;AAAA,IACnB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EAEA,WAAW,CACT,OACA,aACA;AAAA,IACA,MAAM,OAAO,WAAW;AAAA;AAE5B;",
|
|
10
|
+
"debugId": "244314DF75484BAF64756E2164756E21",
|
|
11
|
+
"names": []
|
|
12
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
+
}) : x)(function(x) {
|
|
4
|
+
if (typeof require !== "undefined")
|
|
5
|
+
return require.apply(this, arguments);
|
|
6
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export { __require };
|
|
10
|
+
|
|
11
|
+
//# debugId=4DD4036FF577483964756E2164756E21
|
package/dist/index.d.ts
CHANGED
|
@@ -6,18 +6,24 @@
|
|
|
6
6
|
export * from "./anthropic/common/Anthropic_Constants";
|
|
7
7
|
export * from "./google-gemini/common/Gemini_Constants";
|
|
8
8
|
export * from "./hf-transformers/common/HFT_Constants";
|
|
9
|
+
export * from "./provider-hf-inference/common/HFI_Constants";
|
|
10
|
+
export * from "./provider-llamacpp/common/LlamaCpp_Constants";
|
|
9
11
|
export * from "./provider-ollama/common/Ollama_Constants";
|
|
10
12
|
export * from "./provider-openai/common/OpenAI_Constants";
|
|
11
13
|
export * from "./tf-mediapipe/common/TFMP_Constants";
|
|
12
14
|
export * from "./anthropic/common/Anthropic_ModelSchema";
|
|
13
15
|
export * from "./google-gemini/common/Gemini_ModelSchema";
|
|
14
16
|
export * from "./hf-transformers/common/HFT_ModelSchema";
|
|
17
|
+
export * from "./provider-hf-inference/common/HFI_ModelSchema";
|
|
18
|
+
export * from "./provider-llamacpp/common/LlamaCpp_ModelSchema";
|
|
15
19
|
export * from "./provider-ollama/common/Ollama_ModelSchema";
|
|
16
20
|
export * from "./provider-openai/common/OpenAI_ModelSchema";
|
|
17
21
|
export * from "./tf-mediapipe/common/TFMP_ModelSchema";
|
|
18
22
|
export * from "./anthropic/AnthropicProvider";
|
|
19
23
|
export * from "./google-gemini/GoogleGeminiProvider";
|
|
20
24
|
export * from "./hf-transformers/HuggingFaceTransformersProvider";
|
|
25
|
+
export * from "./provider-hf-inference/HfInferenceProvider";
|
|
26
|
+
export * from "./provider-llamacpp/LlamaCppProvider";
|
|
21
27
|
export * from "./provider-ollama/OllamaProvider";
|
|
22
28
|
export * from "./provider-openai/OpenAiProvider";
|
|
23
29
|
export * from "./tf-mediapipe/TensorFlowMediaPipeProvider";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,cAAc,wCAAwC,CAAC;AACvD,cAAc,yCAAyC,CAAC;AACxD,cAAc,wCAAwC,CAAC;AACvD,cAAc,2CAA2C,CAAC;AAC1D,cAAc,2CAA2C,CAAC;AAC1D,cAAc,sCAAsC,CAAC;AAGrD,cAAc,0CAA0C,CAAC;AACzD,cAAc,2CAA2C,CAAC;AAC1D,cAAc,0CAA0C,CAAC;AACzD,cAAc,6CAA6C,CAAC;AAC5D,cAAc,6CAA6C,CAAC;AAC5D,cAAc,wCAAwC,CAAC;AAGvD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,sCAAsC,CAAC;AACrD,cAAc,mDAAmD,CAAC;AAClE,cAAc,kCAAkC,CAAC;AACjD,cAAc,kCAAkC,CAAC;AACjD,cAAc,4CAA4C,CAAC"}
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