@workglow/ai-provider 0.0.108 → 0.0.110
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/README.md +1 -1
- package/dist/{HFT_JobRunFns-c40ex37f.js → HFT_JobRunFns-0bwh5cmx.js} +4 -2
- package/dist/{HFT_JobRunFns-c40ex37f.js.map → HFT_JobRunFns-0bwh5cmx.js.map} +1 -1
- package/dist/anthropic/AnthropicProvider.d.ts +3 -1
- package/dist/anthropic/AnthropicProvider.d.ts.map +1 -1
- package/dist/anthropic/common/Anthropic_JobRunFns.d.ts +2 -1
- package/dist/anthropic/common/Anthropic_JobRunFns.d.ts.map +1 -1
- package/dist/anthropic/index.js +68 -2
- package/dist/anthropic/index.js.map +3 -3
- package/dist/google-gemini/GoogleGeminiProvider.d.ts +3 -1
- package/dist/google-gemini/GoogleGeminiProvider.d.ts.map +1 -1
- package/dist/google-gemini/common/Gemini_JobRunFns.d.ts +2 -1
- package/dist/google-gemini/common/Gemini_JobRunFns.d.ts.map +1 -1
- package/dist/google-gemini/index.js +68 -2
- package/dist/google-gemini/index.js.map +3 -3
- package/dist/hf-transformers/HuggingFaceTransformersProvider.d.ts +5 -3
- package/dist/hf-transformers/HuggingFaceTransformersProvider.d.ts.map +1 -1
- package/dist/hf-transformers/common/HFT_JobRunFns.d.ts +121 -25
- package/dist/hf-transformers/common/HFT_JobRunFns.d.ts.map +1 -1
- package/dist/hf-transformers/index.js +5 -3
- package/dist/hf-transformers/index.js.map +2 -2
- package/dist/{index-5qjdc78z.js → index-60ev6k93.js} +4 -1
- package/dist/{index-5qjdc78z.js.map → index-60ev6k93.js.map} +3 -3
- package/dist/{index-5hjgs1z7.js → index-8651nz8y.js} +4 -1
- package/dist/{index-5hjgs1z7.js.map → index-8651nz8y.js.map} +3 -3
- package/dist/{index-4fr8p4gy.js → index-dmrxc6ek.js} +302 -175
- package/dist/index-dmrxc6ek.js.map +10 -0
- package/dist/{index-drcnh4z5.js → index-q2t627d5.js} +4 -1
- package/dist/{index-drcnh4z5.js.map → index-q2t627d5.js.map} +3 -3
- package/dist/{index-14pbwsc9.js → index-tp5s7355.js} +4 -1
- package/dist/{index-14pbwsc9.js.map → index-tp5s7355.js.map} +3 -3
- package/dist/{index-aef54vq3.js → index-v72vr07f.js} +4 -1
- package/dist/{index-aef54vq3.js.map → index-v72vr07f.js.map} +3 -3
- package/dist/{index-cejxxqcz.js → index-weaycaap.js} +6 -3
- package/dist/index-weaycaap.js.map +10 -0
- package/dist/{index-xc6m9mcp.js → index-wr57rwyx.js} +4 -1
- package/dist/{index-xc6m9mcp.js.map → index-wr57rwyx.js.map} +3 -3
- package/dist/index.js +11 -8
- package/dist/index.js.map +3 -3
- package/dist/provider-hf-inference/HfInferenceProvider.d.ts +3 -1
- package/dist/provider-hf-inference/HfInferenceProvider.d.ts.map +1 -1
- package/dist/provider-hf-inference/common/HFI_JobRunFns.d.ts +2 -1
- package/dist/provider-hf-inference/common/HFI_JobRunFns.d.ts.map +1 -1
- package/dist/provider-hf-inference/index.js +59 -3
- package/dist/provider-hf-inference/index.js.map +3 -3
- package/dist/provider-llamacpp/LlamaCppProvider.d.ts +3 -1
- package/dist/provider-llamacpp/LlamaCppProvider.d.ts.map +1 -1
- package/dist/provider-llamacpp/common/LlamaCpp_JobRunFns.d.ts +2 -1
- package/dist/provider-llamacpp/common/LlamaCpp_JobRunFns.d.ts.map +1 -1
- package/dist/provider-llamacpp/index.js +87 -4
- package/dist/provider-llamacpp/index.js.map +3 -3
- package/dist/provider-ollama/OllamaProvider.d.ts +3 -1
- package/dist/provider-ollama/OllamaProvider.d.ts.map +1 -1
- package/dist/provider-ollama/common/Ollama_JobRunFns.browser.d.ts +2 -1
- package/dist/provider-ollama/common/Ollama_JobRunFns.browser.d.ts.map +1 -1
- package/dist/provider-ollama/common/Ollama_JobRunFns.d.ts +2 -1
- package/dist/provider-ollama/common/Ollama_JobRunFns.d.ts.map +1 -1
- package/dist/provider-ollama/index.browser.js +78 -2
- package/dist/provider-ollama/index.browser.js.map +4 -4
- package/dist/provider-ollama/index.js +78 -5
- package/dist/provider-ollama/index.js.map +3 -3
- package/dist/provider-openai/OpenAiProvider.d.ts +3 -1
- package/dist/provider-openai/OpenAiProvider.d.ts.map +1 -1
- package/dist/provider-openai/common/OpenAI_JobRunFns.d.ts +2 -1
- package/dist/provider-openai/common/OpenAI_JobRunFns.d.ts.map +1 -1
- package/dist/provider-openai/index.js +68 -2
- package/dist/provider-openai/index.js.map +3 -3
- package/dist/tf-mediapipe/TensorFlowMediaPipeProvider.d.ts +3 -1
- package/dist/tf-mediapipe/TensorFlowMediaPipeProvider.d.ts.map +1 -1
- package/dist/tf-mediapipe/common/TFMP_JobRunFns.d.ts +67 -5
- package/dist/tf-mediapipe/common/TFMP_JobRunFns.d.ts.map +1 -1
- package/dist/tf-mediapipe/index.js +20 -1
- package/dist/tf-mediapipe/index.js.map +4 -4
- package/package.json +20 -19
- package/dist/hf-transformers/common/HFT_CallbackStatus.d.ts +0 -36
- package/dist/hf-transformers/common/HFT_CallbackStatus.d.ts.map +0 -1
- package/dist/index-4fr8p4gy.js.map +0 -10
- package/dist/index-cejxxqcz.js.map +0 -10
|
@@ -5,13 +5,13 @@ import {
|
|
|
5
5
|
OllamaModelRecordSchema,
|
|
6
6
|
OllamaModelSchema,
|
|
7
7
|
OllamaProvider
|
|
8
|
-
} from "../index-
|
|
8
|
+
} from "../index-tp5s7355.js";
|
|
9
9
|
import {
|
|
10
10
|
__require
|
|
11
11
|
} from "../index-6j5pq722.js";
|
|
12
12
|
// src/provider-ollama/common/Ollama_JobRunFns.ts
|
|
13
13
|
import { buildToolDescription, filterValidToolCalls } from "@workglow/ai";
|
|
14
|
-
import { parsePartialJson } from "@workglow/util";
|
|
14
|
+
import { getLogger, parsePartialJson } from "@workglow/util";
|
|
15
15
|
var _sdk;
|
|
16
16
|
async function loadOllamaSDK() {
|
|
17
17
|
if (!_sdk) {
|
|
@@ -36,6 +36,16 @@ function getModelName(model) {
|
|
|
36
36
|
return name;
|
|
37
37
|
}
|
|
38
38
|
var Ollama_TextGeneration = async (input, model, update_progress, signal) => {
|
|
39
|
+
if (Array.isArray(input.prompt)) {
|
|
40
|
+
getLogger().warn("Ollama_TextGeneration: array input received; processing sequentially (no native batch support)");
|
|
41
|
+
const prompts = input.prompt;
|
|
42
|
+
const results = [];
|
|
43
|
+
for (const item of prompts) {
|
|
44
|
+
const r = await Ollama_TextGeneration({ ...input, prompt: item }, model, update_progress, signal);
|
|
45
|
+
results.push(r.text);
|
|
46
|
+
}
|
|
47
|
+
return { text: results };
|
|
48
|
+
}
|
|
39
49
|
update_progress(0, "Starting Ollama text generation");
|
|
40
50
|
const client = await getClient(model);
|
|
41
51
|
const modelName = getModelName(model);
|
|
@@ -71,6 +81,16 @@ var Ollama_TextEmbedding = async (input, model, update_progress, signal) => {
|
|
|
71
81
|
return { vector: new Float32Array(response.embeddings[0]) };
|
|
72
82
|
};
|
|
73
83
|
var Ollama_TextRewriter = async (input, model, update_progress, signal) => {
|
|
84
|
+
if (Array.isArray(input.text)) {
|
|
85
|
+
getLogger().warn("Ollama_TextRewriter: array input received; processing sequentially (no native batch support)");
|
|
86
|
+
const texts = input.text;
|
|
87
|
+
const results = [];
|
|
88
|
+
for (const item of texts) {
|
|
89
|
+
const r = await Ollama_TextRewriter({ ...input, text: item }, model, update_progress, signal);
|
|
90
|
+
results.push(r.text);
|
|
91
|
+
}
|
|
92
|
+
return { text: results };
|
|
93
|
+
}
|
|
74
94
|
update_progress(0, "Starting Ollama text rewriting");
|
|
75
95
|
const client = await getClient(model);
|
|
76
96
|
const modelName = getModelName(model);
|
|
@@ -85,6 +105,16 @@ var Ollama_TextRewriter = async (input, model, update_progress, signal) => {
|
|
|
85
105
|
return { text: response.message.content };
|
|
86
106
|
};
|
|
87
107
|
var Ollama_TextSummary = async (input, model, update_progress, signal) => {
|
|
108
|
+
if (Array.isArray(input.text)) {
|
|
109
|
+
getLogger().warn("Ollama_TextSummary: array input received; processing sequentially (no native batch support)");
|
|
110
|
+
const texts = input.text;
|
|
111
|
+
const results = [];
|
|
112
|
+
for (const item of texts) {
|
|
113
|
+
const r = await Ollama_TextSummary({ ...input, text: item }, model, update_progress, signal);
|
|
114
|
+
results.push(r.text);
|
|
115
|
+
}
|
|
116
|
+
return { text: results };
|
|
117
|
+
}
|
|
88
118
|
update_progress(0, "Starting Ollama text summarization");
|
|
89
119
|
const client = await getClient(model);
|
|
90
120
|
const modelName = getModelName(model);
|
|
@@ -188,6 +218,18 @@ function mapOllamaTools(tools) {
|
|
|
188
218
|
}));
|
|
189
219
|
}
|
|
190
220
|
var Ollama_ToolCalling = async (input, model, update_progress, signal) => {
|
|
221
|
+
if (Array.isArray(input.prompt)) {
|
|
222
|
+
getLogger().warn("Ollama_ToolCalling: array input received; processing sequentially (no native batch support)");
|
|
223
|
+
const prompts = input.prompt;
|
|
224
|
+
const texts = [];
|
|
225
|
+
const toolCallsList = [];
|
|
226
|
+
for (const item of prompts) {
|
|
227
|
+
const r = await Ollama_ToolCalling({ ...input, prompt: item }, model, update_progress, signal);
|
|
228
|
+
texts.push(r.text);
|
|
229
|
+
toolCallsList.push(r.toolCalls);
|
|
230
|
+
}
|
|
231
|
+
return { text: texts, toolCalls: toolCallsList };
|
|
232
|
+
}
|
|
191
233
|
update_progress(0, "Starting Ollama tool calling");
|
|
192
234
|
const client = await getClient(model);
|
|
193
235
|
const modelName = getModelName(model);
|
|
@@ -288,7 +330,37 @@ var Ollama_ToolCalling_Stream = async function* (input, model, signal) {
|
|
|
288
330
|
signal.removeEventListener("abort", onAbort);
|
|
289
331
|
}
|
|
290
332
|
};
|
|
333
|
+
var Ollama_ModelInfo = async (input, model) => {
|
|
334
|
+
const client = await getClient(model);
|
|
335
|
+
const modelName = getModelName(model);
|
|
336
|
+
let is_cached = false;
|
|
337
|
+
let is_loaded = false;
|
|
338
|
+
let file_sizes = null;
|
|
339
|
+
try {
|
|
340
|
+
const showResponse = await client.show({ model: modelName });
|
|
341
|
+
is_cached = true;
|
|
342
|
+
const size = showResponse.size;
|
|
343
|
+
if (size != null) {
|
|
344
|
+
file_sizes = { model: size };
|
|
345
|
+
}
|
|
346
|
+
} catch {}
|
|
347
|
+
try {
|
|
348
|
+
const psResponse = await client.ps();
|
|
349
|
+
is_loaded = psResponse.models.some((m) => m.name === modelName);
|
|
350
|
+
} catch {}
|
|
351
|
+
return {
|
|
352
|
+
model: input.model,
|
|
353
|
+
is_local: true,
|
|
354
|
+
is_remote: false,
|
|
355
|
+
supports_browser: true,
|
|
356
|
+
supports_node: true,
|
|
357
|
+
is_cached,
|
|
358
|
+
is_loaded,
|
|
359
|
+
file_sizes
|
|
360
|
+
};
|
|
361
|
+
};
|
|
291
362
|
var OLLAMA_TASKS = {
|
|
363
|
+
ModelInfoTask: Ollama_ModelInfo,
|
|
292
364
|
TextGenerationTask: Ollama_TextGeneration,
|
|
293
365
|
TextEmbeddingTask: Ollama_TextEmbedding,
|
|
294
366
|
TextRewriterTask: Ollama_TextRewriter,
|
|
@@ -302,12 +374,12 @@ var OLLAMA_STREAM_TASKS = {
|
|
|
302
374
|
ToolCallingTask: Ollama_ToolCalling_Stream
|
|
303
375
|
};
|
|
304
376
|
// src/provider-ollama/Ollama_Worker.ts
|
|
305
|
-
import { getLogger, globalServiceRegistry, WORKER_SERVER } from "@workglow/util";
|
|
377
|
+
import { getLogger as getLogger2, globalServiceRegistry, WORKER_SERVER } from "@workglow/util";
|
|
306
378
|
function OLLAMA_WORKER_JOBRUN_REGISTER() {
|
|
307
379
|
const workerServer = globalServiceRegistry.get(WORKER_SERVER);
|
|
308
380
|
new OllamaProvider(OLLAMA_TASKS, OLLAMA_STREAM_TASKS).registerOnWorkerServer(workerServer);
|
|
309
381
|
workerServer.sendReady();
|
|
310
|
-
|
|
382
|
+
getLogger2().info("OLLAMA_WORKER_JOBRUN registered");
|
|
311
383
|
}
|
|
312
384
|
export {
|
|
313
385
|
Ollama_ToolCalling_Stream,
|
|
@@ -319,6 +391,7 @@ export {
|
|
|
319
391
|
Ollama_TextGeneration_Stream,
|
|
320
392
|
Ollama_TextGeneration,
|
|
321
393
|
Ollama_TextEmbedding,
|
|
394
|
+
Ollama_ModelInfo,
|
|
322
395
|
OllamaProvider,
|
|
323
396
|
OllamaModelSchema,
|
|
324
397
|
OllamaModelRecordSchema,
|
|
@@ -330,4 +403,4 @@ export {
|
|
|
330
403
|
OLLAMA
|
|
331
404
|
};
|
|
332
405
|
|
|
333
|
-
//# debugId=
|
|
406
|
+
//# debugId=2E6316DFEAFA3C9C64756E2164756E21
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/provider-ollama/common/Ollama_JobRunFns.ts", "../src/provider-ollama/Ollama_Worker.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type {\n AiProviderRunFn,\n AiProviderStreamFn,\n TextEmbeddingTaskInput,\n TextEmbeddingTaskOutput,\n TextGenerationTaskInput,\n TextGenerationTaskOutput,\n TextRewriterTaskInput,\n TextRewriterTaskOutput,\n TextSummaryTaskInput,\n TextSummaryTaskOutput,\n ToolCallingTaskInput,\n ToolCallingTaskOutput,\n ToolDefinition,\n} from \"@workglow/ai\";\nimport { buildToolDescription, filterValidToolCalls } from \"@workglow/ai\";\nimport type { StreamEvent } from \"@workglow/task-graph\";\nimport { parsePartialJson } from \"@workglow/util\";\nimport { OLLAMA_DEFAULT_BASE_URL } from \"./Ollama_Constants\";\nimport type { OllamaModelConfig } from \"./Ollama_ModelSchema\";\n\nlet _sdk: typeof import(\"ollama\") | undefined;\nasync function loadOllamaSDK() {\n if (!_sdk) {\n try {\n _sdk = await import(\"ollama\");\n } catch {\n throw new Error(\"ollama is required for Ollama tasks. Install it with: bun add ollama\");\n }\n }\n return _sdk.Ollama;\n}\n\nasync function getClient(model: OllamaModelConfig | undefined) {\n const Ollama = await loadOllamaSDK();\n const host = model?.provider_config?.base_url || OLLAMA_DEFAULT_BASE_URL;\n return new Ollama({ host });\n}\n\nfunction getModelName(model: OllamaModelConfig | undefined): string {\n const name = model?.provider_config?.model_name;\n if (!name) {\n throw new Error(\"Missing model name in provider_config.model_name.\");\n }\n return name;\n}\n\nexport const Ollama_TextGeneration: AiProviderRunFn<\n TextGenerationTaskInput,\n TextGenerationTaskOutput,\n OllamaModelConfig\n> = async (input, model, update_progress, signal) => {\n update_progress(0, \"Starting Ollama text generation\");\n const client = await getClient(model);\n const modelName = getModelName(model);\n\n const response = await client.chat({\n model: modelName,\n messages: [{ role: \"user\", content: input.prompt }],\n options: {\n temperature: input.temperature,\n top_p: input.topP,\n num_predict: input.maxTokens,\n frequency_penalty: input.frequencyPenalty,\n presence_penalty: input.presencePenalty,\n },\n });\n\n update_progress(100, \"Completed Ollama text generation\");\n return { text: response.message.content };\n};\n\nexport const Ollama_TextEmbedding: AiProviderRunFn<\n TextEmbeddingTaskInput,\n TextEmbeddingTaskOutput,\n OllamaModelConfig\n> = async (input, model, update_progress, signal) => {\n update_progress(0, \"Starting Ollama text embedding\");\n const client = await getClient(model);\n const modelName = getModelName(model);\n\n const texts = Array.isArray(input.text) ? input.text : [input.text];\n\n const response = await client.embed({\n model: modelName,\n input: texts,\n });\n\n update_progress(100, \"Completed Ollama text embedding\");\n\n if (Array.isArray(input.text)) {\n return {\n vector: response.embeddings.map((e) => new Float32Array(e)),\n };\n }\n return { vector: new Float32Array(response.embeddings[0]) };\n};\n\nexport const Ollama_TextRewriter: AiProviderRunFn<\n TextRewriterTaskInput,\n TextRewriterTaskOutput,\n OllamaModelConfig\n> = async (input, model, update_progress, signal) => {\n update_progress(0, \"Starting Ollama text rewriting\");\n const client = await getClient(model);\n const modelName = getModelName(model);\n\n const response = await client.chat({\n model: modelName,\n messages: [\n { role: \"system\", content: input.prompt },\n { role: \"user\", content: input.text },\n ],\n });\n\n update_progress(100, \"Completed Ollama text rewriting\");\n return { text: response.message.content };\n};\n\nexport const Ollama_TextSummary: AiProviderRunFn<\n TextSummaryTaskInput,\n TextSummaryTaskOutput,\n OllamaModelConfig\n> = async (input, model, update_progress, signal) => {\n update_progress(0, \"Starting Ollama text summarization\");\n const client = await getClient(model);\n const modelName = getModelName(model);\n\n const response = await client.chat({\n model: modelName,\n messages: [\n { role: \"system\", content: \"Summarize the following text concisely.\" },\n { role: \"user\", content: input.text },\n ],\n });\n\n update_progress(100, \"Completed Ollama text summarization\");\n return { text: response.message.content };\n};\n\n// ========================================================================\n// Streaming implementations (append mode)\n// ========================================================================\n\nexport const Ollama_TextGeneration_Stream: AiProviderStreamFn<\n TextGenerationTaskInput,\n TextGenerationTaskOutput,\n OllamaModelConfig\n> = async function* (input, model, signal): AsyncIterable<StreamEvent<TextGenerationTaskOutput>> {\n const client = await getClient(model);\n const modelName = getModelName(model);\n\n const stream = await client.chat({\n model: modelName,\n messages: [{ role: \"user\", content: input.prompt }],\n options: {\n temperature: input.temperature,\n top_p: input.topP,\n num_predict: input.maxTokens,\n frequency_penalty: input.frequencyPenalty,\n presence_penalty: input.presencePenalty,\n },\n stream: true,\n });\n\n const onAbort = () => stream.abort();\n signal.addEventListener(\"abort\", onAbort, { once: true });\n try {\n for await (const chunk of stream) {\n const delta = chunk.message.content;\n if (delta) {\n yield { type: \"text-delta\", port: \"text\", textDelta: delta };\n }\n }\n yield { type: \"finish\", data: {} as TextGenerationTaskOutput };\n } finally {\n signal.removeEventListener(\"abort\", onAbort);\n }\n};\n\nexport const Ollama_TextRewriter_Stream: AiProviderStreamFn<\n TextRewriterTaskInput,\n TextRewriterTaskOutput,\n OllamaModelConfig\n> = async function* (input, model, signal): AsyncIterable<StreamEvent<TextRewriterTaskOutput>> {\n const client = await getClient(model);\n const modelName = getModelName(model);\n\n const stream = await client.chat({\n model: modelName,\n messages: [\n { role: \"system\", content: input.prompt },\n { role: \"user\", content: input.text },\n ],\n stream: true,\n });\n\n const onAbort = () => stream.abort();\n signal.addEventListener(\"abort\", onAbort, { once: true });\n try {\n for await (const chunk of stream) {\n const delta = chunk.message.content;\n if (delta) {\n yield { type: \"text-delta\", port: \"text\", textDelta: delta };\n }\n }\n yield { type: \"finish\", data: {} as TextRewriterTaskOutput };\n } finally {\n signal.removeEventListener(\"abort\", onAbort);\n }\n};\n\nexport const Ollama_TextSummary_Stream: AiProviderStreamFn<\n TextSummaryTaskInput,\n TextSummaryTaskOutput,\n OllamaModelConfig\n> = async function* (input, model, signal): AsyncIterable<StreamEvent<TextSummaryTaskOutput>> {\n const client = await getClient(model);\n const modelName = getModelName(model);\n\n const stream = await client.chat({\n model: modelName,\n messages: [\n { role: \"system\", content: \"Summarize the following text concisely.\" },\n { role: \"user\", content: input.text },\n ],\n stream: true,\n });\n\n const onAbort = () => stream.abort();\n signal.addEventListener(\"abort\", onAbort, { once: true });\n try {\n for await (const chunk of stream) {\n const delta = chunk.message.content;\n if (delta) {\n yield { type: \"text-delta\", port: \"text\", textDelta: delta };\n }\n }\n yield { type: \"finish\", data: {} as TextSummaryTaskOutput };\n } finally {\n signal.removeEventListener(\"abort\", onAbort);\n }\n};\n\n// ========================================================================\n// Tool calling implementations\n// ========================================================================\n\nfunction mapOllamaTools(tools: ReadonlyArray<ToolDefinition>) {\n return tools.map((t) => ({\n type: \"function\" as const,\n function: {\n name: t.name,\n description: buildToolDescription(t),\n parameters: t.inputSchema as any,\n },\n }));\n}\n\nexport const Ollama_ToolCalling: AiProviderRunFn<\n ToolCallingTaskInput,\n ToolCallingTaskOutput,\n OllamaModelConfig\n> = async (input, model, update_progress, signal) => {\n update_progress(0, \"Starting Ollama tool calling\");\n const client = await getClient(model);\n const modelName = getModelName(model);\n\n const messages: Array<{ role: string; content: string }> = [];\n if (input.systemPrompt) {\n messages.push({ role: \"system\", content: input.systemPrompt });\n }\n messages.push({ role: \"user\", content: input.prompt });\n\n const tools = input.toolChoice === \"none\" ? undefined : mapOllamaTools(input.tools);\n\n const response = await client.chat({\n model: modelName,\n messages,\n tools,\n options: {\n temperature: input.temperature,\n num_predict: input.maxTokens,\n },\n });\n\n const text = response.message.content ?? \"\";\n const toolCalls: Record<string, unknown> = {};\n (response.message.tool_calls ?? []).forEach((tc: any, index: number) => {\n let parsedInput: Record<string, unknown> = {};\n const fnArgs = tc.function.arguments;\n if (typeof fnArgs === \"string\") {\n try {\n parsedInput = JSON.parse(fnArgs);\n } catch {\n const partial = parsePartialJson(fnArgs);\n parsedInput = (partial as Record<string, unknown>) ?? {};\n }\n } else if (fnArgs != null) {\n parsedInput = fnArgs as Record<string, unknown>;\n }\n const id = `call_${index}`;\n toolCalls[id] = { id, name: tc.function.name as string, input: parsedInput };\n });\n\n update_progress(100, \"Completed Ollama tool calling\");\n return { text, toolCalls: filterValidToolCalls(toolCalls, input.tools) };\n};\n\nexport const Ollama_ToolCalling_Stream: AiProviderStreamFn<\n ToolCallingTaskInput,\n ToolCallingTaskOutput,\n OllamaModelConfig\n> = async function* (input, model, signal): AsyncIterable<StreamEvent<ToolCallingTaskOutput>> {\n const client = await getClient(model);\n const modelName = getModelName(model);\n\n const messages: Array<{ role: string; content: string }> = [];\n if (input.systemPrompt) {\n messages.push({ role: \"system\", content: input.systemPrompt });\n }\n messages.push({ role: \"user\", content: input.prompt });\n\n const tools = input.toolChoice === \"none\" ? undefined : mapOllamaTools(input.tools);\n\n const stream = await client.chat({\n model: modelName,\n messages,\n tools,\n options: {\n temperature: input.temperature,\n num_predict: input.maxTokens,\n },\n stream: true,\n });\n\n const onAbort = () => stream.abort();\n signal.addEventListener(\"abort\", onAbort, { once: true });\n\n let accumulatedText = \"\";\n const toolCalls: Record<string, unknown> = {};\n let callIndex = 0;\n\n try {\n for await (const chunk of stream) {\n const delta = chunk.message.content;\n if (delta) {\n accumulatedText += delta;\n yield { type: \"text-delta\", port: \"text\", textDelta: delta };\n }\n\n const chunkToolCalls = (chunk.message as any).tool_calls;\n if (Array.isArray(chunkToolCalls) && chunkToolCalls.length > 0) {\n for (const tc of chunkToolCalls) {\n let parsedInput: Record<string, unknown> = {};\n const fnArgs = tc.function.arguments;\n if (typeof fnArgs === \"string\") {\n try {\n parsedInput = JSON.parse(fnArgs);\n } catch {\n const partial = parsePartialJson(fnArgs);\n parsedInput = (partial as Record<string, unknown>) ?? {};\n }\n } else if (fnArgs != null) {\n parsedInput = fnArgs as Record<string, unknown>;\n }\n const id = `call_${callIndex++}`;\n toolCalls[id] = { id, name: tc.function.name as string, input: parsedInput };\n }\n yield { type: \"object-delta\", port: \"toolCalls\", objectDelta: { ...toolCalls } };\n }\n }\n\n const validToolCalls = filterValidToolCalls(toolCalls, input.tools);\n yield {\n type: \"finish\",\n data: { text: accumulatedText, toolCalls: validToolCalls } as ToolCallingTaskOutput,\n };\n } finally {\n signal.removeEventListener(\"abort\", onAbort);\n }\n};\n\n// ========================================================================\n// Task registries\n// ========================================================================\n\nexport const OLLAMA_TASKS: Record<string, AiProviderRunFn<any, any, OllamaModelConfig>> = {\n TextGenerationTask: Ollama_TextGeneration,\n TextEmbeddingTask: Ollama_TextEmbedding,\n TextRewriterTask: Ollama_TextRewriter,\n TextSummaryTask: Ollama_TextSummary,\n ToolCallingTask: Ollama_ToolCalling,\n};\n\nexport const OLLAMA_STREAM_TASKS: Record<\n string,\n AiProviderStreamFn<any, any, OllamaModelConfig>\n> = {\n TextGenerationTask: Ollama_TextGeneration_Stream,\n TextRewriterTask: Ollama_TextRewriter_Stream,\n TextSummaryTask: Ollama_TextSummary_Stream,\n ToolCallingTask: Ollama_ToolCalling_Stream,\n};\n",
|
|
5
|
+
"/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type {\n AiProviderRunFn,\n AiProviderStreamFn,\n ModelInfoTaskInput,\n ModelInfoTaskOutput,\n TextEmbeddingTaskInput,\n TextEmbeddingTaskOutput,\n TextGenerationTaskInput,\n TextGenerationTaskOutput,\n TextRewriterTaskInput,\n TextRewriterTaskOutput,\n TextSummaryTaskInput,\n TextSummaryTaskOutput,\n ToolCallingTaskInput,\n ToolCallingTaskOutput,\n ToolDefinition,\n} from \"@workglow/ai\";\nimport { buildToolDescription, filterValidToolCalls } from \"@workglow/ai\";\nimport type { StreamEvent } from \"@workglow/task-graph\";\nimport { getLogger, parsePartialJson } from \"@workglow/util\";\nimport { OLLAMA_DEFAULT_BASE_URL } from \"./Ollama_Constants\";\nimport type { OllamaModelConfig } from \"./Ollama_ModelSchema\";\n\nlet _sdk: typeof import(\"ollama\") | undefined;\nasync function loadOllamaSDK() {\n if (!_sdk) {\n try {\n _sdk = await import(\"ollama\");\n } catch {\n throw new Error(\"ollama is required for Ollama tasks. Install it with: bun add ollama\");\n }\n }\n return _sdk.Ollama;\n}\n\nasync function getClient(model: OllamaModelConfig | undefined) {\n const Ollama = await loadOllamaSDK();\n const host = model?.provider_config?.base_url || OLLAMA_DEFAULT_BASE_URL;\n return new Ollama({ host });\n}\n\nfunction getModelName(model: OllamaModelConfig | undefined): string {\n const name = model?.provider_config?.model_name;\n if (!name) {\n throw new Error(\"Missing model name in provider_config.model_name.\");\n }\n return name;\n}\n\nexport const Ollama_TextGeneration: AiProviderRunFn<\n TextGenerationTaskInput,\n TextGenerationTaskOutput,\n OllamaModelConfig\n> = async (input, model, update_progress, signal) => {\n if (Array.isArray(input.prompt)) {\n getLogger().warn(\n \"Ollama_TextGeneration: array input received; processing sequentially (no native batch support)\"\n );\n const prompts = input.prompt as string[];\n const results: string[] = [];\n for (const item of prompts) {\n const r = await Ollama_TextGeneration({ ...input, prompt: item }, model, update_progress, signal);\n results.push(r.text as string);\n }\n return { text: results };\n }\n\n update_progress(0, \"Starting Ollama text generation\");\n const client = await getClient(model);\n const modelName = getModelName(model);\n\n const response = await client.chat({\n model: modelName,\n messages: [{ role: \"user\", content: input.prompt as string }],\n options: {\n temperature: input.temperature,\n top_p: input.topP,\n num_predict: input.maxTokens,\n frequency_penalty: input.frequencyPenalty,\n presence_penalty: input.presencePenalty,\n },\n });\n\n update_progress(100, \"Completed Ollama text generation\");\n return { text: response.message.content };\n};\n\nexport const Ollama_TextEmbedding: AiProviderRunFn<\n TextEmbeddingTaskInput,\n TextEmbeddingTaskOutput,\n OllamaModelConfig\n> = async (input, model, update_progress, signal) => {\n update_progress(0, \"Starting Ollama text embedding\");\n const client = await getClient(model);\n const modelName = getModelName(model);\n\n const texts = Array.isArray(input.text) ? input.text : [input.text];\n\n const response = await client.embed({\n model: modelName,\n input: texts,\n });\n\n update_progress(100, \"Completed Ollama text embedding\");\n\n if (Array.isArray(input.text)) {\n return {\n vector: response.embeddings.map((e) => new Float32Array(e)),\n };\n }\n return { vector: new Float32Array(response.embeddings[0]) };\n};\n\nexport const Ollama_TextRewriter: AiProviderRunFn<\n TextRewriterTaskInput,\n TextRewriterTaskOutput,\n OllamaModelConfig\n> = async (input, model, update_progress, signal) => {\n if (Array.isArray(input.text)) {\n getLogger().warn(\n \"Ollama_TextRewriter: array input received; processing sequentially (no native batch support)\"\n );\n const texts = input.text as string[];\n const results: string[] = [];\n for (const item of texts) {\n const r = await Ollama_TextRewriter({ ...input, text: item }, model, update_progress, signal);\n results.push(r.text as string);\n }\n return { text: results };\n }\n\n update_progress(0, \"Starting Ollama text rewriting\");\n const client = await getClient(model);\n const modelName = getModelName(model);\n\n const response = await client.chat({\n model: modelName,\n messages: [\n { role: \"system\", content: input.prompt as string },\n { role: \"user\", content: input.text as string },\n ],\n });\n\n update_progress(100, \"Completed Ollama text rewriting\");\n return { text: response.message.content };\n};\n\nexport const Ollama_TextSummary: AiProviderRunFn<\n TextSummaryTaskInput,\n TextSummaryTaskOutput,\n OllamaModelConfig\n> = async (input, model, update_progress, signal) => {\n if (Array.isArray(input.text)) {\n getLogger().warn(\n \"Ollama_TextSummary: array input received; processing sequentially (no native batch support)\"\n );\n const texts = input.text as string[];\n const results: string[] = [];\n for (const item of texts) {\n const r = await Ollama_TextSummary({ ...input, text: item }, model, update_progress, signal);\n results.push(r.text as string);\n }\n return { text: results };\n }\n\n update_progress(0, \"Starting Ollama text summarization\");\n const client = await getClient(model);\n const modelName = getModelName(model);\n\n const response = await client.chat({\n model: modelName,\n messages: [\n { role: \"system\", content: \"Summarize the following text concisely.\" },\n { role: \"user\", content: input.text as string },\n ],\n });\n\n update_progress(100, \"Completed Ollama text summarization\");\n return { text: response.message.content };\n};\n\n// ========================================================================\n// Streaming implementations (append mode)\n// ========================================================================\n\nexport const Ollama_TextGeneration_Stream: AiProviderStreamFn<\n TextGenerationTaskInput,\n TextGenerationTaskOutput,\n OllamaModelConfig\n> = async function* (input, model, signal): AsyncIterable<StreamEvent<TextGenerationTaskOutput>> {\n const client = await getClient(model);\n const modelName = getModelName(model);\n\n const stream = await client.chat({\n model: modelName,\n messages: [{ role: \"user\", content: input.prompt as string }],\n options: {\n temperature: input.temperature,\n top_p: input.topP,\n num_predict: input.maxTokens,\n frequency_penalty: input.frequencyPenalty,\n presence_penalty: input.presencePenalty,\n },\n stream: true,\n });\n\n const onAbort = () => stream.abort();\n signal.addEventListener(\"abort\", onAbort, { once: true });\n try {\n for await (const chunk of stream) {\n const delta = chunk.message.content;\n if (delta) {\n yield { type: \"text-delta\", port: \"text\", textDelta: delta };\n }\n }\n yield { type: \"finish\", data: {} as TextGenerationTaskOutput };\n } finally {\n signal.removeEventListener(\"abort\", onAbort);\n }\n};\n\nexport const Ollama_TextRewriter_Stream: AiProviderStreamFn<\n TextRewriterTaskInput,\n TextRewriterTaskOutput,\n OllamaModelConfig\n> = async function* (input, model, signal): AsyncIterable<StreamEvent<TextRewriterTaskOutput>> {\n const client = await getClient(model);\n const modelName = getModelName(model);\n\n const stream = await client.chat({\n model: modelName,\n messages: [\n { role: \"system\", content: input.prompt as string },\n { role: \"user\", content: input.text as string },\n ],\n stream: true,\n });\n\n const onAbort = () => stream.abort();\n signal.addEventListener(\"abort\", onAbort, { once: true });\n try {\n for await (const chunk of stream) {\n const delta = chunk.message.content;\n if (delta) {\n yield { type: \"text-delta\", port: \"text\", textDelta: delta };\n }\n }\n yield { type: \"finish\", data: {} as TextRewriterTaskOutput };\n } finally {\n signal.removeEventListener(\"abort\", onAbort);\n }\n};\n\nexport const Ollama_TextSummary_Stream: AiProviderStreamFn<\n TextSummaryTaskInput,\n TextSummaryTaskOutput,\n OllamaModelConfig\n> = async function* (input, model, signal): AsyncIterable<StreamEvent<TextSummaryTaskOutput>> {\n const client = await getClient(model);\n const modelName = getModelName(model);\n\n const stream = await client.chat({\n model: modelName,\n messages: [\n { role: \"system\", content: \"Summarize the following text concisely.\" },\n { role: \"user\", content: input.text as string },\n ],\n stream: true,\n });\n\n const onAbort = () => stream.abort();\n signal.addEventListener(\"abort\", onAbort, { once: true });\n try {\n for await (const chunk of stream) {\n const delta = chunk.message.content;\n if (delta) {\n yield { type: \"text-delta\", port: \"text\", textDelta: delta };\n }\n }\n yield { type: \"finish\", data: {} as TextSummaryTaskOutput };\n } finally {\n signal.removeEventListener(\"abort\", onAbort);\n }\n};\n\n// ========================================================================\n// Tool calling implementations\n// ========================================================================\n\nfunction mapOllamaTools(tools: ReadonlyArray<ToolDefinition>) {\n return tools.map((t) => ({\n type: \"function\" as const,\n function: {\n name: t.name,\n description: buildToolDescription(t),\n parameters: t.inputSchema as any,\n },\n }));\n}\n\nexport const Ollama_ToolCalling: AiProviderRunFn<\n ToolCallingTaskInput,\n ToolCallingTaskOutput,\n OllamaModelConfig\n> = async (input, model, update_progress, signal) => {\n if (Array.isArray(input.prompt)) {\n getLogger().warn(\n \"Ollama_ToolCalling: array input received; processing sequentially (no native batch support)\"\n );\n const prompts = input.prompt as string[];\n const texts: string[] = [];\n const toolCallsList: Record<string, unknown>[] = [];\n for (const item of prompts) {\n const r = await Ollama_ToolCalling({ ...input, prompt: item }, model, update_progress, signal);\n texts.push(r.text as string);\n toolCallsList.push(r.toolCalls as Record<string, unknown>);\n }\n return { text: texts, toolCalls: toolCallsList };\n }\n\n update_progress(0, \"Starting Ollama tool calling\");\n const client = await getClient(model);\n const modelName = getModelName(model);\n\n const messages: Array<{ role: string; content: string }> = [];\n if (input.systemPrompt) {\n messages.push({ role: \"system\", content: input.systemPrompt as string });\n }\n messages.push({ role: \"user\", content: input.prompt as string });\n\n const tools = input.toolChoice === \"none\" ? undefined : mapOllamaTools(input.tools);\n\n const response = await client.chat({\n model: modelName,\n messages,\n tools,\n options: {\n temperature: input.temperature,\n num_predict: input.maxTokens,\n },\n });\n\n const text = response.message.content ?? \"\";\n const toolCalls: Record<string, unknown> = {};\n (response.message.tool_calls ?? []).forEach((tc: any, index: number) => {\n let parsedInput: Record<string, unknown> = {};\n const fnArgs = tc.function.arguments;\n if (typeof fnArgs === \"string\") {\n try {\n parsedInput = JSON.parse(fnArgs);\n } catch {\n const partial = parsePartialJson(fnArgs);\n parsedInput = (partial as Record<string, unknown>) ?? {};\n }\n } else if (fnArgs != null) {\n parsedInput = fnArgs as Record<string, unknown>;\n }\n const id = `call_${index}`;\n toolCalls[id] = { id, name: tc.function.name as string, input: parsedInput };\n });\n\n update_progress(100, \"Completed Ollama tool calling\");\n return { text, toolCalls: filterValidToolCalls(toolCalls, input.tools) };\n};\n\nexport const Ollama_ToolCalling_Stream: AiProviderStreamFn<\n ToolCallingTaskInput,\n ToolCallingTaskOutput,\n OllamaModelConfig\n> = async function* (input, model, signal): AsyncIterable<StreamEvent<ToolCallingTaskOutput>> {\n const client = await getClient(model);\n const modelName = getModelName(model);\n\n const messages: Array<{ role: string; content: string }> = [];\n if (input.systemPrompt) {\n messages.push({ role: \"system\", content: input.systemPrompt as string });\n }\n messages.push({ role: \"user\", content: input.prompt as string });\n\n const tools = input.toolChoice === \"none\" ? undefined : mapOllamaTools(input.tools);\n\n const stream = await client.chat({\n model: modelName,\n messages,\n tools,\n options: {\n temperature: input.temperature,\n num_predict: input.maxTokens,\n },\n stream: true,\n });\n\n const onAbort = () => stream.abort();\n signal.addEventListener(\"abort\", onAbort, { once: true });\n\n let accumulatedText = \"\";\n const toolCalls: Record<string, unknown> = {};\n let callIndex = 0;\n\n try {\n for await (const chunk of stream) {\n const delta = chunk.message.content;\n if (delta) {\n accumulatedText += delta;\n yield { type: \"text-delta\", port: \"text\", textDelta: delta };\n }\n\n const chunkToolCalls = (chunk.message as any).tool_calls;\n if (Array.isArray(chunkToolCalls) && chunkToolCalls.length > 0) {\n for (const tc of chunkToolCalls) {\n let parsedInput: Record<string, unknown> = {};\n const fnArgs = tc.function.arguments;\n if (typeof fnArgs === \"string\") {\n try {\n parsedInput = JSON.parse(fnArgs);\n } catch {\n const partial = parsePartialJson(fnArgs);\n parsedInput = (partial as Record<string, unknown>) ?? {};\n }\n } else if (fnArgs != null) {\n parsedInput = fnArgs as Record<string, unknown>;\n }\n const id = `call_${callIndex++}`;\n toolCalls[id] = { id, name: tc.function.name as string, input: parsedInput };\n }\n yield { type: \"object-delta\", port: \"toolCalls\", objectDelta: { ...toolCalls } };\n }\n }\n\n const validToolCalls = filterValidToolCalls(toolCalls, input.tools);\n yield {\n type: \"finish\",\n data: { text: accumulatedText, toolCalls: validToolCalls } as ToolCallingTaskOutput,\n };\n } finally {\n signal.removeEventListener(\"abort\", onAbort);\n }\n};\n\n// ========================================================================\n// Model info\n// ========================================================================\n\nexport const Ollama_ModelInfo: AiProviderRunFn<\n ModelInfoTaskInput,\n ModelInfoTaskOutput,\n OllamaModelConfig\n> = async (input, model) => {\n const client = await getClient(model);\n const modelName = getModelName(model);\n\n let is_cached = false;\n let is_loaded = false;\n let file_sizes: Record<string, number> | null = null;\n\n try {\n const showResponse = await client.show({ model: modelName });\n is_cached = true;\n const size = (showResponse as any).size as number | undefined;\n if (size != null) {\n file_sizes = { model: size };\n }\n } catch {\n // Model not available on server\n }\n\n try {\n const psResponse = await client.ps();\n is_loaded = psResponse.models.some((m: any) => m.name === modelName);\n } catch {\n // ps() not available or failed\n }\n\n return {\n model: input.model,\n is_local: true,\n is_remote: false,\n supports_browser: true,\n supports_node: true,\n is_cached,\n is_loaded,\n file_sizes,\n };\n};\n\n// ========================================================================\n// Task registries\n// ========================================================================\n\nexport const OLLAMA_TASKS: Record<string, AiProviderRunFn<any, any, OllamaModelConfig>> = {\n ModelInfoTask: Ollama_ModelInfo,\n TextGenerationTask: Ollama_TextGeneration,\n TextEmbeddingTask: Ollama_TextEmbedding,\n TextRewriterTask: Ollama_TextRewriter,\n TextSummaryTask: Ollama_TextSummary,\n ToolCallingTask: Ollama_ToolCalling,\n};\n\nexport const OLLAMA_STREAM_TASKS: Record<\n string,\n AiProviderStreamFn<any, any, OllamaModelConfig>\n> = {\n TextGenerationTask: Ollama_TextGeneration_Stream,\n TextRewriterTask: Ollama_TextRewriter_Stream,\n TextSummaryTask: Ollama_TextSummary_Stream,\n ToolCallingTask: Ollama_ToolCalling_Stream,\n};\n",
|
|
6
6
|
"/**\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 { OLLAMA_STREAM_TASKS, OLLAMA_TASKS } from \"./common/Ollama_JobRunFns\";\nimport { OllamaProvider } from \"./OllamaProvider\";\n\nexport function OLLAMA_WORKER_JOBRUN_REGISTER() {\n const workerServer = globalServiceRegistry.get(WORKER_SERVER);\n new OllamaProvider(OLLAMA_TASKS, OLLAMA_STREAM_TASKS).registerOnWorkerServer(workerServer);\n workerServer.sendReady();\n getLogger().info(\"OLLAMA_WORKER_JOBRUN registered\");\n}\n"
|
|
7
7
|
],
|
|
8
|
-
"mappings": ";;;;;;;;;;;;
|
|
9
|
-
"debugId": "
|
|
8
|
+
"mappings": ";;;;;;;;;;;;AAuBA;AAEA;AAIA,IAAI;AACJ,eAAe,aAAa,GAAG;AAAA,EAC7B,IAAI,CAAC,MAAM;AAAA,IACT,IAAI;AAAA,MACF,OAAO,MAAa;AAAA,MACpB,MAAM;AAAA,MACN,MAAM,IAAI,MAAM,sEAAsE;AAAA;AAAA,EAE1F;AAAA,EACA,OAAO,KAAK;AAAA;AAGd,eAAe,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
|
}
|
|
@@ -34,7 +34,9 @@ import type { OpenAiModelConfig } from "./common/OpenAI_ModelSchema";
|
|
|
34
34
|
*/
|
|
35
35
|
export declare class OpenAiProvider extends AiProvider<OpenAiModelConfig> {
|
|
36
36
|
readonly name = "OPENAI";
|
|
37
|
-
readonly
|
|
37
|
+
readonly isLocal = false;
|
|
38
|
+
readonly supportsBrowser = true;
|
|
39
|
+
readonly taskTypes: readonly ["TextGenerationTask", "TextEmbeddingTask", "TextRewriterTask", "TextSummaryTask", "CountTokensTask", "ModelInfoTask", "StructuredGenerationTask", "ToolCallingTask"];
|
|
38
40
|
constructor(tasks?: Record<string, AiProviderRunFn<any, any, OpenAiModelConfig>>, streamTasks?: Record<string, AiProviderStreamFn<any, any, OpenAiModelConfig>>, reactiveTasks?: Record<string, AiProviderReactiveRunFn<any, any, OpenAiModelConfig>>);
|
|
39
41
|
}
|
|
40
42
|
//# sourceMappingURL=OpenAiProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenAiProvider.d.ts","sourceRoot":"","sources":["../../src/provider-openai/OpenAiProvider.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,UAAU,EACV,KAAK,uBAAuB,EAC5B,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACxB,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAErE;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,qBAAa,cAAe,SAAQ,UAAU,CAAC,iBAAiB,CAAC;IAC/D,QAAQ,CAAC,IAAI,YAAU;
|
|
1
|
+
{"version":3,"file":"OpenAiProvider.d.ts","sourceRoot":"","sources":["../../src/provider-openai/OpenAiProvider.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,UAAU,EACV,KAAK,uBAAuB,EAC5B,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACxB,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAErE;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,qBAAa,cAAe,SAAQ,UAAU,CAAC,iBAAiB,CAAC;IAC/D,QAAQ,CAAC,IAAI,YAAU;IACvB,QAAQ,CAAC,OAAO,SAAS;IACzB,QAAQ,CAAC,eAAe,QAAQ;IAEhC,QAAQ,CAAC,SAAS,iLASP;gBAGT,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,iBAAiB,CAAC,CAAC,EACpE,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,GAAG,EAAE,GAAG,EAAE,iBAAiB,CAAC,CAAC,EAC7E,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,uBAAuB,CAAC,GAAG,EAAE,GAAG,EAAE,iBAAiB,CAAC,CAAC;CAIvF"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Copyright 2025 Steven Roussey <sroussey@gmail.com>
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
import type { AiProviderReactiveRunFn, AiProviderRunFn, AiProviderStreamFn, CountTokensTaskInput, CountTokensTaskOutput, StructuredGenerationTaskInput, StructuredGenerationTaskOutput, TextEmbeddingTaskInput, TextEmbeddingTaskOutput, TextGenerationTaskInput, TextGenerationTaskOutput, TextRewriterTaskInput, TextRewriterTaskOutput, TextSummaryTaskInput, TextSummaryTaskOutput, ToolCallingTaskInput, ToolCallingTaskOutput } from "@workglow/ai";
|
|
6
|
+
import type { AiProviderReactiveRunFn, AiProviderRunFn, AiProviderStreamFn, CountTokensTaskInput, CountTokensTaskOutput, ModelInfoTaskInput, ModelInfoTaskOutput, StructuredGenerationTaskInput, StructuredGenerationTaskOutput, TextEmbeddingTaskInput, TextEmbeddingTaskOutput, TextGenerationTaskInput, TextGenerationTaskOutput, TextRewriterTaskInput, TextRewriterTaskOutput, TextSummaryTaskInput, TextSummaryTaskOutput, ToolCallingTaskInput, ToolCallingTaskOutput } from "@workglow/ai";
|
|
7
7
|
import type { OpenAiModelConfig } from "./OpenAI_ModelSchema";
|
|
8
8
|
export declare const OpenAI_TextGeneration: AiProviderRunFn<TextGenerationTaskInput, TextGenerationTaskOutput, OpenAiModelConfig>;
|
|
9
9
|
export declare const OpenAI_TextEmbedding: AiProviderRunFn<TextEmbeddingTaskInput, TextEmbeddingTaskOutput, OpenAiModelConfig>;
|
|
@@ -24,6 +24,7 @@ export declare const OpenAI_StructuredGeneration: AiProviderRunFn<StructuredGene
|
|
|
24
24
|
export declare const OpenAI_StructuredGeneration_Stream: AiProviderStreamFn<StructuredGenerationTaskInput, StructuredGenerationTaskOutput, OpenAiModelConfig>;
|
|
25
25
|
export declare const OpenAI_ToolCalling: AiProviderRunFn<ToolCallingTaskInput, ToolCallingTaskOutput, OpenAiModelConfig>;
|
|
26
26
|
export declare const OpenAI_ToolCalling_Stream: AiProviderStreamFn<ToolCallingTaskInput, ToolCallingTaskOutput, OpenAiModelConfig>;
|
|
27
|
+
export declare const OpenAI_ModelInfo: AiProviderRunFn<ModelInfoTaskInput, ModelInfoTaskOutput, OpenAiModelConfig>;
|
|
27
28
|
export declare const OPENAI_TASKS: Record<string, AiProviderRunFn<any, any, OpenAiModelConfig>>;
|
|
28
29
|
export declare const OPENAI_STREAM_TASKS: Record<string, AiProviderStreamFn<any, any, OpenAiModelConfig>>;
|
|
29
30
|
export declare const OPENAI_REACTIVE_TASKS: Record<string, AiProviderReactiveRunFn<any, any, OpenAiModelConfig>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenAI_JobRunFns.d.ts","sourceRoot":"","sources":["../../../src/provider-openai/common/OpenAI_JobRunFns.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,uBAAuB,EACvB,eAAe,EACf,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EACrB,6BAA6B,EAC7B,8BAA8B,EAC9B,sBAAsB,EACtB,uBAAuB,EACvB,uBAAuB,EACvB,wBAAwB,EACxB,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EAEtB,MAAM,cAAc,CAAC;AAItB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAkD9D,eAAO,MAAM,qBAAqB,EAAE,eAAe,CACjD,uBAAuB,EACvB,wBAAwB,EACxB,iBAAiB,
|
|
1
|
+
{"version":3,"file":"OpenAI_JobRunFns.d.ts","sourceRoot":"","sources":["../../../src/provider-openai/common/OpenAI_JobRunFns.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,uBAAuB,EACvB,eAAe,EACf,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EACrB,kBAAkB,EAClB,mBAAmB,EACnB,6BAA6B,EAC7B,8BAA8B,EAC9B,sBAAsB,EACtB,uBAAuB,EACvB,uBAAuB,EACvB,wBAAwB,EACxB,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EAEtB,MAAM,cAAc,CAAC;AAItB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAkD9D,eAAO,MAAM,qBAAqB,EAAE,eAAe,CACjD,uBAAuB,EACvB,wBAAwB,EACxB,iBAAiB,CAuClB,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,eAAe,CAChD,sBAAsB,EACtB,uBAAuB,EACvB,iBAAiB,CA6BlB,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,eAAe,CAC/C,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,CAgClB,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,eAAe,CAC9C,oBAAoB,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,CAAC,CASrF,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,MAAM,CACtC,MAAM,EACN,kBAAkB,CAAC,GAAG,EAAE,GAAG,EAAE,iBAAiB,CAAC,CAOhD,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,MAAM,CACxC,MAAM,EACN,uBAAuB,CAAC,GAAG,EAAE,GAAG,EAAE,iBAAiB,CAAC,CAGrD,CAAC"}
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
OpenAiModelRecordSchema,
|
|
5
5
|
OpenAiModelSchema,
|
|
6
6
|
OpenAiProvider
|
|
7
|
-
} from "../index-
|
|
7
|
+
} from "../index-q2t627d5.js";
|
|
8
8
|
import {
|
|
9
9
|
__require
|
|
10
10
|
} from "../index-6j5pq722.js";
|
|
@@ -44,6 +44,16 @@ function getModelName(model) {
|
|
|
44
44
|
return name;
|
|
45
45
|
}
|
|
46
46
|
var OpenAI_TextGeneration = async (input, model, update_progress, signal) => {
|
|
47
|
+
if (Array.isArray(input.prompt)) {
|
|
48
|
+
getLogger().warn("OpenAI_TextGeneration: array input received; processing sequentially (no native batch support)");
|
|
49
|
+
const prompts = input.prompt;
|
|
50
|
+
const results = [];
|
|
51
|
+
for (const item of prompts) {
|
|
52
|
+
const r = await OpenAI_TextGeneration({ ...input, prompt: item }, model, update_progress, signal);
|
|
53
|
+
results.push(r.text);
|
|
54
|
+
}
|
|
55
|
+
return { text: results };
|
|
56
|
+
}
|
|
47
57
|
const logger = getLogger();
|
|
48
58
|
const timerLabel = `openai:TextGeneration:${model?.provider_config?.model_name}`;
|
|
49
59
|
logger.time(timerLabel, { model: model?.provider_config?.model_name });
|
|
@@ -84,6 +94,16 @@ var OpenAI_TextEmbedding = async (input, model, update_progress, signal) => {
|
|
|
84
94
|
return { vector: new Float32Array(response.data[0].embedding) };
|
|
85
95
|
};
|
|
86
96
|
var OpenAI_TextRewriter = async (input, model, update_progress, signal) => {
|
|
97
|
+
if (Array.isArray(input.text)) {
|
|
98
|
+
getLogger().warn("OpenAI_TextRewriter: array input received; processing sequentially (no native batch support)");
|
|
99
|
+
const texts = input.text;
|
|
100
|
+
const results = [];
|
|
101
|
+
for (const item of texts) {
|
|
102
|
+
const r = await OpenAI_TextRewriter({ ...input, text: item }, model, update_progress, signal);
|
|
103
|
+
results.push(r.text);
|
|
104
|
+
}
|
|
105
|
+
return { text: results };
|
|
106
|
+
}
|
|
87
107
|
update_progress(0, "Starting OpenAI text rewriting");
|
|
88
108
|
const client = await getClient(model);
|
|
89
109
|
const modelName = getModelName(model);
|
|
@@ -98,6 +118,16 @@ var OpenAI_TextRewriter = async (input, model, update_progress, signal) => {
|
|
|
98
118
|
return { text: response.choices[0]?.message?.content ?? "" };
|
|
99
119
|
};
|
|
100
120
|
var OpenAI_TextSummary = async (input, model, update_progress, signal) => {
|
|
121
|
+
if (Array.isArray(input.text)) {
|
|
122
|
+
getLogger().warn("OpenAI_TextSummary: array input received; processing sequentially (no native batch support)");
|
|
123
|
+
const texts = input.text;
|
|
124
|
+
const results = [];
|
|
125
|
+
for (const item of texts) {
|
|
126
|
+
const r = await OpenAI_TextSummary({ ...input, text: item }, model, update_progress, signal);
|
|
127
|
+
results.push(r.text);
|
|
128
|
+
}
|
|
129
|
+
return { text: results };
|
|
130
|
+
}
|
|
101
131
|
update_progress(0, "Starting OpenAI text summarization");
|
|
102
132
|
const client = await getClient(model);
|
|
103
133
|
const modelName = getModelName(model);
|
|
@@ -202,6 +232,16 @@ async function getEncoder(modelName) {
|
|
|
202
232
|
return _encoderCache.get(modelName);
|
|
203
233
|
}
|
|
204
234
|
var OpenAI_CountTokens = async (input, model) => {
|
|
235
|
+
if (Array.isArray(input.text)) {
|
|
236
|
+
getLogger().warn("OpenAI_CountTokens: array input received; processing sequentially (no native batch support)");
|
|
237
|
+
const texts = input.text;
|
|
238
|
+
const counts = [];
|
|
239
|
+
for (const item of texts) {
|
|
240
|
+
const r = await OpenAI_CountTokens({ ...input, text: item }, model, () => {}, new AbortController().signal);
|
|
241
|
+
counts.push(r.count);
|
|
242
|
+
}
|
|
243
|
+
return { count: counts };
|
|
244
|
+
}
|
|
205
245
|
const enc = await getEncoder(getModelName(model));
|
|
206
246
|
const tokens = enc.encode(input.text);
|
|
207
247
|
return { count: tokens.length };
|
|
@@ -280,6 +320,18 @@ function mapOpenAIToolChoice(toolChoice) {
|
|
|
280
320
|
return { type: "function", function: { name: toolChoice } };
|
|
281
321
|
}
|
|
282
322
|
var OpenAI_ToolCalling = async (input, model, update_progress, signal) => {
|
|
323
|
+
if (Array.isArray(input.prompt)) {
|
|
324
|
+
getLogger().warn("OpenAI_ToolCalling: array input received; processing sequentially (no native batch support)");
|
|
325
|
+
const prompts = input.prompt;
|
|
326
|
+
const texts = [];
|
|
327
|
+
const toolCallsList = [];
|
|
328
|
+
for (const item of prompts) {
|
|
329
|
+
const r = await OpenAI_ToolCalling({ ...input, prompt: item }, model, update_progress, signal);
|
|
330
|
+
texts.push(r.text);
|
|
331
|
+
toolCallsList.push(r.toolCalls);
|
|
332
|
+
}
|
|
333
|
+
return { text: texts, toolCalls: toolCallsList };
|
|
334
|
+
}
|
|
283
335
|
update_progress(0, "Starting OpenAI tool calling");
|
|
284
336
|
const client = await getClient(model);
|
|
285
337
|
const modelName = getModelName(model);
|
|
@@ -423,8 +475,21 @@ var OpenAI_ToolCalling_Stream = async function* (input, model, signal) {
|
|
|
423
475
|
data: { text: accumulatedText, toolCalls: validToolCalls }
|
|
424
476
|
};
|
|
425
477
|
};
|
|
478
|
+
var OpenAI_ModelInfo = async (input) => {
|
|
479
|
+
return {
|
|
480
|
+
model: input.model,
|
|
481
|
+
is_local: false,
|
|
482
|
+
is_remote: true,
|
|
483
|
+
supports_browser: true,
|
|
484
|
+
supports_node: true,
|
|
485
|
+
is_cached: false,
|
|
486
|
+
is_loaded: false,
|
|
487
|
+
file_sizes: null
|
|
488
|
+
};
|
|
489
|
+
};
|
|
426
490
|
var OPENAI_TASKS = {
|
|
427
491
|
TextGenerationTask: OpenAI_TextGeneration,
|
|
492
|
+
ModelInfoTask: OpenAI_ModelInfo,
|
|
428
493
|
TextEmbeddingTask: OpenAI_TextEmbedding,
|
|
429
494
|
TextRewriterTask: OpenAI_TextRewriter,
|
|
430
495
|
TextSummaryTask: OpenAI_TextSummary,
|
|
@@ -467,6 +532,7 @@ export {
|
|
|
467
532
|
OpenAI_TextEmbedding,
|
|
468
533
|
OpenAI_StructuredGeneration_Stream,
|
|
469
534
|
OpenAI_StructuredGeneration,
|
|
535
|
+
OpenAI_ModelInfo,
|
|
470
536
|
OpenAI_CountTokens_Reactive,
|
|
471
537
|
OpenAI_CountTokens,
|
|
472
538
|
OPENAI_WORKER_JOBRUN_REGISTER,
|
|
@@ -476,4 +542,4 @@ export {
|
|
|
476
542
|
OPENAI
|
|
477
543
|
};
|
|
478
544
|
|
|
479
|
-
//# debugId=
|
|
545
|
+
//# debugId=5D380F4AD364860164756E2164756E21
|