@workglow/ai 0.1.1 → 0.2.0
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 +8 -7
- package/dist/browser.js +1436 -397
- package/dist/browser.js.map +64 -58
- package/dist/bun.js +1436 -397
- package/dist/bun.js.map +64 -58
- package/dist/common.d.ts +1 -0
- package/dist/common.d.ts.map +1 -1
- package/dist/execution/DirectExecutionStrategy.d.ts +1 -1
- package/dist/execution/DirectExecutionStrategy.d.ts.map +1 -1
- package/dist/execution/QueuedExecutionStrategy.d.ts +2 -2
- package/dist/execution/QueuedExecutionStrategy.d.ts.map +1 -1
- package/dist/job/AiJob.d.ts +2 -1
- package/dist/job/AiJob.d.ts.map +1 -1
- package/dist/model/ModelRegistry.d.ts.map +1 -1
- package/dist/model/ModelRepository.d.ts +11 -15
- package/dist/model/ModelRepository.d.ts.map +1 -1
- package/dist/model/ModelSchema.d.ts.map +1 -1
- package/dist/node.js +1436 -397
- package/dist/node.js.map +64 -58
- package/dist/provider/AiProvider.d.ts +2 -2
- package/dist/provider/AiProvider.d.ts.map +1 -1
- package/dist/provider/AiProviderRegistry.d.ts +3 -2
- package/dist/provider/AiProviderRegistry.d.ts.map +1 -1
- package/dist/provider/QueuedAiProvider.d.ts +2 -1
- package/dist/provider/QueuedAiProvider.d.ts.map +1 -1
- package/dist/task/AgentTask.d.ts +525 -0
- package/dist/task/AgentTask.d.ts.map +1 -0
- package/dist/task/AgentTypes.d.ts +183 -0
- package/dist/task/AgentTypes.d.ts.map +1 -0
- package/dist/task/AgentUtils.d.ts +55 -0
- package/dist/task/AgentUtils.d.ts.map +1 -0
- package/dist/task/BackgroundRemovalTask.d.ts +6 -34
- package/dist/task/BackgroundRemovalTask.d.ts.map +1 -1
- package/dist/task/ChunkRetrievalTask.d.ts +6 -4
- package/dist/task/ChunkRetrievalTask.d.ts.map +1 -1
- package/dist/task/ChunkToVectorTask.d.ts +6 -26
- package/dist/task/ChunkToVectorTask.d.ts.map +1 -1
- package/dist/task/ChunkVectorHybridSearchTask.d.ts +6 -25
- package/dist/task/ChunkVectorHybridSearchTask.d.ts.map +1 -1
- package/dist/task/ChunkVectorSearchTask.d.ts +6 -12
- package/dist/task/ChunkVectorSearchTask.d.ts.map +1 -1
- package/dist/task/ChunkVectorUpsertTask.d.ts +6 -13
- package/dist/task/ChunkVectorUpsertTask.d.ts.map +1 -1
- package/dist/task/ContextBuilderTask.d.ts +6 -30
- package/dist/task/ContextBuilderTask.d.ts.map +1 -1
- package/dist/task/CountTokensTask.d.ts +6 -21
- package/dist/task/CountTokensTask.d.ts.map +1 -1
- package/dist/task/DocumentEnricherTask.d.ts +6 -40
- package/dist/task/DocumentEnricherTask.d.ts.map +1 -1
- package/dist/task/DownloadModelTask.d.ts +7 -21
- package/dist/task/DownloadModelTask.d.ts.map +1 -1
- package/dist/task/FaceDetectorTask.d.ts +6 -36
- package/dist/task/FaceDetectorTask.d.ts.map +1 -1
- package/dist/task/FaceLandmarkerTask.d.ts +6 -40
- package/dist/task/FaceLandmarkerTask.d.ts.map +1 -1
- package/dist/task/GestureRecognizerTask.d.ts +6 -38
- package/dist/task/GestureRecognizerTask.d.ts.map +1 -1
- package/dist/task/HandLandmarkerTask.d.ts +6 -38
- package/dist/task/HandLandmarkerTask.d.ts.map +1 -1
- package/dist/task/HierarchicalChunkerTask.d.ts +6 -26
- package/dist/task/HierarchicalChunkerTask.d.ts.map +1 -1
- package/dist/task/HierarchyJoinTask.d.ts +6 -29
- package/dist/task/HierarchyJoinTask.d.ts.map +1 -1
- package/dist/task/ImageClassificationTask.d.ts +6 -36
- package/dist/task/ImageClassificationTask.d.ts.map +1 -1
- package/dist/task/ImageEmbeddingTask.d.ts +6 -47
- package/dist/task/ImageEmbeddingTask.d.ts.map +1 -1
- package/dist/task/ImageSegmentationTask.d.ts +6 -36
- package/dist/task/ImageSegmentationTask.d.ts.map +1 -1
- package/dist/task/ImageToTextTask.d.ts +6 -35
- package/dist/task/ImageToTextTask.d.ts.map +1 -1
- package/dist/task/MessageConversion.d.ts +52 -0
- package/dist/task/MessageConversion.d.ts.map +1 -0
- package/dist/task/ModelInfoTask.d.ts +7 -22
- package/dist/task/ModelInfoTask.d.ts.map +1 -1
- package/dist/task/ModelSearchTask.d.ts +6 -7
- package/dist/task/ModelSearchTask.d.ts.map +1 -1
- package/dist/task/ObjectDetectionTask.d.ts +6 -36
- package/dist/task/ObjectDetectionTask.d.ts.map +1 -1
- package/dist/task/PoseLandmarkerTask.d.ts +6 -39
- package/dist/task/PoseLandmarkerTask.d.ts.map +1 -1
- package/dist/task/QueryExpanderTask.d.ts +6 -9
- package/dist/task/QueryExpanderTask.d.ts.map +1 -1
- package/dist/task/RerankerTask.d.ts +6 -28
- package/dist/task/RerankerTask.d.ts.map +1 -1
- package/dist/task/StructuralParserTask.d.ts +6 -10
- package/dist/task/StructuralParserTask.d.ts.map +1 -1
- package/dist/task/StructuredGenerationTask.d.ts +6 -26
- package/dist/task/StructuredGenerationTask.d.ts.map +1 -1
- package/dist/task/TextChunkerTask.d.ts +6 -9
- package/dist/task/TextChunkerTask.d.ts.map +1 -1
- package/dist/task/TextClassificationTask.d.ts +6 -23
- package/dist/task/TextClassificationTask.d.ts.map +1 -1
- package/dist/task/TextEmbeddingTask.d.ts +6 -21
- package/dist/task/TextEmbeddingTask.d.ts.map +1 -1
- package/dist/task/TextFillMaskTask.d.ts +6 -21
- package/dist/task/TextFillMaskTask.d.ts.map +1 -1
- package/dist/task/TextGenerationTask.d.ts +6 -26
- package/dist/task/TextGenerationTask.d.ts.map +1 -1
- package/dist/task/TextLanguageDetectionTask.d.ts +6 -22
- package/dist/task/TextLanguageDetectionTask.d.ts.map +1 -1
- package/dist/task/TextNamedEntityRecognitionTask.d.ts +6 -22
- package/dist/task/TextNamedEntityRecognitionTask.d.ts.map +1 -1
- package/dist/task/TextQuestionAnswerTask.d.ts +6 -22
- package/dist/task/TextQuestionAnswerTask.d.ts.map +1 -1
- package/dist/task/TextRewriterTask.d.ts +6 -22
- package/dist/task/TextRewriterTask.d.ts.map +1 -1
- package/dist/task/TextSummaryTask.d.ts +6 -21
- package/dist/task/TextSummaryTask.d.ts.map +1 -1
- package/dist/task/TextTranslationTask.d.ts +6 -23
- package/dist/task/TextTranslationTask.d.ts.map +1 -1
- package/dist/task/ToolCallingTask.d.ts +348 -0
- package/dist/task/ToolCallingTask.d.ts.map +1 -0
- package/dist/task/ToolCallingUtils.d.ts +75 -0
- package/dist/task/ToolCallingUtils.d.ts.map +1 -0
- package/dist/task/TopicSegmenterTask.d.ts +6 -10
- package/dist/task/TopicSegmenterTask.d.ts.map +1 -1
- package/dist/task/UnloadModelTask.d.ts +6 -20
- package/dist/task/UnloadModelTask.d.ts.map +1 -1
- package/dist/task/VectorQuantizeTask.d.ts +6 -8
- package/dist/task/VectorQuantizeTask.d.ts.map +1 -1
- package/dist/task/VectorSimilarityTask.d.ts +7 -10
- package/dist/task/VectorSimilarityTask.d.ts.map +1 -1
- package/dist/task/base/AiTask.d.ts +8 -5
- package/dist/task/base/AiTask.d.ts.map +1 -1
- package/dist/task/base/AiTaskSchemas.d.ts.map +1 -1
- package/dist/task/base/AiVisionTask.d.ts +3 -7
- package/dist/task/base/AiVisionTask.d.ts.map +1 -1
- package/dist/task/base/StreamingAiTask.d.ts +4 -7
- package/dist/task/base/StreamingAiTask.d.ts.map +1 -1
- package/dist/task/index.d.ts +9 -1
- package/dist/task/index.d.ts.map +1 -1
- package/dist/worker.d.ts +2 -0
- package/dist/worker.d.ts.map +1 -1
- package/dist/worker.js +247 -25
- package/dist/worker.js.map +9 -7
- package/package.json +16 -11
package/dist/node.js
CHANGED
|
@@ -4,7 +4,8 @@ import {
|
|
|
4
4
|
Job,
|
|
5
5
|
JobStatus,
|
|
6
6
|
PermanentJobError,
|
|
7
|
-
RetryableJobError
|
|
7
|
+
RetryableJobError,
|
|
8
|
+
withJobErrorDiagnostics
|
|
8
9
|
} from "@workglow/job-queue";
|
|
9
10
|
import { getLogger } from "@workglow/util/worker";
|
|
10
11
|
|
|
@@ -137,16 +138,13 @@ function setAiProviderRegistry(pr) {
|
|
|
137
138
|
|
|
138
139
|
// src/job/AiJob.ts
|
|
139
140
|
var DEFAULT_AI_TIMEOUT_MS = 120000;
|
|
140
|
-
var
|
|
141
|
+
var LOCAL_INFERENCE_DEFAULT_TIMEOUT_MS = 300000;
|
|
141
142
|
function resolveAiJobTimeoutMs(aiProvider, explicitMs) {
|
|
142
143
|
if (explicitMs !== undefined) {
|
|
143
144
|
return explicitMs;
|
|
144
145
|
}
|
|
145
|
-
if (aiProvider === "LOCAL_LLAMACPP") {
|
|
146
|
-
return
|
|
147
|
-
}
|
|
148
|
-
if (aiProvider === "HF_TRANSFORMERS_ONNX" || aiProvider.startsWith("HF_TRANSFORMERS_ONNX")) {
|
|
149
|
-
return LOCAL_MODEL_DEFAULT_TIMEOUT_MS;
|
|
146
|
+
if (aiProvider === "LOCAL_LLAMACPP" || aiProvider === "HF_TRANSFORMERS_ONNX") {
|
|
147
|
+
return LOCAL_INFERENCE_DEFAULT_TIMEOUT_MS;
|
|
150
148
|
}
|
|
151
149
|
return DEFAULT_AI_TIMEOUT_MS;
|
|
152
150
|
}
|
|
@@ -159,39 +157,39 @@ function classifyProviderError(err, taskType, provider) {
|
|
|
159
157
|
const m = message.match(/\b([45]\d{2})\b/);
|
|
160
158
|
return m ? parseInt(m[1], 10) : undefined;
|
|
161
159
|
})();
|
|
162
|
-
if (err instanceof
|
|
163
|
-
return new AbortSignalJobError(`Provider call aborted for ${taskType} (${provider})
|
|
160
|
+
if (err instanceof Error && err.name === "AbortError") {
|
|
161
|
+
return new AbortSignalJobError(withJobErrorDiagnostics(`Provider call aborted for ${taskType} (${provider})`, err));
|
|
164
162
|
}
|
|
165
|
-
if (err instanceof
|
|
166
|
-
return new AbortSignalJobError(`Provider call timed out for ${taskType} (${provider})
|
|
163
|
+
if (err instanceof Error && err.name === "TimeoutError") {
|
|
164
|
+
return new AbortSignalJobError(withJobErrorDiagnostics(`Provider call timed out for ${taskType} (${provider})`, err));
|
|
167
165
|
}
|
|
168
166
|
if (message.includes("Pipeline download aborted") || message.includes("Operation aborted") || message.includes("operation was aborted") || message.includes("The operation was aborted")) {
|
|
169
|
-
return new AbortSignalJobError(`Provider call aborted for ${taskType} (${provider}): ${message}
|
|
167
|
+
return new AbortSignalJobError(withJobErrorDiagnostics(`Provider call aborted for ${taskType} (${provider}): ${message}`, err));
|
|
170
168
|
}
|
|
171
169
|
if (message.startsWith("HFT_NULL_PROCESSOR:")) {
|
|
172
|
-
return new RetryableJobError(message);
|
|
170
|
+
return new RetryableJobError(withJobErrorDiagnostics(message, err));
|
|
173
171
|
}
|
|
174
172
|
if (status === 429) {
|
|
175
173
|
const retryAfterMatch = message.match(/retry.after[:\s]*(\d+)/i);
|
|
176
174
|
const retryMs = retryAfterMatch ? parseInt(retryAfterMatch[1], 10) * 1000 : 30000;
|
|
177
|
-
return new RetryableJobError(`Rate limited by ${provider} for ${taskType}: ${message}`, new Date(Date.now() + retryMs));
|
|
175
|
+
return new RetryableJobError(withJobErrorDiagnostics(`Rate limited by ${provider} for ${taskType}: ${message}`, err), new Date(Date.now() + retryMs));
|
|
178
176
|
}
|
|
179
177
|
if (status === 401 || status === 403) {
|
|
180
|
-
return new PermanentJobError(`Authentication failed for ${provider} (${taskType}): ${message}
|
|
178
|
+
return new PermanentJobError(withJobErrorDiagnostics(`Authentication failed for ${provider} (${taskType}): ${message}`, err));
|
|
181
179
|
}
|
|
182
180
|
if (status === 400 || status === 404) {
|
|
183
|
-
return new PermanentJobError(`Invalid request to ${provider} for ${taskType}: ${message}
|
|
181
|
+
return new PermanentJobError(withJobErrorDiagnostics(`Invalid request to ${provider} for ${taskType}: ${message}`, err));
|
|
184
182
|
}
|
|
185
183
|
if (status && status >= 500) {
|
|
186
|
-
return new RetryableJobError(`Server error from ${provider} for ${taskType} (HTTP ${status}): ${message}
|
|
184
|
+
return new RetryableJobError(withJobErrorDiagnostics(`Server error from ${provider} for ${taskType} (HTTP ${status}): ${message}`, err));
|
|
187
185
|
}
|
|
188
186
|
if (message.includes("ECONNREFUSED") || message.includes("ECONNRESET") || message.includes("ETIMEDOUT") || message.includes("fetch failed") || message.includes("network") || err instanceof TypeError && message.includes("fetch")) {
|
|
189
|
-
return new RetryableJobError(`Network error calling ${provider} for ${taskType}: ${message}
|
|
187
|
+
return new RetryableJobError(withJobErrorDiagnostics(`Network error calling ${provider} for ${taskType}: ${message}`, err));
|
|
190
188
|
}
|
|
191
189
|
if (message.includes("timed out") || message.includes("timeout")) {
|
|
192
|
-
return new RetryableJobError(`Timeout calling ${provider} for ${taskType}: ${message}
|
|
190
|
+
return new RetryableJobError(withJobErrorDiagnostics(`Timeout calling ${provider} for ${taskType}: ${message}`, err));
|
|
193
191
|
}
|
|
194
|
-
return new PermanentJobError(`Provider ${provider} failed for ${taskType}: ${message}
|
|
192
|
+
return new PermanentJobError(withJobErrorDiagnostics(`Provider ${provider} failed for ${taskType}: ${message}`, err));
|
|
195
193
|
}
|
|
196
194
|
|
|
197
195
|
class AiJob extends Job {
|
|
@@ -297,12 +295,14 @@ class DirectExecutionStrategy {
|
|
|
297
295
|
}
|
|
298
296
|
|
|
299
297
|
// src/execution/QueuedExecutionStrategy.ts
|
|
300
|
-
import { ConcurrencyLimiter, JobQueueClient, JobQueueServer } from "@workglow/job-queue";
|
|
301
|
-
import { InMemoryQueueStorage } from "@workglow/storage";
|
|
302
298
|
import {
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
299
|
+
AbortSignalJobError as AbortSignalJobError2,
|
|
300
|
+
ConcurrencyLimiter,
|
|
301
|
+
JobQueueClient,
|
|
302
|
+
JobQueueServer
|
|
303
|
+
} from "@workglow/job-queue";
|
|
304
|
+
import { InMemoryQueueStorage } from "@workglow/storage";
|
|
305
|
+
import { getTaskQueueRegistry, TaskConfigurationError } from "@workglow/task-graph";
|
|
306
306
|
class QueuedExecutionStrategy {
|
|
307
307
|
queueName;
|
|
308
308
|
concurrency;
|
|
@@ -315,7 +315,7 @@ class QueuedExecutionStrategy {
|
|
|
315
315
|
}
|
|
316
316
|
async execute(jobInput, context, runnerId) {
|
|
317
317
|
if (context.signal.aborted) {
|
|
318
|
-
throw context.signal.reason ?? new
|
|
318
|
+
throw context.signal.reason ?? new AbortSignalJobError2("The operation was aborted");
|
|
319
319
|
}
|
|
320
320
|
const registeredQueue = await this.ensureQueue();
|
|
321
321
|
const { client } = registeredQueue;
|
|
@@ -334,7 +334,7 @@ class QueuedExecutionStrategy {
|
|
|
334
334
|
});
|
|
335
335
|
try {
|
|
336
336
|
if (context.signal.aborted) {
|
|
337
|
-
throw context.signal.reason ?? new
|
|
337
|
+
throw context.signal.reason ?? new AbortSignalJobError2("The operation was aborted");
|
|
338
338
|
}
|
|
339
339
|
const output = await handle.waitFor();
|
|
340
340
|
return output;
|
|
@@ -408,11 +408,101 @@ class QueuedExecutionStrategy {
|
|
|
408
408
|
}
|
|
409
409
|
}
|
|
410
410
|
|
|
411
|
+
// src/task/ToolCallingUtils.ts
|
|
412
|
+
import { getLogger as getLogger2 } from "@workglow/util/worker";
|
|
413
|
+
function buildToolDescription(tool) {
|
|
414
|
+
let desc = tool.description;
|
|
415
|
+
if (tool.outputSchema && typeof tool.outputSchema === "object") {
|
|
416
|
+
desc += `
|
|
417
|
+
|
|
418
|
+
Returns: ${JSON.stringify(tool.outputSchema)}`;
|
|
419
|
+
}
|
|
420
|
+
return desc;
|
|
421
|
+
}
|
|
422
|
+
function isAllowedToolName(name, allowedTools) {
|
|
423
|
+
return allowedTools.some((t) => t.name === name);
|
|
424
|
+
}
|
|
425
|
+
function filterValidToolCalls(toolCalls, allowedTools) {
|
|
426
|
+
return toolCalls.filter((tc) => {
|
|
427
|
+
if (tc.name && isAllowedToolName(tc.name, allowedTools)) {
|
|
428
|
+
return true;
|
|
429
|
+
}
|
|
430
|
+
getLogger2().warn(`Filtered out tool call with unknown name "${tc.name ?? "(missing)"}"`, {
|
|
431
|
+
callId: tc.id,
|
|
432
|
+
toolName: tc.name
|
|
433
|
+
});
|
|
434
|
+
return false;
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
|
|
411
438
|
// src/model/InMemoryModelRepository.ts
|
|
412
439
|
import { InMemoryTabularStorage } from "@workglow/storage";
|
|
413
440
|
|
|
414
441
|
// src/model/ModelRepository.ts
|
|
415
442
|
import { EventEmitter } from "@workglow/util";
|
|
443
|
+
import { compileSchema } from "@workglow/util/schema";
|
|
444
|
+
|
|
445
|
+
// src/model/ModelSchema.ts
|
|
446
|
+
var ModelConfigSchema = {
|
|
447
|
+
type: "object",
|
|
448
|
+
properties: {
|
|
449
|
+
model_id: { type: "string" },
|
|
450
|
+
tasks: { type: "array", items: { type: "string" }, "x-ui-editor": "multiselect" },
|
|
451
|
+
title: { type: "string" },
|
|
452
|
+
description: { type: "string", "x-ui-editor": "textarea" },
|
|
453
|
+
provider: { type: "string" },
|
|
454
|
+
provider_config: {
|
|
455
|
+
type: "object",
|
|
456
|
+
properties: {
|
|
457
|
+
credential_key: { type: "string", format: "credential", "x-ui-hidden": true }
|
|
458
|
+
},
|
|
459
|
+
additionalProperties: true,
|
|
460
|
+
default: {}
|
|
461
|
+
},
|
|
462
|
+
metadata: { type: "object", default: {}, "x-ui-hidden": true }
|
|
463
|
+
},
|
|
464
|
+
required: ["provider", "provider_config"],
|
|
465
|
+
format: "model",
|
|
466
|
+
additionalProperties: true
|
|
467
|
+
};
|
|
468
|
+
var ModelRecordSchema = {
|
|
469
|
+
type: "object",
|
|
470
|
+
properties: {
|
|
471
|
+
...ModelConfigSchema.properties
|
|
472
|
+
},
|
|
473
|
+
required: [
|
|
474
|
+
"model_id",
|
|
475
|
+
"tasks",
|
|
476
|
+
"provider",
|
|
477
|
+
"title",
|
|
478
|
+
"description",
|
|
479
|
+
"provider_config",
|
|
480
|
+
"metadata"
|
|
481
|
+
],
|
|
482
|
+
format: "model",
|
|
483
|
+
additionalProperties: false
|
|
484
|
+
};
|
|
485
|
+
var ModelPrimaryKeyNames = ["model_id"];
|
|
486
|
+
|
|
487
|
+
// src/model/ModelRepository.ts
|
|
488
|
+
var compiledModelRecordSchema;
|
|
489
|
+
function getModelRecordSchemaNode() {
|
|
490
|
+
if (!compiledModelRecordSchema) {
|
|
491
|
+
compiledModelRecordSchema = compileSchema(ModelRecordSchema);
|
|
492
|
+
}
|
|
493
|
+
return compiledModelRecordSchema;
|
|
494
|
+
}
|
|
495
|
+
function validateModelRecord(model) {
|
|
496
|
+
const schemaNode = getModelRecordSchemaNode();
|
|
497
|
+
const result = schemaNode.validate(model);
|
|
498
|
+
if (!result.valid) {
|
|
499
|
+
const errorMessages = result.errors.map((e) => {
|
|
500
|
+
const path = e.data?.pointer || "";
|
|
501
|
+
return `${e.message}${path ? ` (${path})` : ""}`;
|
|
502
|
+
});
|
|
503
|
+
throw new Error(`Invalid model record: ${errorMessages.join(", ")}`);
|
|
504
|
+
}
|
|
505
|
+
}
|
|
416
506
|
|
|
417
507
|
class ModelRepository {
|
|
418
508
|
modelTabularRepository;
|
|
@@ -436,10 +526,25 @@ class ModelRepository {
|
|
|
436
526
|
return this.events.waitOn(name);
|
|
437
527
|
}
|
|
438
528
|
async addModel(model) {
|
|
529
|
+
validateModelRecord(model);
|
|
530
|
+
const existing = await this.modelTabularRepository.get({ model_id: model.model_id });
|
|
531
|
+
if (existing) {
|
|
532
|
+
throw new Error(`Model with id "${model.model_id}" already exists`);
|
|
533
|
+
}
|
|
439
534
|
await this.modelTabularRepository.put(model);
|
|
440
535
|
this.events.emit("model_added", model);
|
|
441
536
|
return model;
|
|
442
537
|
}
|
|
538
|
+
async updateModel(model) {
|
|
539
|
+
validateModelRecord(model);
|
|
540
|
+
const existing = await this.modelTabularRepository.get({ model_id: model.model_id });
|
|
541
|
+
if (!existing) {
|
|
542
|
+
throw new Error(`Model with id "${model.model_id}" not found`);
|
|
543
|
+
}
|
|
544
|
+
await this.modelTabularRepository.put(model);
|
|
545
|
+
this.events.emit("model_updated", model);
|
|
546
|
+
return model;
|
|
547
|
+
}
|
|
443
548
|
async removeModel(model_id) {
|
|
444
549
|
const model = await this.modelTabularRepository.get({ model_id });
|
|
445
550
|
if (!model) {
|
|
@@ -498,48 +603,6 @@ class ModelRepository {
|
|
|
498
603
|
}
|
|
499
604
|
}
|
|
500
605
|
|
|
501
|
-
// src/model/ModelSchema.ts
|
|
502
|
-
var ModelConfigSchema = {
|
|
503
|
-
type: "object",
|
|
504
|
-
properties: {
|
|
505
|
-
model_id: { type: "string" },
|
|
506
|
-
tasks: { type: "array", items: { type: "string" }, "x-ui-editor": "multiselect" },
|
|
507
|
-
title: { type: "string" },
|
|
508
|
-
description: { type: "string", "x-ui-editor": "textarea" },
|
|
509
|
-
provider: { type: "string" },
|
|
510
|
-
provider_config: {
|
|
511
|
-
type: "object",
|
|
512
|
-
properties: {
|
|
513
|
-
credential_key: { type: "string", format: "credential", "x-ui-hidden": true }
|
|
514
|
-
},
|
|
515
|
-
additionalProperties: true,
|
|
516
|
-
default: {}
|
|
517
|
-
},
|
|
518
|
-
metadata: { type: "object", default: {}, "x-ui-hidden": true }
|
|
519
|
-
},
|
|
520
|
-
required: ["provider", "provider_config"],
|
|
521
|
-
format: "model",
|
|
522
|
-
additionalProperties: true
|
|
523
|
-
};
|
|
524
|
-
var ModelRecordSchema = {
|
|
525
|
-
type: "object",
|
|
526
|
-
properties: {
|
|
527
|
-
...ModelConfigSchema.properties
|
|
528
|
-
},
|
|
529
|
-
required: [
|
|
530
|
-
"model_id",
|
|
531
|
-
"tasks",
|
|
532
|
-
"provider",
|
|
533
|
-
"title",
|
|
534
|
-
"description",
|
|
535
|
-
"provider_config",
|
|
536
|
-
"metadata"
|
|
537
|
-
],
|
|
538
|
-
format: "model",
|
|
539
|
-
additionalProperties: false
|
|
540
|
-
};
|
|
541
|
-
var ModelPrimaryKeyNames = ["model_id"];
|
|
542
|
-
|
|
543
606
|
// src/model/InMemoryModelRepository.ts
|
|
544
607
|
class InMemoryModelRepository extends ModelRepository {
|
|
545
608
|
constructor() {
|
|
@@ -551,12 +614,11 @@ class InMemoryModelRepository extends ModelRepository {
|
|
|
551
614
|
import {
|
|
552
615
|
createServiceToken,
|
|
553
616
|
globalServiceRegistry as globalServiceRegistry2,
|
|
617
|
+
registerInputCompactor,
|
|
554
618
|
registerInputResolver
|
|
555
619
|
} from "@workglow/util";
|
|
556
620
|
var MODEL_REPOSITORY = createServiceToken("model.repository");
|
|
557
|
-
|
|
558
|
-
globalServiceRegistry2.register(MODEL_REPOSITORY, () => new InMemoryModelRepository, true);
|
|
559
|
-
}
|
|
621
|
+
globalServiceRegistry2.registerIfAbsent(MODEL_REPOSITORY, () => new InMemoryModelRepository, true);
|
|
560
622
|
function getGlobalModelRepository() {
|
|
561
623
|
return globalServiceRegistry2.get(MODEL_REPOSITORY);
|
|
562
624
|
}
|
|
@@ -572,12 +634,22 @@ async function resolveModelFromRegistry(id, format, registry) {
|
|
|
572
634
|
return model;
|
|
573
635
|
}
|
|
574
636
|
registerInputResolver("model", resolveModelFromRegistry);
|
|
637
|
+
registerInputCompactor("model", async (value, _format, registry) => {
|
|
638
|
+
if (typeof value === "object" && value !== null && "model_id" in value) {
|
|
639
|
+
const id = value.model_id;
|
|
640
|
+
if (typeof id !== "string")
|
|
641
|
+
return;
|
|
642
|
+
const modelRepo = registry.has(MODEL_REPOSITORY) ? registry.get(MODEL_REPOSITORY) : getGlobalModelRepository();
|
|
643
|
+
const model = await modelRepo.findByName(id);
|
|
644
|
+
if (!model)
|
|
645
|
+
return;
|
|
646
|
+
return id;
|
|
647
|
+
}
|
|
648
|
+
return;
|
|
649
|
+
});
|
|
575
650
|
|
|
576
651
|
// src/provider/AiProvider.ts
|
|
577
|
-
import {
|
|
578
|
-
globalServiceRegistry as globalServiceRegistry3,
|
|
579
|
-
WORKER_MANAGER as WORKER_MANAGER2
|
|
580
|
-
} from "@workglow/util/worker";
|
|
652
|
+
import { globalServiceRegistry as globalServiceRegistry3, WORKER_MANAGER as WORKER_MANAGER2 } from "@workglow/util/worker";
|
|
581
653
|
function resolveAiProviderGpuQueueConcurrency(concurrency) {
|
|
582
654
|
if (concurrency === undefined) {
|
|
583
655
|
return 1;
|
|
@@ -697,8 +769,74 @@ class QueuedAiProvider extends AiProvider {
|
|
|
697
769
|
// src/task/index.ts
|
|
698
770
|
import { TaskRegistry } from "@workglow/task-graph";
|
|
699
771
|
|
|
700
|
-
// src/task/
|
|
701
|
-
import { CreateWorkflow, Workflow } from "@workglow/task-graph";
|
|
772
|
+
// src/task/AgentTask.ts
|
|
773
|
+
import { CreateWorkflow as CreateWorkflow2, Task as Task2, Workflow as Workflow2 } from "@workglow/task-graph";
|
|
774
|
+
import { getLogger as getLogger4 } from "@workglow/util";
|
|
775
|
+
|
|
776
|
+
// src/task/AgentTypes.ts
|
|
777
|
+
import { parseDataUri } from "@workglow/util/media";
|
|
778
|
+
function imageBlock(mimeType, data) {
|
|
779
|
+
return { type: "image", mimeType, data };
|
|
780
|
+
}
|
|
781
|
+
function audioBlock(mimeType, data) {
|
|
782
|
+
return { type: "audio", mimeType, data };
|
|
783
|
+
}
|
|
784
|
+
function imageBlockFromDataUri(dataUri) {
|
|
785
|
+
const { mimeType, base64 } = parseDataUri(dataUri);
|
|
786
|
+
return { type: "image", mimeType, data: base64 };
|
|
787
|
+
}
|
|
788
|
+
function audioBlockFromDataUri(dataUri) {
|
|
789
|
+
const { mimeType, base64 } = parseDataUri(dataUri);
|
|
790
|
+
return { type: "audio", mimeType, data: base64 };
|
|
791
|
+
}
|
|
792
|
+
function userMessage(prompt) {
|
|
793
|
+
return { role: "user", content: prompt };
|
|
794
|
+
}
|
|
795
|
+
function assistantMessage(text, toolCalls) {
|
|
796
|
+
const content = [];
|
|
797
|
+
if (text) {
|
|
798
|
+
content.push({ type: "text", text });
|
|
799
|
+
}
|
|
800
|
+
if (toolCalls) {
|
|
801
|
+
for (const tc of toolCalls) {
|
|
802
|
+
content.push({
|
|
803
|
+
type: "tool_use",
|
|
804
|
+
id: tc.id,
|
|
805
|
+
name: tc.name,
|
|
806
|
+
input: tc.input
|
|
807
|
+
});
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
return { role: "assistant", content };
|
|
811
|
+
}
|
|
812
|
+
function toolMessage(results) {
|
|
813
|
+
return {
|
|
814
|
+
role: "tool",
|
|
815
|
+
content: results.map((r) => {
|
|
816
|
+
const jsonText = JSON.stringify(r.output);
|
|
817
|
+
const content = r.mediaContent && r.mediaContent.length > 0 ? [{ type: "text", text: jsonText }, ...r.mediaContent] : jsonText;
|
|
818
|
+
return {
|
|
819
|
+
type: "tool_result",
|
|
820
|
+
tool_use_id: r.toolCallId,
|
|
821
|
+
content,
|
|
822
|
+
is_error: r.isError || undefined
|
|
823
|
+
};
|
|
824
|
+
})
|
|
825
|
+
};
|
|
826
|
+
}
|
|
827
|
+
function toolSourceDefinitions(sources) {
|
|
828
|
+
return sources.map((s) => s.definition);
|
|
829
|
+
}
|
|
830
|
+
function findToolSource(sources, name) {
|
|
831
|
+
return sources.find((s) => s.definition.name === name);
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
// src/task/AgentUtils.ts
|
|
835
|
+
import { getTaskConstructors as getTaskConstructors2, TaskAbortedError } from "@workglow/task-graph";
|
|
836
|
+
import { getLogger as getLogger3 } from "@workglow/util";
|
|
837
|
+
|
|
838
|
+
// src/task/ToolCallingTask.ts
|
|
839
|
+
import { CreateWorkflow, getTaskConstructors, Workflow } from "@workglow/task-graph";
|
|
702
840
|
|
|
703
841
|
// src/task/base/AiTaskSchemas.ts
|
|
704
842
|
var TypeLanguage = (annotations = {}) => ({
|
|
@@ -857,11 +995,12 @@ var TypeCategory = {
|
|
|
857
995
|
description: "Classification category with label and score"
|
|
858
996
|
};
|
|
859
997
|
|
|
860
|
-
// src/task/base/
|
|
861
|
-
import {
|
|
998
|
+
// src/task/base/StreamingAiTask.ts
|
|
999
|
+
import { getStreamingPorts, TaskConfigurationError as TaskConfigurationError3 } from "@workglow/task-graph";
|
|
862
1000
|
|
|
863
1001
|
// src/task/base/AiTask.ts
|
|
864
1002
|
import {
|
|
1003
|
+
Entitlements,
|
|
865
1004
|
Task,
|
|
866
1005
|
TaskConfigSchema,
|
|
867
1006
|
TaskConfigurationError as TaskConfigurationError2,
|
|
@@ -880,6 +1019,27 @@ var aiTaskConfigSchema = {
|
|
|
880
1019
|
|
|
881
1020
|
class AiTask extends Task {
|
|
882
1021
|
static type = "AiTask";
|
|
1022
|
+
static hasDynamicEntitlements = true;
|
|
1023
|
+
static entitlements() {
|
|
1024
|
+
return {
|
|
1025
|
+
entitlements: [{ id: Entitlements.AI_INFERENCE, reason: "Runs AI model inference" }]
|
|
1026
|
+
};
|
|
1027
|
+
}
|
|
1028
|
+
entitlements() {
|
|
1029
|
+
const base = [
|
|
1030
|
+
{ id: Entitlements.AI_INFERENCE, reason: "Runs AI model inference" }
|
|
1031
|
+
];
|
|
1032
|
+
const runModel = this.runInputData?.model;
|
|
1033
|
+
const modelId = typeof runModel === "string" ? runModel : typeof this.defaults.model === "string" ? this.defaults.model : undefined;
|
|
1034
|
+
if (modelId) {
|
|
1035
|
+
base.push({
|
|
1036
|
+
id: Entitlements.AI_MODEL,
|
|
1037
|
+
reason: `Uses model ${modelId}`,
|
|
1038
|
+
resources: [modelId]
|
|
1039
|
+
});
|
|
1040
|
+
}
|
|
1041
|
+
return { entitlements: base };
|
|
1042
|
+
}
|
|
883
1043
|
static configSchema() {
|
|
884
1044
|
return aiTaskConfigSchema;
|
|
885
1045
|
}
|
|
@@ -942,71 +1102,773 @@ class AiTask extends Task {
|
|
|
942
1102
|
return reactiveFn(input, output, model);
|
|
943
1103
|
}
|
|
944
1104
|
}
|
|
945
|
-
return super.executeReactive(input, output, context);
|
|
1105
|
+
return super.executeReactive(input, output, context);
|
|
1106
|
+
}
|
|
1107
|
+
async validateInput(input) {
|
|
1108
|
+
const inputSchema = this.inputSchema();
|
|
1109
|
+
if (typeof inputSchema === "boolean") {
|
|
1110
|
+
if (inputSchema === false) {
|
|
1111
|
+
throw new TaskConfigurationError2(`AiTask: Input schema is 'false' and accepts no inputs`);
|
|
1112
|
+
}
|
|
1113
|
+
return true;
|
|
1114
|
+
}
|
|
1115
|
+
const modelTaskProperties = Object.entries(inputSchema.properties || {}).filter(([key, schema]) => schemaFormat(schema)?.startsWith("model:"));
|
|
1116
|
+
for (const [key] of modelTaskProperties) {
|
|
1117
|
+
const model = input[key];
|
|
1118
|
+
if (typeof model === "object" && model !== null) {
|
|
1119
|
+
const tasks = model.tasks;
|
|
1120
|
+
if (Array.isArray(tasks) && tasks.length > 0 && !tasks.includes(this.type)) {
|
|
1121
|
+
const modelId = model.model_id ?? "(inline config)";
|
|
1122
|
+
throw new TaskConfigurationError2(`AiTask: Model "${modelId}" for '${key}' is not compatible with task '${this.type}'. ` + `Model supports: [${tasks.join(", ")}]`);
|
|
1123
|
+
}
|
|
1124
|
+
} else if (model !== undefined && model !== null) {
|
|
1125
|
+
throw new TaskConfigurationError2(`AiTask: Invalid model for '${key}' - expected ModelConfig object but got ${typeof model}. ` + `Ensure the model ID was registered in the ModelRepository before running the task.`);
|
|
1126
|
+
}
|
|
1127
|
+
}
|
|
1128
|
+
const modelPlainProperties = Object.entries(inputSchema.properties || {}).filter(([key, schema]) => schemaFormat(schema) === "model");
|
|
1129
|
+
for (const [key] of modelPlainProperties) {
|
|
1130
|
+
const model = input[key];
|
|
1131
|
+
if (model !== undefined && model !== null && typeof model !== "object") {
|
|
1132
|
+
throw new TaskConfigurationError2(`AiTask: Invalid model for '${key}' - expected ModelConfig object but got ${typeof model}. ` + `Ensure the model ID was registered in the ModelRepository before running the task.`);
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
return super.validateInput(input);
|
|
1136
|
+
}
|
|
1137
|
+
async narrowInput(input, registry) {
|
|
1138
|
+
const inputSchema = this.inputSchema();
|
|
1139
|
+
if (typeof inputSchema === "boolean") {
|
|
1140
|
+
if (inputSchema === false) {
|
|
1141
|
+
throw new TaskConfigurationError2(`AiTask: Input schema is 'false' and accepts no inputs`);
|
|
1142
|
+
}
|
|
1143
|
+
return input;
|
|
1144
|
+
}
|
|
1145
|
+
const modelTaskProperties = Object.entries(inputSchema.properties || {}).filter(([key, schema]) => schemaFormat(schema)?.startsWith("model:"));
|
|
1146
|
+
if (modelTaskProperties.length > 0) {
|
|
1147
|
+
const modelRepo = registry.get(MODEL_REPOSITORY);
|
|
1148
|
+
const taskModels = await modelRepo.findModelsByTask(this.type) ?? [];
|
|
1149
|
+
for (const [key, propSchema] of modelTaskProperties) {
|
|
1150
|
+
const requestedModel = input[key];
|
|
1151
|
+
if (typeof requestedModel === "string") {
|
|
1152
|
+
const found = taskModels?.find((m) => m.model_id === requestedModel);
|
|
1153
|
+
if (!found) {
|
|
1154
|
+
input[key] = undefined;
|
|
1155
|
+
}
|
|
1156
|
+
} else if (typeof requestedModel === "object" && requestedModel !== null) {
|
|
1157
|
+
const model = requestedModel;
|
|
1158
|
+
const tasks = model.tasks;
|
|
1159
|
+
if (Array.isArray(tasks) && tasks.length > 0 && !tasks.includes(this.type)) {
|
|
1160
|
+
input[key] = undefined;
|
|
1161
|
+
}
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
return input;
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
|
|
1169
|
+
// src/task/base/StreamingAiTask.ts
|
|
1170
|
+
class StreamingAiTask extends AiTask {
|
|
1171
|
+
static type = "StreamingAiTask";
|
|
1172
|
+
async* executeStream(input, context) {
|
|
1173
|
+
const model = input.model;
|
|
1174
|
+
if (!model || typeof model !== "object") {
|
|
1175
|
+
throw new TaskConfigurationError3("StreamingAiTask: Model was not resolved to ModelConfig - this indicates a bug in the resolution system");
|
|
1176
|
+
}
|
|
1177
|
+
const jobInput = await this.getJobInput(input);
|
|
1178
|
+
const strategy = getAiProviderRegistry().getStrategy(model);
|
|
1179
|
+
const outSchema = this.outputSchema();
|
|
1180
|
+
const ports = getStreamingPorts(outSchema);
|
|
1181
|
+
let defaultPort = "text";
|
|
1182
|
+
if (ports.length > 0) {
|
|
1183
|
+
defaultPort = ports[0].port;
|
|
1184
|
+
} else {
|
|
1185
|
+
if (typeof outSchema === "object" && outSchema.properties) {
|
|
1186
|
+
const firstProp = Object.keys(outSchema.properties)[0];
|
|
1187
|
+
if (firstProp)
|
|
1188
|
+
defaultPort = firstProp;
|
|
1189
|
+
}
|
|
1190
|
+
}
|
|
1191
|
+
for await (const event of strategy.executeStream(jobInput, context, this.runConfig.runnerId)) {
|
|
1192
|
+
if (event.type === "text-delta") {
|
|
1193
|
+
yield { ...event, port: event.port ?? defaultPort };
|
|
1194
|
+
} else if (event.type === "object-delta") {
|
|
1195
|
+
yield { ...event, port: event.port ?? defaultPort };
|
|
1196
|
+
} else {
|
|
1197
|
+
yield event;
|
|
1198
|
+
}
|
|
1199
|
+
}
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1202
|
+
|
|
1203
|
+
// src/task/ToolCallingTask.ts
|
|
1204
|
+
function taskTypesToTools(taskNames, registry) {
|
|
1205
|
+
const constructors = getTaskConstructors(registry);
|
|
1206
|
+
return taskNames.map((name) => {
|
|
1207
|
+
const ctor = constructors.get(name);
|
|
1208
|
+
if (!ctor) {
|
|
1209
|
+
throw new Error(`taskTypesToTools: Unknown task type "${name}" — not found in task constructors registry (ServiceRegistry: ${registry ? "custom" : "default"})`);
|
|
1210
|
+
}
|
|
1211
|
+
const configSchema = "configSchema" in ctor && typeof ctor.configSchema === "function" ? ctor.configSchema() : undefined;
|
|
1212
|
+
return {
|
|
1213
|
+
name: ctor.type,
|
|
1214
|
+
description: ctor.description ?? "",
|
|
1215
|
+
inputSchema: ctor.inputSchema(),
|
|
1216
|
+
outputSchema: ctor.outputSchema(),
|
|
1217
|
+
...configSchema ? { configSchema } : {},
|
|
1218
|
+
taskType: name
|
|
1219
|
+
};
|
|
1220
|
+
});
|
|
1221
|
+
}
|
|
1222
|
+
var ToolDefinitionSchema = {
|
|
1223
|
+
type: "object",
|
|
1224
|
+
properties: {
|
|
1225
|
+
name: {
|
|
1226
|
+
type: "string",
|
|
1227
|
+
title: "Name",
|
|
1228
|
+
description: "The tool name"
|
|
1229
|
+
},
|
|
1230
|
+
description: {
|
|
1231
|
+
type: "string",
|
|
1232
|
+
title: "Description",
|
|
1233
|
+
description: "A description of what the tool does"
|
|
1234
|
+
},
|
|
1235
|
+
inputSchema: {
|
|
1236
|
+
type: "object",
|
|
1237
|
+
title: "Input Schema",
|
|
1238
|
+
description: "JSON Schema describing the tool's input parameters",
|
|
1239
|
+
additionalProperties: true
|
|
1240
|
+
},
|
|
1241
|
+
outputSchema: {
|
|
1242
|
+
type: "object",
|
|
1243
|
+
title: "Output Schema",
|
|
1244
|
+
description: "JSON Schema describing what the tool returns",
|
|
1245
|
+
additionalProperties: true
|
|
1246
|
+
},
|
|
1247
|
+
configSchema: {
|
|
1248
|
+
type: "object",
|
|
1249
|
+
title: "Config Schema",
|
|
1250
|
+
description: "JSON Schema describing the task's configuration options (not sent to the LLM)",
|
|
1251
|
+
additionalProperties: true
|
|
1252
|
+
},
|
|
1253
|
+
config: {
|
|
1254
|
+
type: "object",
|
|
1255
|
+
title: "Config",
|
|
1256
|
+
description: "Concrete configuration values for the backing task (not sent to the LLM)",
|
|
1257
|
+
additionalProperties: true
|
|
1258
|
+
}
|
|
1259
|
+
},
|
|
1260
|
+
required: ["name", "description", "inputSchema"],
|
|
1261
|
+
additionalProperties: true
|
|
1262
|
+
};
|
|
1263
|
+
var ToolCallSchema = {
|
|
1264
|
+
type: "object",
|
|
1265
|
+
properties: {
|
|
1266
|
+
id: {
|
|
1267
|
+
type: "string",
|
|
1268
|
+
title: "ID",
|
|
1269
|
+
description: "Unique identifier for this tool call"
|
|
1270
|
+
},
|
|
1271
|
+
name: {
|
|
1272
|
+
type: "string",
|
|
1273
|
+
title: "Name",
|
|
1274
|
+
description: "The name of the tool to invoke"
|
|
1275
|
+
},
|
|
1276
|
+
input: {
|
|
1277
|
+
type: "object",
|
|
1278
|
+
title: "Input",
|
|
1279
|
+
description: "The input arguments for the tool call",
|
|
1280
|
+
additionalProperties: true
|
|
1281
|
+
}
|
|
1282
|
+
},
|
|
1283
|
+
required: ["id", "name", "input"],
|
|
1284
|
+
additionalProperties: false
|
|
1285
|
+
};
|
|
1286
|
+
var modelSchema = TypeModel("model:ToolCallingTask");
|
|
1287
|
+
var ToolCallingInputSchema = {
|
|
1288
|
+
type: "object",
|
|
1289
|
+
properties: {
|
|
1290
|
+
model: modelSchema,
|
|
1291
|
+
prompt: {
|
|
1292
|
+
oneOf: [
|
|
1293
|
+
{ type: "string", title: "Prompt", description: "The prompt to send to the model" },
|
|
1294
|
+
{
|
|
1295
|
+
type: "array",
|
|
1296
|
+
title: "Prompt",
|
|
1297
|
+
description: "The prompt as an array of strings or content blocks",
|
|
1298
|
+
items: {
|
|
1299
|
+
oneOf: [
|
|
1300
|
+
{ type: "string" },
|
|
1301
|
+
{
|
|
1302
|
+
type: "object",
|
|
1303
|
+
properties: {
|
|
1304
|
+
type: { type: "string", enum: ["text", "image", "audio"] }
|
|
1305
|
+
},
|
|
1306
|
+
required: ["type"],
|
|
1307
|
+
additionalProperties: true
|
|
1308
|
+
}
|
|
1309
|
+
]
|
|
1310
|
+
}
|
|
1311
|
+
}
|
|
1312
|
+
],
|
|
1313
|
+
title: "Prompt",
|
|
1314
|
+
description: "The prompt to send to the model"
|
|
1315
|
+
},
|
|
1316
|
+
systemPrompt: {
|
|
1317
|
+
type: "string",
|
|
1318
|
+
title: "System Prompt",
|
|
1319
|
+
description: "Optional system instructions for the model"
|
|
1320
|
+
},
|
|
1321
|
+
messages: {
|
|
1322
|
+
type: "array",
|
|
1323
|
+
title: "Messages",
|
|
1324
|
+
description: "Full conversation history for multi-turn interactions. When provided, used instead of prompt to construct the messages array sent to the provider.",
|
|
1325
|
+
items: {
|
|
1326
|
+
type: "object",
|
|
1327
|
+
properties: {
|
|
1328
|
+
role: { type: "string", enum: ["user", "assistant", "tool"] },
|
|
1329
|
+
content: {}
|
|
1330
|
+
},
|
|
1331
|
+
required: ["role", "content"],
|
|
1332
|
+
additionalProperties: true
|
|
1333
|
+
}
|
|
1334
|
+
},
|
|
1335
|
+
tools: {
|
|
1336
|
+
type: "array",
|
|
1337
|
+
format: "tasks",
|
|
1338
|
+
title: "Tools",
|
|
1339
|
+
description: "Tool definitions available for the model to call",
|
|
1340
|
+
items: {
|
|
1341
|
+
oneOf: [
|
|
1342
|
+
{ type: "string", format: "tasks", description: "Task type name" },
|
|
1343
|
+
ToolDefinitionSchema
|
|
1344
|
+
]
|
|
1345
|
+
}
|
|
1346
|
+
},
|
|
1347
|
+
toolChoice: {
|
|
1348
|
+
type: "string",
|
|
1349
|
+
title: "Tool Choice",
|
|
1350
|
+
description: 'Controls tool selection: "auto" (model decides), "none" (no tools), "required" (must call a tool), or a specific tool name',
|
|
1351
|
+
"x-ui-group": "Configuration"
|
|
1352
|
+
},
|
|
1353
|
+
maxTokens: {
|
|
1354
|
+
type: "number",
|
|
1355
|
+
title: "Max Tokens",
|
|
1356
|
+
description: "The maximum number of tokens to generate",
|
|
1357
|
+
minimum: 1,
|
|
1358
|
+
"x-ui-group": "Configuration"
|
|
1359
|
+
},
|
|
1360
|
+
temperature: {
|
|
1361
|
+
type: "number",
|
|
1362
|
+
title: "Temperature",
|
|
1363
|
+
description: "The temperature to use for sampling",
|
|
1364
|
+
minimum: 0,
|
|
1365
|
+
maximum: 2,
|
|
1366
|
+
"x-ui-group": "Configuration"
|
|
1367
|
+
}
|
|
1368
|
+
},
|
|
1369
|
+
required: ["model", "prompt", "tools"],
|
|
1370
|
+
additionalProperties: false
|
|
1371
|
+
};
|
|
1372
|
+
var ToolCallingOutputSchema = {
|
|
1373
|
+
type: "object",
|
|
1374
|
+
properties: {
|
|
1375
|
+
text: {
|
|
1376
|
+
type: "string",
|
|
1377
|
+
title: "Text",
|
|
1378
|
+
description: "Any text content generated by the model",
|
|
1379
|
+
"x-stream": "append"
|
|
1380
|
+
},
|
|
1381
|
+
toolCalls: {
|
|
1382
|
+
type: "array",
|
|
1383
|
+
items: ToolCallSchema,
|
|
1384
|
+
title: "Tool Calls",
|
|
1385
|
+
description: "Tool calls requested by the model",
|
|
1386
|
+
"x-stream": "object"
|
|
1387
|
+
}
|
|
1388
|
+
},
|
|
1389
|
+
required: ["text", "toolCalls"],
|
|
1390
|
+
additionalProperties: false
|
|
1391
|
+
};
|
|
1392
|
+
|
|
1393
|
+
class ToolCallingTask extends StreamingAiTask {
|
|
1394
|
+
static type = "ToolCallingTask";
|
|
1395
|
+
static category = "AI Text Model";
|
|
1396
|
+
static title = "Tool Calling";
|
|
1397
|
+
static description = "Sends a prompt with tool definitions to a language model and returns text along with any tool calls the model requests";
|
|
1398
|
+
static inputSchema() {
|
|
1399
|
+
return ToolCallingInputSchema;
|
|
1400
|
+
}
|
|
1401
|
+
static outputSchema() {
|
|
1402
|
+
return ToolCallingOutputSchema;
|
|
1403
|
+
}
|
|
1404
|
+
}
|
|
1405
|
+
var toolCalling = (input, config) => {
|
|
1406
|
+
return new ToolCallingTask(config).run(input);
|
|
1407
|
+
};
|
|
1408
|
+
Workflow.prototype.toolCalling = CreateWorkflow(ToolCallingTask);
|
|
1409
|
+
|
|
1410
|
+
// src/task/AgentUtils.ts
|
|
1411
|
+
function resolveToolConfig(toolName, config, taskConfigSchema) {
|
|
1412
|
+
if (config && !taskConfigSchema) {
|
|
1413
|
+
getLogger3().warn(`AgentTask: Tool "${toolName}" provided config but task has no configSchema — config ignored`);
|
|
1414
|
+
return {};
|
|
1415
|
+
}
|
|
1416
|
+
return config;
|
|
1417
|
+
}
|
|
1418
|
+
function buildToolSources(tools, registry) {
|
|
1419
|
+
if (!tools || tools.length === 0)
|
|
1420
|
+
return [];
|
|
1421
|
+
const stringNames = tools.filter((t) => typeof t === "string");
|
|
1422
|
+
const resolvedDefs = new Map(taskTypesToTools(stringNames, registry).map((d) => [d.taskType, d]));
|
|
1423
|
+
const constructors = getTaskConstructors2(registry);
|
|
1424
|
+
const sources = [];
|
|
1425
|
+
for (const tool of tools) {
|
|
1426
|
+
if (typeof tool === "string") {
|
|
1427
|
+
const def = resolvedDefs.get(tool);
|
|
1428
|
+
if (def) {
|
|
1429
|
+
const { taskType, ...definition } = def;
|
|
1430
|
+
sources.push({
|
|
1431
|
+
type: "registry",
|
|
1432
|
+
definition,
|
|
1433
|
+
taskType
|
|
1434
|
+
});
|
|
1435
|
+
}
|
|
1436
|
+
} else if (tool.type === "function" || !tool.type && tool.execute) {
|
|
1437
|
+
if (!tool.execute) {
|
|
1438
|
+
getLogger3().warn(`AgentTask: Tool "${tool.name}" has type "function" but no execute function — will throw on invocation`);
|
|
1439
|
+
}
|
|
1440
|
+
const { execute, configSchema: _cs, config: _c, type: _t, ...definition } = tool;
|
|
1441
|
+
sources.push({
|
|
1442
|
+
type: "function",
|
|
1443
|
+
definition,
|
|
1444
|
+
run: execute ?? (async () => {
|
|
1445
|
+
throw new Error(`No execute function for tool "${tool.name}"`);
|
|
1446
|
+
})
|
|
1447
|
+
});
|
|
1448
|
+
} else if (tool.type === "task") {
|
|
1449
|
+
const ctor = constructors.get(tool.name);
|
|
1450
|
+
if (!ctor) {
|
|
1451
|
+
getLogger3().warn(`AgentTask: Tool "${tool.name}" has type "task" but is not in TaskRegistry — will throw on invocation`);
|
|
1452
|
+
const { execute: _e, configSchema: _cs, config: _c, type: _t, ...definition } = tool;
|
|
1453
|
+
sources.push({
|
|
1454
|
+
type: "function",
|
|
1455
|
+
definition,
|
|
1456
|
+
run: async () => {
|
|
1457
|
+
throw new Error(`Task "${tool.name}" not found in TaskRegistry`);
|
|
1458
|
+
}
|
|
1459
|
+
});
|
|
1460
|
+
} else {
|
|
1461
|
+
const safeConfig = resolveToolConfig(tool.name, tool.config, ctor.configSchema?.());
|
|
1462
|
+
const { execute: _e, configSchema: _cs, config: _c, type: _t, ...definition } = tool;
|
|
1463
|
+
sources.push({
|
|
1464
|
+
type: "registry",
|
|
1465
|
+
definition,
|
|
1466
|
+
taskType: tool.name,
|
|
1467
|
+
config: safeConfig
|
|
1468
|
+
});
|
|
1469
|
+
}
|
|
1470
|
+
} else {
|
|
1471
|
+
const ctor = constructors.get(tool.name);
|
|
1472
|
+
if (ctor) {
|
|
1473
|
+
const safeConfig = resolveToolConfig(tool.name, tool.config, ctor.configSchema?.());
|
|
1474
|
+
const { execute: _e, configSchema: _cs, config: _c, type: _t, ...definition } = tool;
|
|
1475
|
+
sources.push({
|
|
1476
|
+
type: "registry",
|
|
1477
|
+
definition,
|
|
1478
|
+
taskType: tool.name,
|
|
1479
|
+
config: safeConfig
|
|
1480
|
+
});
|
|
1481
|
+
} else {
|
|
1482
|
+
const { execute: _e, configSchema: _cs, config: _c, type: _t, ...definition } = tool;
|
|
1483
|
+
sources.push({
|
|
1484
|
+
type: "function",
|
|
1485
|
+
definition,
|
|
1486
|
+
run: async () => {
|
|
1487
|
+
throw new Error(`No executor registered for tool "${tool.name}"`);
|
|
1488
|
+
}
|
|
1489
|
+
});
|
|
1490
|
+
}
|
|
1491
|
+
}
|
|
1492
|
+
}
|
|
1493
|
+
return sources;
|
|
1494
|
+
}
|
|
1495
|
+
async function executeToolCall(toolCall, sources, context, hooks) {
|
|
1496
|
+
const source = findToolSource(sources, toolCall.name);
|
|
1497
|
+
if (!source) {
|
|
1498
|
+
getLogger3().warn(`AgentTask: Unknown tool "${toolCall.name}" — not found in tool sources`);
|
|
1499
|
+
return {
|
|
1500
|
+
toolCallId: toolCall.id,
|
|
1501
|
+
toolName: toolCall.name,
|
|
1502
|
+
output: { error: `Unknown tool: ${toolCall.name}` },
|
|
1503
|
+
isError: true
|
|
1504
|
+
};
|
|
1505
|
+
}
|
|
1506
|
+
let effectiveCall = toolCall;
|
|
1507
|
+
if (hooks?.beforeToolCall) {
|
|
1508
|
+
const decision = await hooks.beforeToolCall(toolCall, source);
|
|
1509
|
+
if (decision.action === "deny") {
|
|
1510
|
+
return {
|
|
1511
|
+
toolCallId: toolCall.id,
|
|
1512
|
+
toolName: toolCall.name,
|
|
1513
|
+
output: { error: decision.reason ?? "Tool call denied by hook" },
|
|
1514
|
+
isError: true
|
|
1515
|
+
};
|
|
1516
|
+
}
|
|
1517
|
+
if (decision.action === "modify") {
|
|
1518
|
+
effectiveCall = { ...toolCall, input: decision.input };
|
|
1519
|
+
}
|
|
1520
|
+
}
|
|
1521
|
+
try {
|
|
1522
|
+
let output;
|
|
1523
|
+
switch (source.type) {
|
|
1524
|
+
case "registry": {
|
|
1525
|
+
const ctor = getTaskConstructors2(context.registry).get(source.taskType);
|
|
1526
|
+
if (!ctor) {
|
|
1527
|
+
throw new Error(`Task type "${source.taskType}" not found in TaskRegistry`);
|
|
1528
|
+
}
|
|
1529
|
+
const taskConfig = source.config ?? {};
|
|
1530
|
+
const task = context.own(new ctor({}, taskConfig));
|
|
1531
|
+
output = await task.run(effectiveCall.input) ?? {};
|
|
1532
|
+
break;
|
|
1533
|
+
}
|
|
1534
|
+
case "function": {
|
|
1535
|
+
output = await source.run(effectiveCall.input);
|
|
1536
|
+
break;
|
|
1537
|
+
}
|
|
1538
|
+
}
|
|
1539
|
+
let result = {
|
|
1540
|
+
toolCallId: toolCall.id,
|
|
1541
|
+
toolName: toolCall.name,
|
|
1542
|
+
output,
|
|
1543
|
+
isError: false
|
|
1544
|
+
};
|
|
1545
|
+
if (hooks?.afterToolCall) {
|
|
1546
|
+
result = await hooks.afterToolCall(toolCall, result);
|
|
1547
|
+
}
|
|
1548
|
+
return result;
|
|
1549
|
+
} catch (err) {
|
|
1550
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
1551
|
+
if (hooks?.onToolError) {
|
|
1552
|
+
const action = await hooks.onToolError(toolCall, error);
|
|
1553
|
+
if (action.action === "result") {
|
|
1554
|
+
return {
|
|
1555
|
+
toolCallId: toolCall.id,
|
|
1556
|
+
toolName: toolCall.name,
|
|
1557
|
+
output: action.output,
|
|
1558
|
+
isError: false
|
|
1559
|
+
};
|
|
1560
|
+
}
|
|
1561
|
+
}
|
|
1562
|
+
getLogger3().warn(`AgentTask: Tool "${toolCall.name}" failed: ${error.message}`);
|
|
1563
|
+
return {
|
|
1564
|
+
toolCallId: toolCall.id,
|
|
1565
|
+
toolName: toolCall.name,
|
|
1566
|
+
output: { error: error.message },
|
|
1567
|
+
isError: true
|
|
1568
|
+
};
|
|
1569
|
+
}
|
|
1570
|
+
}
|
|
1571
|
+
async function executeToolCalls(toolCalls, sources, context, hooks, maxConcurrency = 5) {
|
|
1572
|
+
const calls = toolCalls;
|
|
1573
|
+
if (calls.length === 0)
|
|
1574
|
+
return [];
|
|
1575
|
+
const concurrency = Math.max(1, Math.min(maxConcurrency, calls.length));
|
|
1576
|
+
const results = new Array(calls.length);
|
|
1577
|
+
let cursor = 0;
|
|
1578
|
+
const workers = Array.from({ length: concurrency }, async () => {
|
|
1579
|
+
while (true) {
|
|
1580
|
+
if (context.signal.aborted) {
|
|
1581
|
+
throw context.signal.reason ?? new TaskAbortedError("The operation was aborted");
|
|
1582
|
+
}
|
|
1583
|
+
const position = cursor;
|
|
1584
|
+
cursor += 1;
|
|
1585
|
+
if (position >= calls.length)
|
|
1586
|
+
return;
|
|
1587
|
+
results[position] = await executeToolCall(calls[position], sources, context, hooks);
|
|
1588
|
+
}
|
|
1589
|
+
});
|
|
1590
|
+
await Promise.all(workers);
|
|
1591
|
+
return results;
|
|
1592
|
+
}
|
|
1593
|
+
function hasToolCalls(toolCalls) {
|
|
1594
|
+
return toolCalls !== undefined && toolCalls.length > 0;
|
|
1595
|
+
}
|
|
1596
|
+
function countAssistantToolUses(messages) {
|
|
1597
|
+
let n = 0;
|
|
1598
|
+
for (const m of messages) {
|
|
1599
|
+
if (m.role !== "assistant")
|
|
1600
|
+
continue;
|
|
1601
|
+
for (const block of m.content) {
|
|
1602
|
+
if (block.type === "tool_use")
|
|
1603
|
+
n += 1;
|
|
1604
|
+
}
|
|
1605
|
+
}
|
|
1606
|
+
return n;
|
|
1607
|
+
}
|
|
1608
|
+
|
|
1609
|
+
// src/task/AgentTask.ts
|
|
1610
|
+
var MAX_CONTEXT_MESSAGES = 1000;
|
|
1611
|
+
var modelSchema2 = TypeModel("model:ToolCallingTask");
|
|
1612
|
+
var AgentInputSchema = {
|
|
1613
|
+
type: "object",
|
|
1614
|
+
properties: {
|
|
1615
|
+
model: modelSchema2,
|
|
1616
|
+
prompt: {
|
|
1617
|
+
oneOf: [
|
|
1618
|
+
{ type: "string" },
|
|
1619
|
+
{
|
|
1620
|
+
type: "array",
|
|
1621
|
+
items: {
|
|
1622
|
+
type: "object",
|
|
1623
|
+
properties: {
|
|
1624
|
+
type: { type: "string", enum: ["text", "image", "audio"] }
|
|
1625
|
+
},
|
|
1626
|
+
required: ["type"],
|
|
1627
|
+
additionalProperties: true
|
|
1628
|
+
}
|
|
1629
|
+
}
|
|
1630
|
+
],
|
|
1631
|
+
title: "Prompt",
|
|
1632
|
+
description: "The user prompt to start the agent loop. Can be a string or an array of content blocks (text, image, audio)."
|
|
1633
|
+
},
|
|
1634
|
+
systemPrompt: {
|
|
1635
|
+
type: "string",
|
|
1636
|
+
title: "System Prompt",
|
|
1637
|
+
description: "Optional system instructions for the agent"
|
|
1638
|
+
},
|
|
1639
|
+
tools: {
|
|
1640
|
+
type: "array",
|
|
1641
|
+
format: "tasks",
|
|
1642
|
+
title: "Tools",
|
|
1643
|
+
description: "Tools available to the agent. Each entry is a task type name (string, resolved from TaskRegistry) or a full ToolDefinition object with optional config for configurable tasks.",
|
|
1644
|
+
items: {
|
|
1645
|
+
oneOf: [
|
|
1646
|
+
{ type: "string", format: "tasks", description: "Task type name" },
|
|
1647
|
+
ToolDefinitionSchema
|
|
1648
|
+
]
|
|
1649
|
+
}
|
|
1650
|
+
},
|
|
1651
|
+
stopTool: {
|
|
1652
|
+
type: "string",
|
|
1653
|
+
title: "Stop Tool",
|
|
1654
|
+
description: "Name of a tool that signals agent completion. When called, the loop ends and the tool input becomes structuredOutput.",
|
|
1655
|
+
"x-ui-group": "Configuration"
|
|
1656
|
+
},
|
|
1657
|
+
maxIterations: {
|
|
1658
|
+
type: "number",
|
|
1659
|
+
title: "Max Iterations",
|
|
1660
|
+
description: "Maximum number of agent loop iterations (default: 10)",
|
|
1661
|
+
minimum: 1,
|
|
1662
|
+
"x-ui-group": "Configuration"
|
|
1663
|
+
},
|
|
1664
|
+
maxContextMessages: {
|
|
1665
|
+
type: "number",
|
|
1666
|
+
title: "Max Context Messages",
|
|
1667
|
+
description: "Maximum messages in conversation history. Older messages are trimmed to prevent context overflow.",
|
|
1668
|
+
minimum: 3,
|
|
1669
|
+
"x-ui-group": "Configuration"
|
|
1670
|
+
},
|
|
1671
|
+
maxTokens: {
|
|
1672
|
+
type: "number",
|
|
1673
|
+
title: "Max Tokens",
|
|
1674
|
+
description: "Maximum tokens per LLM call",
|
|
1675
|
+
minimum: 1,
|
|
1676
|
+
"x-ui-group": "Configuration"
|
|
1677
|
+
},
|
|
1678
|
+
temperature: {
|
|
1679
|
+
type: "number",
|
|
1680
|
+
title: "Temperature",
|
|
1681
|
+
description: "Sampling temperature for LLM calls",
|
|
1682
|
+
minimum: 0,
|
|
1683
|
+
maximum: 2,
|
|
1684
|
+
"x-ui-group": "Configuration"
|
|
1685
|
+
}
|
|
1686
|
+
},
|
|
1687
|
+
required: ["model", "prompt"],
|
|
1688
|
+
additionalProperties: false
|
|
1689
|
+
};
|
|
1690
|
+
var AgentOutputSchema = {
|
|
1691
|
+
type: "object",
|
|
1692
|
+
properties: {
|
|
1693
|
+
text: {
|
|
1694
|
+
type: "string",
|
|
1695
|
+
title: "Text",
|
|
1696
|
+
description: "The final text response from the agent",
|
|
1697
|
+
"x-stream": "append"
|
|
1698
|
+
},
|
|
1699
|
+
messages: {
|
|
1700
|
+
type: "array",
|
|
1701
|
+
title: "Messages",
|
|
1702
|
+
description: "Full conversation history including all tool calls and results",
|
|
1703
|
+
items: {
|
|
1704
|
+
type: "object",
|
|
1705
|
+
additionalProperties: true
|
|
1706
|
+
}
|
|
1707
|
+
},
|
|
1708
|
+
iterations: {
|
|
1709
|
+
type: "number",
|
|
1710
|
+
title: "Iterations",
|
|
1711
|
+
description: "Number of LLM calls made during the agent loop"
|
|
1712
|
+
},
|
|
1713
|
+
toolCallCount: {
|
|
1714
|
+
type: "number",
|
|
1715
|
+
title: "Tool Call Count",
|
|
1716
|
+
description: "Total number of tool calls the assistant requested (tool_use blocks in assistant messages)"
|
|
1717
|
+
},
|
|
1718
|
+
structuredOutput: {
|
|
1719
|
+
type: "object",
|
|
1720
|
+
title: "Structured Output",
|
|
1721
|
+
description: "Present when the agent terminated via a stop tool",
|
|
1722
|
+
additionalProperties: true
|
|
1723
|
+
}
|
|
1724
|
+
},
|
|
1725
|
+
required: ["text", "messages", "iterations", "toolCallCount"],
|
|
1726
|
+
additionalProperties: false
|
|
1727
|
+
};
|
|
1728
|
+
|
|
1729
|
+
class AgentTask extends Task2 {
|
|
1730
|
+
static type = "AgentTask";
|
|
1731
|
+
static category = "AI Agent";
|
|
1732
|
+
static title = "Agent";
|
|
1733
|
+
static description = "Multi-turn agentic loop that calls an LLM with tools, executes tool calls, and iterates until done";
|
|
1734
|
+
static cacheable = false;
|
|
1735
|
+
static inputSchema() {
|
|
1736
|
+
return AgentInputSchema;
|
|
946
1737
|
}
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
const modelTaskProperties = Object.entries(inputSchema.properties || {}).filter(([key, schema]) => schemaFormat(schema)?.startsWith("model:"));
|
|
956
|
-
for (const [key] of modelTaskProperties) {
|
|
957
|
-
const model = input[key];
|
|
958
|
-
if (typeof model === "object" && model !== null) {
|
|
959
|
-
const tasks = model.tasks;
|
|
960
|
-
if (Array.isArray(tasks) && tasks.length > 0 && !tasks.includes(this.type)) {
|
|
961
|
-
const modelId = model.model_id ?? "(inline config)";
|
|
962
|
-
throw new TaskConfigurationError2(`AiTask: Model "${modelId}" for '${key}' is not compatible with task '${this.type}'. ` + `Model supports: [${tasks.join(", ")}]`);
|
|
963
|
-
}
|
|
964
|
-
} else if (model !== undefined && model !== null) {
|
|
965
|
-
throw new TaskConfigurationError2(`AiTask: Invalid model for '${key}' - expected ModelConfig object but got ${typeof model}. ` + `Ensure the model ID was registered in the ModelRepository before running the task.`);
|
|
1738
|
+
static outputSchema() {
|
|
1739
|
+
return AgentOutputSchema;
|
|
1740
|
+
}
|
|
1741
|
+
async execute(input, context) {
|
|
1742
|
+
let result;
|
|
1743
|
+
for await (const event of this.agentLoop(input, context)) {
|
|
1744
|
+
if (event.type === "finish") {
|
|
1745
|
+
result = event.data;
|
|
966
1746
|
}
|
|
967
1747
|
}
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
const model = input[key];
|
|
971
|
-
if (model !== undefined && model !== null && typeof model !== "object") {
|
|
972
|
-
throw new TaskConfigurationError2(`AiTask: Invalid model for '${key}' - expected ModelConfig object but got ${typeof model}. ` + `Ensure the model ID was registered in the ModelRepository before running the task.`);
|
|
973
|
-
}
|
|
1748
|
+
if (!result) {
|
|
1749
|
+
throw new Error("AgentTask: loop ended without producing output");
|
|
974
1750
|
}
|
|
975
|
-
return
|
|
1751
|
+
return result;
|
|
976
1752
|
}
|
|
977
|
-
async
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
1753
|
+
async* executeStream(input, context) {
|
|
1754
|
+
yield* this.agentLoop(input, context);
|
|
1755
|
+
}
|
|
1756
|
+
async* agentLoop(input, context) {
|
|
1757
|
+
const maxIterations = input.maxIterations ?? 10;
|
|
1758
|
+
const hooks = this.config.hooks;
|
|
1759
|
+
const maxConcurrency = this.config.maxConcurrency ?? 5;
|
|
1760
|
+
const toolSources = this.resolveToolSources(input, context);
|
|
1761
|
+
const toolDefs = this.resolveToolDefs(toolSources, input.stopTool);
|
|
1762
|
+
const messages = [userMessage(input.prompt)];
|
|
1763
|
+
let finalText = "";
|
|
1764
|
+
let structuredOutput;
|
|
1765
|
+
for (let iteration = 0;iteration < maxIterations; iteration++) {
|
|
1766
|
+
if (context.signal.aborted)
|
|
1767
|
+
break;
|
|
1768
|
+
if (hooks?.onIteration) {
|
|
1769
|
+
const action = await hooks.onIteration(iteration, messages, {
|
|
1770
|
+
totalToolCalls: countAssistantToolUses(messages)
|
|
1771
|
+
});
|
|
1772
|
+
if (action.action === "stop")
|
|
1773
|
+
break;
|
|
982
1774
|
}
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
const
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
1775
|
+
await context.updateProgress(Math.round(iteration / maxIterations * 100), `Agent iteration ${iteration + 1}`);
|
|
1776
|
+
const contextMessages = this.trimMessages(messages, input.maxContextMessages ?? MAX_CONTEXT_MESSAGES);
|
|
1777
|
+
const llmTask = context.own(new ToolCallingTask);
|
|
1778
|
+
let iterationText = "";
|
|
1779
|
+
let toolCalls = [];
|
|
1780
|
+
for await (const event of llmTask.executeStream({
|
|
1781
|
+
model: input.model,
|
|
1782
|
+
prompt: input.prompt,
|
|
1783
|
+
systemPrompt: input.systemPrompt,
|
|
1784
|
+
tools: toolDefs,
|
|
1785
|
+
messages: contextMessages,
|
|
1786
|
+
maxTokens: input.maxTokens,
|
|
1787
|
+
temperature: input.temperature
|
|
1788
|
+
}, context)) {
|
|
1789
|
+
if (event.type === "text-delta") {
|
|
1790
|
+
yield { type: "text-delta", port: "text", textDelta: event.textDelta };
|
|
1791
|
+
iterationText += event.textDelta;
|
|
1792
|
+
} else if (event.type === "object-delta" && event.port === "toolCalls") {
|
|
1793
|
+
const items = event.objectDelta;
|
|
1794
|
+
for (const item of items) {
|
|
1795
|
+
const idx = toolCalls.findIndex((tc) => tc.id === item.id);
|
|
1796
|
+
if (idx >= 0)
|
|
1797
|
+
toolCalls[idx] = item;
|
|
1798
|
+
else
|
|
1799
|
+
toolCalls.push(item);
|
|
995
1800
|
}
|
|
996
|
-
} else if (
|
|
997
|
-
const
|
|
998
|
-
|
|
999
|
-
if (
|
|
1000
|
-
|
|
1801
|
+
} else if (event.type === "finish") {
|
|
1802
|
+
const data = event.data;
|
|
1803
|
+
iterationText = data?.text ?? iterationText;
|
|
1804
|
+
if (data?.toolCalls && data.toolCalls.length > 0) {
|
|
1805
|
+
toolCalls = data.toolCalls;
|
|
1001
1806
|
}
|
|
1002
1807
|
}
|
|
1003
1808
|
}
|
|
1809
|
+
finalText = iterationText;
|
|
1810
|
+
messages.push(assistantMessage(iterationText, toolCalls));
|
|
1811
|
+
if (input.stopTool) {
|
|
1812
|
+
const stopCall = toolCalls.find((tc) => tc.name === input.stopTool);
|
|
1813
|
+
if (stopCall) {
|
|
1814
|
+
structuredOutput = stopCall.input;
|
|
1815
|
+
break;
|
|
1816
|
+
}
|
|
1817
|
+
}
|
|
1818
|
+
if (!hasToolCalls(toolCalls)) {
|
|
1819
|
+
break;
|
|
1820
|
+
}
|
|
1821
|
+
const results = await executeToolCalls(toolCalls, toolSources, context, hooks, maxConcurrency);
|
|
1822
|
+
messages.push(toolMessage(results));
|
|
1004
1823
|
}
|
|
1005
|
-
|
|
1824
|
+
const output = {
|
|
1825
|
+
text: finalText,
|
|
1826
|
+
messages,
|
|
1827
|
+
iterations: messages.filter((m) => m.role === "assistant").length,
|
|
1828
|
+
toolCallCount: countAssistantToolUses(messages),
|
|
1829
|
+
...structuredOutput !== undefined ? { structuredOutput } : {}
|
|
1830
|
+
};
|
|
1831
|
+
yield { type: "finish", data: output };
|
|
1832
|
+
}
|
|
1833
|
+
resolveToolSources(input, context) {
|
|
1834
|
+
return buildToolSources(input.tools, context.registry);
|
|
1835
|
+
}
|
|
1836
|
+
resolveToolDefs(toolSources, stopTool) {
|
|
1837
|
+
const defs = toolSourceDefinitions(toolSources);
|
|
1838
|
+
if (stopTool && !defs.some((d) => d.name === stopTool)) {
|
|
1839
|
+
defs.push({
|
|
1840
|
+
name: stopTool,
|
|
1841
|
+
description: "Call this tool when you have completed the task. Pass your final structured result as the input.",
|
|
1842
|
+
inputSchema: { type: "object", additionalProperties: true }
|
|
1843
|
+
});
|
|
1844
|
+
}
|
|
1845
|
+
return defs;
|
|
1846
|
+
}
|
|
1847
|
+
trimMessages(messages, maxContextMessages) {
|
|
1848
|
+
if (!maxContextMessages || messages.length <= maxContextMessages) {
|
|
1849
|
+
return messages;
|
|
1850
|
+
}
|
|
1851
|
+
getLogger4().debug(`AgentTask: Trimming context from ${messages.length} to ${maxContextMessages} messages`);
|
|
1852
|
+
const tail = messages.slice(1);
|
|
1853
|
+
let startIdx = tail.length - (maxContextMessages - 1);
|
|
1854
|
+
if (startIdx < 0)
|
|
1855
|
+
startIdx = 0;
|
|
1856
|
+
while (startIdx > 0 && startIdx < tail.length && tail[startIdx].role === "tool") {
|
|
1857
|
+
startIdx -= 1;
|
|
1858
|
+
}
|
|
1859
|
+
return [messages[0], ...tail.slice(startIdx)];
|
|
1006
1860
|
}
|
|
1007
1861
|
}
|
|
1862
|
+
var agent = (input, config) => {
|
|
1863
|
+
return new AgentTask(config).run(input);
|
|
1864
|
+
};
|
|
1865
|
+
Workflow2.prototype.agent = CreateWorkflow2(AgentTask);
|
|
1866
|
+
|
|
1867
|
+
// src/task/BackgroundRemovalTask.ts
|
|
1868
|
+
import { CreateWorkflow as CreateWorkflow3, Workflow as Workflow3 } from "@workglow/task-graph";
|
|
1008
1869
|
|
|
1009
1870
|
// src/task/base/AiVisionTask.ts
|
|
1871
|
+
import { convertImageDataToUseableForm } from "@workglow/util/media";
|
|
1010
1872
|
class AiVisionTask extends AiTask {
|
|
1011
1873
|
static type = "AiVisionTask";
|
|
1012
1874
|
async getJobInput(input) {
|
|
@@ -1027,7 +1889,7 @@ class AiVisionTask extends AiTask {
|
|
|
1027
1889
|
}
|
|
1028
1890
|
|
|
1029
1891
|
// src/task/BackgroundRemovalTask.ts
|
|
1030
|
-
var
|
|
1892
|
+
var modelSchema3 = TypeModel("model:BackgroundRemovalTask");
|
|
1031
1893
|
var processedImageSchema = {
|
|
1032
1894
|
type: "string",
|
|
1033
1895
|
contentEncoding: "base64",
|
|
@@ -1039,7 +1901,7 @@ var BackgroundRemovalInputSchema = {
|
|
|
1039
1901
|
type: "object",
|
|
1040
1902
|
properties: {
|
|
1041
1903
|
image: TypeImageInput,
|
|
1042
|
-
model:
|
|
1904
|
+
model: modelSchema3
|
|
1043
1905
|
},
|
|
1044
1906
|
required: ["image", "model"],
|
|
1045
1907
|
additionalProperties: false
|
|
@@ -1066,24 +1928,24 @@ class BackgroundRemovalTask extends AiVisionTask {
|
|
|
1066
1928
|
}
|
|
1067
1929
|
}
|
|
1068
1930
|
var backgroundRemoval = (input, config) => {
|
|
1069
|
-
return new BackgroundRemovalTask(
|
|
1931
|
+
return new BackgroundRemovalTask(config).run(input);
|
|
1070
1932
|
};
|
|
1071
|
-
|
|
1933
|
+
Workflow3.prototype.backgroundRemoval = CreateWorkflow3(BackgroundRemovalTask);
|
|
1072
1934
|
|
|
1073
1935
|
// src/task/ChunkRetrievalTask.ts
|
|
1074
1936
|
import { TypeKnowledgeBase } from "@workglow/knowledge-base";
|
|
1075
|
-
import { CreateWorkflow as
|
|
1937
|
+
import { CreateWorkflow as CreateWorkflow5, Task as Task3, Workflow as Workflow5 } from "@workglow/task-graph";
|
|
1076
1938
|
import {
|
|
1077
1939
|
isTypedArray,
|
|
1078
1940
|
TypedArraySchema as TypedArraySchema2
|
|
1079
1941
|
} from "@workglow/util/schema";
|
|
1080
1942
|
|
|
1081
1943
|
// src/task/TextEmbeddingTask.ts
|
|
1082
|
-
import { CreateWorkflow as
|
|
1944
|
+
import { CreateWorkflow as CreateWorkflow4, Workflow as Workflow4 } from "@workglow/task-graph";
|
|
1083
1945
|
import {
|
|
1084
1946
|
TypedArraySchema
|
|
1085
1947
|
} from "@workglow/util/schema";
|
|
1086
|
-
var
|
|
1948
|
+
var modelSchema4 = TypeModel("model:TextEmbeddingTask");
|
|
1087
1949
|
var TextEmbeddingInputSchema = {
|
|
1088
1950
|
type: "object",
|
|
1089
1951
|
properties: {
|
|
@@ -1092,7 +1954,7 @@ var TextEmbeddingInputSchema = {
|
|
|
1092
1954
|
title: "Text",
|
|
1093
1955
|
description: "The text to embed"
|
|
1094
1956
|
}),
|
|
1095
|
-
model:
|
|
1957
|
+
model: modelSchema4
|
|
1096
1958
|
},
|
|
1097
1959
|
required: ["text", "model"],
|
|
1098
1960
|
additionalProperties: false
|
|
@@ -1122,9 +1984,9 @@ class TextEmbeddingTask extends AiTask {
|
|
|
1122
1984
|
}
|
|
1123
1985
|
}
|
|
1124
1986
|
var textEmbedding = async (input, config) => {
|
|
1125
|
-
return new TextEmbeddingTask(
|
|
1987
|
+
return new TextEmbeddingTask(config).run(input);
|
|
1126
1988
|
};
|
|
1127
|
-
|
|
1989
|
+
Workflow4.prototype.textEmbedding = CreateWorkflow4(TextEmbeddingTask);
|
|
1128
1990
|
|
|
1129
1991
|
// src/task/ChunkRetrievalTask.ts
|
|
1130
1992
|
var inputSchema = {
|
|
@@ -1249,7 +2111,7 @@ var outputSchema = {
|
|
|
1249
2111
|
additionalProperties: false
|
|
1250
2112
|
};
|
|
1251
2113
|
|
|
1252
|
-
class ChunkRetrievalTask extends
|
|
2114
|
+
class ChunkRetrievalTask extends Task3 {
|
|
1253
2115
|
static type = "ChunkRetrievalTask";
|
|
1254
2116
|
static category = "RAG";
|
|
1255
2117
|
static title = "Chunk Retrieval";
|
|
@@ -1277,8 +2139,8 @@ class ChunkRetrievalTask extends Task2 {
|
|
|
1277
2139
|
if (!model) {
|
|
1278
2140
|
throw new Error("Model is required when query is a string. Please provide a model with format 'model:TextEmbeddingTask'.");
|
|
1279
2141
|
}
|
|
1280
|
-
const embeddingTask = context.own(new TextEmbeddingTask
|
|
1281
|
-
const embeddingResult = await embeddingTask.run();
|
|
2142
|
+
const embeddingTask = context.own(new TextEmbeddingTask);
|
|
2143
|
+
const embeddingResult = await embeddingTask.run({ text: query, model });
|
|
1282
2144
|
queryVectors = Array.isArray(embeddingResult.vector) ? embeddingResult.vector : [embeddingResult.vector];
|
|
1283
2145
|
} else if (isTypedArray(query) || Array.isArray(query) && query.every(isTypedArray)) {
|
|
1284
2146
|
queryVectors = Array.isArray(query) ? query : [query];
|
|
@@ -1314,13 +2176,13 @@ class ChunkRetrievalTask extends Task2 {
|
|
|
1314
2176
|
}
|
|
1315
2177
|
}
|
|
1316
2178
|
var chunkRetrieval = (input, config) => {
|
|
1317
|
-
return new ChunkRetrievalTask(
|
|
2179
|
+
return new ChunkRetrievalTask(config).run(input);
|
|
1318
2180
|
};
|
|
1319
|
-
|
|
2181
|
+
Workflow5.prototype.chunkRetrieval = CreateWorkflow5(ChunkRetrievalTask);
|
|
1320
2182
|
|
|
1321
2183
|
// src/task/ChunkToVectorTask.ts
|
|
1322
2184
|
import { ChunkRecordSchema } from "@workglow/knowledge-base";
|
|
1323
|
-
import { CreateWorkflow as
|
|
2185
|
+
import { CreateWorkflow as CreateWorkflow6, Task as Task4, Workflow as Workflow6 } from "@workglow/task-graph";
|
|
1324
2186
|
import {
|
|
1325
2187
|
TypedArraySchema as TypedArraySchema3
|
|
1326
2188
|
} from "@workglow/util/schema";
|
|
@@ -1395,7 +2257,7 @@ var outputSchema2 = {
|
|
|
1395
2257
|
additionalProperties: false
|
|
1396
2258
|
};
|
|
1397
2259
|
|
|
1398
|
-
class ChunkToVectorTask extends
|
|
2260
|
+
class ChunkToVectorTask extends Task4 {
|
|
1399
2261
|
static type = "ChunkToVectorTask";
|
|
1400
2262
|
static category = "Document";
|
|
1401
2263
|
static title = "Chunk to Vector";
|
|
@@ -1444,13 +2306,13 @@ class ChunkToVectorTask extends Task3 {
|
|
|
1444
2306
|
}
|
|
1445
2307
|
}
|
|
1446
2308
|
var chunkToVector = (input, config) => {
|
|
1447
|
-
return new ChunkToVectorTask(
|
|
2309
|
+
return new ChunkToVectorTask(config).run(input);
|
|
1448
2310
|
};
|
|
1449
|
-
|
|
2311
|
+
Workflow6.prototype.chunkToVector = CreateWorkflow6(ChunkToVectorTask);
|
|
1450
2312
|
|
|
1451
2313
|
// src/task/ChunkVectorHybridSearchTask.ts
|
|
1452
2314
|
import { TypeKnowledgeBase as TypeKnowledgeBase2 } from "@workglow/knowledge-base";
|
|
1453
|
-
import { CreateWorkflow as
|
|
2315
|
+
import { CreateWorkflow as CreateWorkflow7, Task as Task5, Workflow as Workflow7 } from "@workglow/task-graph";
|
|
1454
2316
|
import {
|
|
1455
2317
|
TypedArraySchema as TypedArraySchema4
|
|
1456
2318
|
} from "@workglow/util/schema";
|
|
@@ -1563,7 +2425,7 @@ var outputSchema3 = {
|
|
|
1563
2425
|
additionalProperties: false
|
|
1564
2426
|
};
|
|
1565
2427
|
|
|
1566
|
-
class ChunkVectorHybridSearchTask extends
|
|
2428
|
+
class ChunkVectorHybridSearchTask extends Task5 {
|
|
1567
2429
|
static type = "ChunkVectorHybridSearchTask";
|
|
1568
2430
|
static category = "RAG";
|
|
1569
2431
|
static title = "Hybrid Search";
|
|
@@ -1614,13 +2476,13 @@ class ChunkVectorHybridSearchTask extends Task4 {
|
|
|
1614
2476
|
}
|
|
1615
2477
|
}
|
|
1616
2478
|
var hybridSearch = async (input, config) => {
|
|
1617
|
-
return new ChunkVectorHybridSearchTask(
|
|
2479
|
+
return new ChunkVectorHybridSearchTask(config).run(input);
|
|
1618
2480
|
};
|
|
1619
|
-
|
|
2481
|
+
Workflow7.prototype.hybridSearch = CreateWorkflow7(ChunkVectorHybridSearchTask);
|
|
1620
2482
|
|
|
1621
2483
|
// src/task/ChunkVectorSearchTask.ts
|
|
1622
2484
|
import { TypeKnowledgeBase as TypeKnowledgeBase3 } from "@workglow/knowledge-base";
|
|
1623
|
-
import { CreateWorkflow as
|
|
2485
|
+
import { CreateWorkflow as CreateWorkflow8, Task as Task6, Workflow as Workflow8 } from "@workglow/task-graph";
|
|
1624
2486
|
import {
|
|
1625
2487
|
TypedArraySchema as TypedArraySchema5
|
|
1626
2488
|
} from "@workglow/util/schema";
|
|
@@ -1703,7 +2565,7 @@ var outputSchema4 = {
|
|
|
1703
2565
|
additionalProperties: false
|
|
1704
2566
|
};
|
|
1705
2567
|
|
|
1706
|
-
class ChunkVectorSearchTask extends
|
|
2568
|
+
class ChunkVectorSearchTask extends Task6 {
|
|
1707
2569
|
static type = "ChunkVectorSearchTask";
|
|
1708
2570
|
static category = "Vector Store";
|
|
1709
2571
|
static title = "Vector Store Search";
|
|
@@ -1733,13 +2595,13 @@ class ChunkVectorSearchTask extends Task5 {
|
|
|
1733
2595
|
}
|
|
1734
2596
|
}
|
|
1735
2597
|
var vectorStoreSearch = (input, config) => {
|
|
1736
|
-
return new ChunkVectorSearchTask(
|
|
2598
|
+
return new ChunkVectorSearchTask(config).run(input);
|
|
1737
2599
|
};
|
|
1738
|
-
|
|
2600
|
+
Workflow8.prototype.vectorStoreSearch = CreateWorkflow8(ChunkVectorSearchTask);
|
|
1739
2601
|
|
|
1740
2602
|
// src/task/ChunkVectorUpsertTask.ts
|
|
1741
2603
|
import { TypeKnowledgeBase as TypeKnowledgeBase4 } from "@workglow/knowledge-base";
|
|
1742
|
-
import { CreateWorkflow as
|
|
2604
|
+
import { CreateWorkflow as CreateWorkflow9, Task as Task7, Workflow as Workflow9 } from "@workglow/task-graph";
|
|
1743
2605
|
import {
|
|
1744
2606
|
TypedArraySchema as TypedArraySchema6
|
|
1745
2607
|
} from "@workglow/util/schema";
|
|
@@ -1793,7 +2655,7 @@ var outputSchema5 = {
|
|
|
1793
2655
|
additionalProperties: false
|
|
1794
2656
|
};
|
|
1795
2657
|
|
|
1796
|
-
class ChunkVectorUpsertTask extends
|
|
2658
|
+
class ChunkVectorUpsertTask extends Task7 {
|
|
1797
2659
|
static type = "ChunkVectorUpsertTask";
|
|
1798
2660
|
static category = "Vector Store";
|
|
1799
2661
|
static title = "Add to Vector Store";
|
|
@@ -1851,21 +2713,17 @@ class ChunkVectorUpsertTask extends Task6 {
|
|
|
1851
2713
|
}
|
|
1852
2714
|
}
|
|
1853
2715
|
var chunkVectorUpsert = (input, config) => {
|
|
1854
|
-
return new ChunkVectorUpsertTask(
|
|
2716
|
+
return new ChunkVectorUpsertTask(config).run(input);
|
|
1855
2717
|
};
|
|
1856
|
-
|
|
2718
|
+
Workflow9.prototype.chunkVectorUpsert = CreateWorkflow9(ChunkVectorUpsertTask);
|
|
1857
2719
|
|
|
1858
2720
|
// src/task/ContextBuilderTask.ts
|
|
1859
2721
|
import { estimateTokens } from "@workglow/knowledge-base";
|
|
1860
|
-
import {
|
|
1861
|
-
CreateWorkflow as CreateWorkflow9,
|
|
1862
|
-
Task as Task7,
|
|
1863
|
-
Workflow as Workflow9
|
|
1864
|
-
} from "@workglow/task-graph";
|
|
2722
|
+
import { CreateWorkflow as CreateWorkflow11, Task as Task8, Workflow as Workflow11 } from "@workglow/task-graph";
|
|
1865
2723
|
|
|
1866
2724
|
// src/task/CountTokensTask.ts
|
|
1867
|
-
import { CreateWorkflow as
|
|
1868
|
-
var
|
|
2725
|
+
import { CreateWorkflow as CreateWorkflow10, Workflow as Workflow10 } from "@workglow/task-graph";
|
|
2726
|
+
var modelSchema5 = TypeModel("model");
|
|
1869
2727
|
var CountTokensInputSchema = {
|
|
1870
2728
|
type: "object",
|
|
1871
2729
|
properties: {
|
|
@@ -1874,7 +2732,7 @@ var CountTokensInputSchema = {
|
|
|
1874
2732
|
title: "Text",
|
|
1875
2733
|
description: "The text to count tokens for"
|
|
1876
2734
|
},
|
|
1877
|
-
model:
|
|
2735
|
+
model: modelSchema5
|
|
1878
2736
|
},
|
|
1879
2737
|
required: ["text", "model"],
|
|
1880
2738
|
additionalProperties: false
|
|
@@ -1906,9 +2764,9 @@ class CountTokensTask extends AiTask {
|
|
|
1906
2764
|
}
|
|
1907
2765
|
}
|
|
1908
2766
|
var countTokens = async (input, config) => {
|
|
1909
|
-
return new CountTokensTask(
|
|
2767
|
+
return new CountTokensTask(config).run(input);
|
|
1910
2768
|
};
|
|
1911
|
-
|
|
2769
|
+
Workflow10.prototype.countTokens = CreateWorkflow10(CountTokensTask);
|
|
1912
2770
|
|
|
1913
2771
|
// src/task/ContextBuilderTask.ts
|
|
1914
2772
|
var ContextFormat = {
|
|
@@ -1918,7 +2776,7 @@ var ContextFormat = {
|
|
|
1918
2776
|
MARKDOWN: "markdown",
|
|
1919
2777
|
JSON: "json"
|
|
1920
2778
|
};
|
|
1921
|
-
var
|
|
2779
|
+
var modelSchema6 = TypeModel("model", {
|
|
1922
2780
|
title: "Model",
|
|
1923
2781
|
description: "Model to use for token counting (optional, falls back to estimation)"
|
|
1924
2782
|
});
|
|
@@ -1982,7 +2840,7 @@ var inputSchema6 = {
|
|
|
1982
2840
|
|
|
1983
2841
|
`
|
|
1984
2842
|
},
|
|
1985
|
-
model:
|
|
2843
|
+
model: modelSchema6
|
|
1986
2844
|
},
|
|
1987
2845
|
required: ["chunks"],
|
|
1988
2846
|
additionalProperties: false
|
|
@@ -2015,7 +2873,7 @@ var outputSchema6 = {
|
|
|
2015
2873
|
additionalProperties: false
|
|
2016
2874
|
};
|
|
2017
2875
|
|
|
2018
|
-
class ContextBuilderTask extends
|
|
2876
|
+
class ContextBuilderTask extends Task8 {
|
|
2019
2877
|
static type = "ContextBuilderTask";
|
|
2020
2878
|
static category = "RAG";
|
|
2021
2879
|
static title = "Context Builder";
|
|
@@ -2042,7 +2900,7 @@ class ContextBuilderTask extends Task7 {
|
|
|
2042
2900
|
} = input;
|
|
2043
2901
|
let countFn = async (text) => estimateTokens(text);
|
|
2044
2902
|
if (input.model) {
|
|
2045
|
-
const countTask = context.own(new CountTokensTask({ model: input.model }));
|
|
2903
|
+
const countTask = context.own(new CountTokensTask({ defaults: { model: input.model } }));
|
|
2046
2904
|
countFn = async (text) => {
|
|
2047
2905
|
try {
|
|
2048
2906
|
const result = await countTask.run({ text });
|
|
@@ -2206,20 +3064,17 @@ class ContextBuilderTask extends Task7 {
|
|
|
2206
3064
|
}
|
|
2207
3065
|
}
|
|
2208
3066
|
var contextBuilder = (input, config) => {
|
|
2209
|
-
return new ContextBuilderTask(
|
|
3067
|
+
return new ContextBuilderTask(config).run(input);
|
|
2210
3068
|
};
|
|
2211
|
-
|
|
3069
|
+
Workflow11.prototype.contextBuilder = CreateWorkflow11(ContextBuilderTask);
|
|
2212
3070
|
|
|
2213
3071
|
// src/task/DocumentEnricherTask.ts
|
|
2214
|
-
import {
|
|
2215
|
-
|
|
2216
|
-
hasChildren
|
|
2217
|
-
} from "@workglow/knowledge-base";
|
|
2218
|
-
import { CreateWorkflow as CreateWorkflow12, Task as Task8, Workflow as Workflow12 } from "@workglow/task-graph";
|
|
3072
|
+
import { getChildren, hasChildren } from "@workglow/knowledge-base";
|
|
3073
|
+
import { CreateWorkflow as CreateWorkflow14, Task as Task9, Workflow as Workflow14 } from "@workglow/task-graph";
|
|
2219
3074
|
|
|
2220
3075
|
// src/task/TextNamedEntityRecognitionTask.ts
|
|
2221
|
-
import { CreateWorkflow as
|
|
2222
|
-
var
|
|
3076
|
+
import { CreateWorkflow as CreateWorkflow12, Workflow as Workflow12 } from "@workglow/task-graph";
|
|
3077
|
+
var modelSchema7 = TypeModel("model:TextNamedEntityRecognitionTask");
|
|
2223
3078
|
var TextNamedEntityRecognitionInputSchema = {
|
|
2224
3079
|
type: "object",
|
|
2225
3080
|
properties: {
|
|
@@ -2238,7 +3093,7 @@ var TextNamedEntityRecognitionInputSchema = {
|
|
|
2238
3093
|
"x-ui-group": "Configuration",
|
|
2239
3094
|
"x-ui-group-open": false
|
|
2240
3095
|
},
|
|
2241
|
-
model:
|
|
3096
|
+
model: modelSchema7
|
|
2242
3097
|
},
|
|
2243
3098
|
required: ["text", "model"],
|
|
2244
3099
|
additionalProperties: false
|
|
@@ -2291,53 +3146,13 @@ class TextNamedEntityRecognitionTask extends AiTask {
|
|
|
2291
3146
|
}
|
|
2292
3147
|
}
|
|
2293
3148
|
var textNamedEntityRecognition = (input, config) => {
|
|
2294
|
-
return new TextNamedEntityRecognitionTask(
|
|
3149
|
+
return new TextNamedEntityRecognitionTask(config).run(input);
|
|
2295
3150
|
};
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
// src/task/TextSummaryTask.ts
|
|
2299
|
-
import { CreateWorkflow as CreateWorkflow11, Workflow as Workflow11 } from "@workglow/task-graph";
|
|
2300
|
-
|
|
2301
|
-
// src/task/base/StreamingAiTask.ts
|
|
2302
|
-
import {
|
|
2303
|
-
getStreamingPorts,
|
|
2304
|
-
TaskConfigurationError as TaskConfigurationError3
|
|
2305
|
-
} from "@workglow/task-graph";
|
|
2306
|
-
class StreamingAiTask extends AiTask {
|
|
2307
|
-
static type = "StreamingAiTask";
|
|
2308
|
-
async* executeStream(input, context) {
|
|
2309
|
-
const model = input.model;
|
|
2310
|
-
if (!model || typeof model !== "object") {
|
|
2311
|
-
throw new TaskConfigurationError3("StreamingAiTask: Model was not resolved to ModelConfig - this indicates a bug in the resolution system");
|
|
2312
|
-
}
|
|
2313
|
-
const jobInput = await this.getJobInput(input);
|
|
2314
|
-
const strategy = getAiProviderRegistry().getStrategy(model);
|
|
2315
|
-
const outSchema = this.outputSchema();
|
|
2316
|
-
const ports = getStreamingPorts(outSchema);
|
|
2317
|
-
let defaultPort = "text";
|
|
2318
|
-
if (ports.length > 0) {
|
|
2319
|
-
defaultPort = ports[0].port;
|
|
2320
|
-
} else {
|
|
2321
|
-
if (typeof outSchema === "object" && outSchema.properties) {
|
|
2322
|
-
const firstProp = Object.keys(outSchema.properties)[0];
|
|
2323
|
-
if (firstProp)
|
|
2324
|
-
defaultPort = firstProp;
|
|
2325
|
-
}
|
|
2326
|
-
}
|
|
2327
|
-
for await (const event of strategy.executeStream(jobInput, context, this.runConfig.runnerId)) {
|
|
2328
|
-
if (event.type === "text-delta") {
|
|
2329
|
-
yield { ...event, port: event.port ?? defaultPort };
|
|
2330
|
-
} else if (event.type === "object-delta") {
|
|
2331
|
-
yield { ...event, port: event.port ?? defaultPort };
|
|
2332
|
-
} else {
|
|
2333
|
-
yield event;
|
|
2334
|
-
}
|
|
2335
|
-
}
|
|
2336
|
-
}
|
|
2337
|
-
}
|
|
3151
|
+
Workflow12.prototype.textNamedEntityRecognition = CreateWorkflow12(TextNamedEntityRecognitionTask);
|
|
2338
3152
|
|
|
2339
3153
|
// src/task/TextSummaryTask.ts
|
|
2340
|
-
|
|
3154
|
+
import { CreateWorkflow as CreateWorkflow13, Workflow as Workflow13 } from "@workglow/task-graph";
|
|
3155
|
+
var modelSchema8 = TypeModel("model:TextSummaryTask");
|
|
2341
3156
|
var TextSummaryInputSchema = {
|
|
2342
3157
|
type: "object",
|
|
2343
3158
|
properties: {
|
|
@@ -2346,7 +3161,7 @@ var TextSummaryInputSchema = {
|
|
|
2346
3161
|
title: "Text",
|
|
2347
3162
|
description: "The text to summarize"
|
|
2348
3163
|
},
|
|
2349
|
-
model:
|
|
3164
|
+
model: modelSchema8
|
|
2350
3165
|
},
|
|
2351
3166
|
required: ["text", "model"],
|
|
2352
3167
|
additionalProperties: false
|
|
@@ -2378,9 +3193,9 @@ class TextSummaryTask extends StreamingAiTask {
|
|
|
2378
3193
|
}
|
|
2379
3194
|
}
|
|
2380
3195
|
var textSummary = async (input, config) => {
|
|
2381
|
-
return new TextSummaryTask(
|
|
3196
|
+
return new TextSummaryTask(config).run(input);
|
|
2382
3197
|
};
|
|
2383
|
-
|
|
3198
|
+
Workflow13.prototype.textSummary = CreateWorkflow13(TextSummaryTask);
|
|
2384
3199
|
|
|
2385
3200
|
// src/task/DocumentEnricherTask.ts
|
|
2386
3201
|
var inputSchema7 = {
|
|
@@ -2452,7 +3267,7 @@ var outputSchema7 = {
|
|
|
2452
3267
|
additionalProperties: false
|
|
2453
3268
|
};
|
|
2454
3269
|
|
|
2455
|
-
class DocumentEnricherTask extends
|
|
3270
|
+
class DocumentEnricherTask extends Task9 {
|
|
2456
3271
|
static type = "DocumentEnricherTask";
|
|
2457
3272
|
static category = "Document";
|
|
2458
3273
|
static title = "Document Enricher";
|
|
@@ -2480,7 +3295,7 @@ class DocumentEnricherTask extends Task8 {
|
|
|
2480
3295
|
let summaryCount = 0;
|
|
2481
3296
|
let entityCount = 0;
|
|
2482
3297
|
const extract = extractEntities && nerModel ? async (text) => {
|
|
2483
|
-
const result = await context.own(new TextNamedEntityRecognitionTask({ text, model: nerModel })
|
|
3298
|
+
const result = await context.own(new TextNamedEntityRecognitionTask).run({ text, model: nerModel });
|
|
2484
3299
|
return result.entities.map((e) => ({
|
|
2485
3300
|
type: e.entity,
|
|
2486
3301
|
text: e.word,
|
|
@@ -2609,17 +3424,17 @@ class DocumentEnricherTask extends Task8 {
|
|
|
2609
3424
|
}
|
|
2610
3425
|
}
|
|
2611
3426
|
var documentEnricher = (input, config) => {
|
|
2612
|
-
return new DocumentEnricherTask(
|
|
3427
|
+
return new DocumentEnricherTask(config).run(input);
|
|
2613
3428
|
};
|
|
2614
|
-
|
|
3429
|
+
Workflow14.prototype.documentEnricher = CreateWorkflow14(DocumentEnricherTask);
|
|
2615
3430
|
|
|
2616
3431
|
// src/task/DownloadModelTask.ts
|
|
2617
|
-
import { CreateWorkflow as
|
|
2618
|
-
var
|
|
3432
|
+
import { CreateWorkflow as CreateWorkflow15, Workflow as Workflow15 } from "@workglow/task-graph";
|
|
3433
|
+
var modelSchema9 = TypeModel("model");
|
|
2619
3434
|
var DownloadModelInputSchema = {
|
|
2620
3435
|
type: "object",
|
|
2621
3436
|
properties: {
|
|
2622
|
-
model:
|
|
3437
|
+
model: modelSchema9
|
|
2623
3438
|
},
|
|
2624
3439
|
required: ["model"],
|
|
2625
3440
|
additionalProperties: false
|
|
@@ -2627,7 +3442,7 @@ var DownloadModelInputSchema = {
|
|
|
2627
3442
|
var DownloadModelOutputSchema = {
|
|
2628
3443
|
type: "object",
|
|
2629
3444
|
properties: {
|
|
2630
|
-
model:
|
|
3445
|
+
model: modelSchema9
|
|
2631
3446
|
},
|
|
2632
3447
|
required: ["model"],
|
|
2633
3448
|
additionalProperties: false
|
|
@@ -2646,8 +3461,8 @@ class DownloadModelTask extends AiTask {
|
|
|
2646
3461
|
}
|
|
2647
3462
|
static cacheable = false;
|
|
2648
3463
|
files = [];
|
|
2649
|
-
constructor(
|
|
2650
|
-
super(
|
|
3464
|
+
constructor(config = {}) {
|
|
3465
|
+
super(config);
|
|
2651
3466
|
this.on("progress", this.processProgress.bind(this));
|
|
2652
3467
|
this.on("start", () => {
|
|
2653
3468
|
this.files = [];
|
|
@@ -2679,13 +3494,13 @@ class DownloadModelTask extends AiTask {
|
|
|
2679
3494
|
}
|
|
2680
3495
|
}
|
|
2681
3496
|
var downloadModel = (input, config) => {
|
|
2682
|
-
return new DownloadModelTask(
|
|
3497
|
+
return new DownloadModelTask(config).run(input);
|
|
2683
3498
|
};
|
|
2684
|
-
|
|
3499
|
+
Workflow15.prototype.downloadModel = CreateWorkflow15(DownloadModelTask);
|
|
2685
3500
|
|
|
2686
3501
|
// src/task/FaceDetectorTask.ts
|
|
2687
|
-
import { CreateWorkflow as
|
|
2688
|
-
var
|
|
3502
|
+
import { CreateWorkflow as CreateWorkflow16, Workflow as Workflow16 } from "@workglow/task-graph";
|
|
3503
|
+
var modelSchema10 = TypeModel("model:FaceDetectorTask");
|
|
2689
3504
|
var TypeBoundingBox2 = {
|
|
2690
3505
|
type: "object",
|
|
2691
3506
|
properties: {
|
|
@@ -2758,7 +3573,7 @@ var FaceDetectorInputSchema = {
|
|
|
2758
3573
|
type: "object",
|
|
2759
3574
|
properties: {
|
|
2760
3575
|
image: TypeImageInput,
|
|
2761
|
-
model:
|
|
3576
|
+
model: modelSchema10,
|
|
2762
3577
|
minDetectionConfidence: {
|
|
2763
3578
|
type: "number",
|
|
2764
3579
|
minimum: 0,
|
|
@@ -2810,13 +3625,13 @@ class FaceDetectorTask extends AiVisionTask {
|
|
|
2810
3625
|
}
|
|
2811
3626
|
}
|
|
2812
3627
|
var faceDetector = (input, config) => {
|
|
2813
|
-
return new FaceDetectorTask(
|
|
3628
|
+
return new FaceDetectorTask(config).run(input);
|
|
2814
3629
|
};
|
|
2815
|
-
|
|
3630
|
+
Workflow16.prototype.faceDetector = CreateWorkflow16(FaceDetectorTask);
|
|
2816
3631
|
|
|
2817
3632
|
// src/task/FaceLandmarkerTask.ts
|
|
2818
|
-
import { CreateWorkflow as
|
|
2819
|
-
var
|
|
3633
|
+
import { CreateWorkflow as CreateWorkflow17, Workflow as Workflow17 } from "@workglow/task-graph";
|
|
3634
|
+
var modelSchema11 = TypeModel("model:FaceLandmarkerTask");
|
|
2820
3635
|
var TypeLandmark = {
|
|
2821
3636
|
type: "object",
|
|
2822
3637
|
properties: {
|
|
@@ -2888,7 +3703,7 @@ var FaceLandmarkerInputSchema = {
|
|
|
2888
3703
|
type: "object",
|
|
2889
3704
|
properties: {
|
|
2890
3705
|
image: TypeImageInput,
|
|
2891
|
-
model:
|
|
3706
|
+
model: modelSchema11,
|
|
2892
3707
|
numFaces: {
|
|
2893
3708
|
type: "number",
|
|
2894
3709
|
minimum: 1,
|
|
@@ -2972,13 +3787,13 @@ class FaceLandmarkerTask extends AiVisionTask {
|
|
|
2972
3787
|
}
|
|
2973
3788
|
}
|
|
2974
3789
|
var faceLandmarker = (input, config) => {
|
|
2975
|
-
return new FaceLandmarkerTask(
|
|
3790
|
+
return new FaceLandmarkerTask(config).run(input);
|
|
2976
3791
|
};
|
|
2977
|
-
|
|
3792
|
+
Workflow17.prototype.faceLandmarker = CreateWorkflow17(FaceLandmarkerTask);
|
|
2978
3793
|
|
|
2979
3794
|
// src/task/GestureRecognizerTask.ts
|
|
2980
|
-
import { CreateWorkflow as
|
|
2981
|
-
var
|
|
3795
|
+
import { CreateWorkflow as CreateWorkflow18, Workflow as Workflow18 } from "@workglow/task-graph";
|
|
3796
|
+
var modelSchema12 = TypeModel("model:GestureRecognizerTask");
|
|
2982
3797
|
var TypeLandmark2 = {
|
|
2983
3798
|
type: "object",
|
|
2984
3799
|
properties: {
|
|
@@ -3070,7 +3885,7 @@ var GestureRecognizerInputSchema = {
|
|
|
3070
3885
|
type: "object",
|
|
3071
3886
|
properties: {
|
|
3072
3887
|
image: TypeImageInput,
|
|
3073
|
-
model:
|
|
3888
|
+
model: modelSchema12,
|
|
3074
3889
|
numHands: {
|
|
3075
3890
|
type: "number",
|
|
3076
3891
|
minimum: 1,
|
|
@@ -3140,13 +3955,13 @@ class GestureRecognizerTask extends AiVisionTask {
|
|
|
3140
3955
|
}
|
|
3141
3956
|
}
|
|
3142
3957
|
var gestureRecognizer = (input, config) => {
|
|
3143
|
-
return new GestureRecognizerTask(
|
|
3958
|
+
return new GestureRecognizerTask(config).run(input);
|
|
3144
3959
|
};
|
|
3145
|
-
|
|
3960
|
+
Workflow18.prototype.gestureRecognizer = CreateWorkflow18(GestureRecognizerTask);
|
|
3146
3961
|
|
|
3147
3962
|
// src/task/HandLandmarkerTask.ts
|
|
3148
|
-
import { CreateWorkflow as
|
|
3149
|
-
var
|
|
3963
|
+
import { CreateWorkflow as CreateWorkflow19, Workflow as Workflow19 } from "@workglow/task-graph";
|
|
3964
|
+
var modelSchema13 = TypeModel("model:HandLandmarkerTask");
|
|
3150
3965
|
var TypeLandmark3 = {
|
|
3151
3966
|
type: "object",
|
|
3152
3967
|
properties: {
|
|
@@ -3215,7 +4030,7 @@ var HandLandmarkerInputSchema = {
|
|
|
3215
4030
|
type: "object",
|
|
3216
4031
|
properties: {
|
|
3217
4032
|
image: TypeImageInput,
|
|
3218
|
-
model:
|
|
4033
|
+
model: modelSchema13,
|
|
3219
4034
|
numHands: {
|
|
3220
4035
|
type: "number",
|
|
3221
4036
|
minimum: 1,
|
|
@@ -3285,9 +4100,9 @@ class HandLandmarkerTask extends AiVisionTask {
|
|
|
3285
4100
|
}
|
|
3286
4101
|
}
|
|
3287
4102
|
var handLandmarker = (input, config) => {
|
|
3288
|
-
return new HandLandmarkerTask(
|
|
4103
|
+
return new HandLandmarkerTask(config).run(input);
|
|
3289
4104
|
};
|
|
3290
|
-
|
|
4105
|
+
Workflow19.prototype.handLandmarker = CreateWorkflow19(HandLandmarkerTask);
|
|
3291
4106
|
|
|
3292
4107
|
// src/task/HierarchicalChunkerTask.ts
|
|
3293
4108
|
import {
|
|
@@ -3296,9 +4111,9 @@ import {
|
|
|
3296
4111
|
getChildren as getChildren2,
|
|
3297
4112
|
hasChildren as hasChildren2
|
|
3298
4113
|
} from "@workglow/knowledge-base";
|
|
3299
|
-
import { CreateWorkflow as
|
|
4114
|
+
import { CreateWorkflow as CreateWorkflow20, Task as Task10, Workflow as Workflow20 } from "@workglow/task-graph";
|
|
3300
4115
|
import { uuid4 } from "@workglow/util";
|
|
3301
|
-
var
|
|
4116
|
+
var modelSchema14 = TypeModel("model", {
|
|
3302
4117
|
title: "Model",
|
|
3303
4118
|
description: "Model to use for token counting"
|
|
3304
4119
|
});
|
|
@@ -3342,7 +4157,7 @@ var inputSchema8 = {
|
|
|
3342
4157
|
description: "Strategy for chunking",
|
|
3343
4158
|
default: "hierarchical"
|
|
3344
4159
|
},
|
|
3345
|
-
model:
|
|
4160
|
+
model: modelSchema14
|
|
3346
4161
|
},
|
|
3347
4162
|
required: ["doc_id", "documentTree"],
|
|
3348
4163
|
additionalProperties: false
|
|
@@ -3377,7 +4192,7 @@ var outputSchema8 = {
|
|
|
3377
4192
|
additionalProperties: false
|
|
3378
4193
|
};
|
|
3379
4194
|
|
|
3380
|
-
class HierarchicalChunkerTask extends
|
|
4195
|
+
class HierarchicalChunkerTask extends Task10 {
|
|
3381
4196
|
static type = "HierarchicalChunkerTask";
|
|
3382
4197
|
static category = "Document";
|
|
3383
4198
|
static title = "Hierarchical Chunker";
|
|
@@ -3412,7 +4227,7 @@ class HierarchicalChunkerTask extends Task9 {
|
|
|
3412
4227
|
};
|
|
3413
4228
|
let countFn = async (text) => estimateTokens2(text);
|
|
3414
4229
|
if (input.model) {
|
|
3415
|
-
const countTask = context.own(new CountTokensTask({ model: input.model }));
|
|
4230
|
+
const countTask = context.own(new CountTokensTask({ defaults: { model: input.model } }));
|
|
3416
4231
|
countFn = async (text) => {
|
|
3417
4232
|
try {
|
|
3418
4233
|
const result = await countTask.run({ text });
|
|
@@ -3519,16 +4334,13 @@ class HierarchicalChunkerTask extends Task9 {
|
|
|
3519
4334
|
}
|
|
3520
4335
|
}
|
|
3521
4336
|
var hierarchicalChunker = (input, config) => {
|
|
3522
|
-
return new HierarchicalChunkerTask(
|
|
4337
|
+
return new HierarchicalChunkerTask(config).run(input);
|
|
3523
4338
|
};
|
|
3524
|
-
|
|
4339
|
+
Workflow20.prototype.hierarchicalChunker = CreateWorkflow20(HierarchicalChunkerTask);
|
|
3525
4340
|
|
|
3526
4341
|
// src/task/HierarchyJoinTask.ts
|
|
3527
|
-
import {
|
|
3528
|
-
|
|
3529
|
-
TypeKnowledgeBase as TypeKnowledgeBase5
|
|
3530
|
-
} from "@workglow/knowledge-base";
|
|
3531
|
-
import { CreateWorkflow as CreateWorkflow19, Task as Task10, Workflow as Workflow19 } from "@workglow/task-graph";
|
|
4342
|
+
import { ChunkRecordArraySchema, TypeKnowledgeBase as TypeKnowledgeBase5 } from "@workglow/knowledge-base";
|
|
4343
|
+
import { CreateWorkflow as CreateWorkflow21, Task as Task11, Workflow as Workflow21 } from "@workglow/task-graph";
|
|
3532
4344
|
var inputSchema9 = {
|
|
3533
4345
|
type: "object",
|
|
3534
4346
|
properties: {
|
|
@@ -3603,7 +4415,7 @@ var outputSchema9 = {
|
|
|
3603
4415
|
additionalProperties: false
|
|
3604
4416
|
};
|
|
3605
4417
|
|
|
3606
|
-
class HierarchyJoinTask extends
|
|
4418
|
+
class HierarchyJoinTask extends Task11 {
|
|
3607
4419
|
static type = "HierarchyJoinTask";
|
|
3608
4420
|
static category = "RAG";
|
|
3609
4421
|
static title = "Hierarchy Join";
|
|
@@ -3695,18 +4507,18 @@ class HierarchyJoinTask extends Task10 {
|
|
|
3695
4507
|
}
|
|
3696
4508
|
}
|
|
3697
4509
|
var hierarchyJoin = (input, config) => {
|
|
3698
|
-
return new HierarchyJoinTask(
|
|
4510
|
+
return new HierarchyJoinTask(config).run(input);
|
|
3699
4511
|
};
|
|
3700
|
-
|
|
4512
|
+
Workflow21.prototype.hierarchyJoin = CreateWorkflow21(HierarchyJoinTask);
|
|
3701
4513
|
|
|
3702
4514
|
// src/task/ImageClassificationTask.ts
|
|
3703
|
-
import { CreateWorkflow as
|
|
3704
|
-
var
|
|
4515
|
+
import { CreateWorkflow as CreateWorkflow22, Workflow as Workflow22 } from "@workglow/task-graph";
|
|
4516
|
+
var modelSchema15 = TypeModel("model:ImageClassificationTask");
|
|
3705
4517
|
var ImageClassificationInputSchema = {
|
|
3706
4518
|
type: "object",
|
|
3707
4519
|
properties: {
|
|
3708
4520
|
image: TypeImageInput,
|
|
3709
|
-
model:
|
|
4521
|
+
model: modelSchema15,
|
|
3710
4522
|
categories: {
|
|
3711
4523
|
type: "array",
|
|
3712
4524
|
items: {
|
|
@@ -3758,21 +4570,21 @@ class ImageClassificationTask extends AiVisionTask {
|
|
|
3758
4570
|
}
|
|
3759
4571
|
}
|
|
3760
4572
|
var imageClassification = (input, config) => {
|
|
3761
|
-
return new ImageClassificationTask(
|
|
4573
|
+
return new ImageClassificationTask(config).run(input);
|
|
3762
4574
|
};
|
|
3763
|
-
|
|
4575
|
+
Workflow22.prototype.imageClassification = CreateWorkflow22(ImageClassificationTask);
|
|
3764
4576
|
|
|
3765
4577
|
// src/task/ImageEmbeddingTask.ts
|
|
3766
|
-
import { CreateWorkflow as
|
|
4578
|
+
import { CreateWorkflow as CreateWorkflow23, Workflow as Workflow23 } from "@workglow/task-graph";
|
|
3767
4579
|
import {
|
|
3768
4580
|
TypedArraySchema as TypedArraySchema7
|
|
3769
4581
|
} from "@workglow/util/schema";
|
|
3770
|
-
var
|
|
4582
|
+
var modelSchema16 = TypeModel("model:ImageEmbeddingTask");
|
|
3771
4583
|
var ImageEmbeddingInputSchema = {
|
|
3772
4584
|
type: "object",
|
|
3773
4585
|
properties: {
|
|
3774
4586
|
image: TypeSingleOrArray(TypeImageInput),
|
|
3775
|
-
model:
|
|
4587
|
+
model: modelSchema16
|
|
3776
4588
|
},
|
|
3777
4589
|
required: ["image", "model"],
|
|
3778
4590
|
additionalProperties: false
|
|
@@ -3802,18 +4614,18 @@ class ImageEmbeddingTask extends AiVisionTask {
|
|
|
3802
4614
|
}
|
|
3803
4615
|
}
|
|
3804
4616
|
var imageEmbedding = (input, config) => {
|
|
3805
|
-
return new ImageEmbeddingTask(
|
|
4617
|
+
return new ImageEmbeddingTask(config).run(input);
|
|
3806
4618
|
};
|
|
3807
|
-
|
|
4619
|
+
Workflow23.prototype.imageEmbedding = CreateWorkflow23(ImageEmbeddingTask);
|
|
3808
4620
|
|
|
3809
4621
|
// src/task/ImageSegmentationTask.ts
|
|
3810
|
-
import { CreateWorkflow as
|
|
3811
|
-
var
|
|
4622
|
+
import { CreateWorkflow as CreateWorkflow24, Workflow as Workflow24 } from "@workglow/task-graph";
|
|
4623
|
+
var modelSchema17 = TypeModel("model:ImageSegmentationTask");
|
|
3812
4624
|
var ImageSegmentationInputSchema = {
|
|
3813
4625
|
type: "object",
|
|
3814
4626
|
properties: {
|
|
3815
4627
|
image: TypeImageInput,
|
|
3816
|
-
model:
|
|
4628
|
+
model: modelSchema17,
|
|
3817
4629
|
threshold: {
|
|
3818
4630
|
type: "number",
|
|
3819
4631
|
title: "Threshold",
|
|
@@ -3890,13 +4702,13 @@ class ImageSegmentationTask extends AiVisionTask {
|
|
|
3890
4702
|
}
|
|
3891
4703
|
}
|
|
3892
4704
|
var imageSegmentation = (input, config) => {
|
|
3893
|
-
return new ImageSegmentationTask(
|
|
4705
|
+
return new ImageSegmentationTask(config).run(input);
|
|
3894
4706
|
};
|
|
3895
|
-
|
|
4707
|
+
Workflow24.prototype.imageSegmentation = CreateWorkflow24(ImageSegmentationTask);
|
|
3896
4708
|
|
|
3897
4709
|
// src/task/ImageToTextTask.ts
|
|
3898
|
-
import { CreateWorkflow as
|
|
3899
|
-
var
|
|
4710
|
+
import { CreateWorkflow as CreateWorkflow25, Workflow as Workflow25 } from "@workglow/task-graph";
|
|
4711
|
+
var modelSchema18 = TypeModel("model:ImageToTextTask");
|
|
3900
4712
|
var generatedTextSchema = {
|
|
3901
4713
|
type: "string",
|
|
3902
4714
|
title: "Text",
|
|
@@ -3906,7 +4718,7 @@ var ImageToTextInputSchema = {
|
|
|
3906
4718
|
type: "object",
|
|
3907
4719
|
properties: {
|
|
3908
4720
|
image: TypeImageInput,
|
|
3909
|
-
model:
|
|
4721
|
+
model: modelSchema18,
|
|
3910
4722
|
maxTokens: {
|
|
3911
4723
|
type: "number",
|
|
3912
4724
|
title: "Max Tokens",
|
|
@@ -3945,17 +4757,17 @@ class ImageToTextTask extends AiVisionTask {
|
|
|
3945
4757
|
}
|
|
3946
4758
|
}
|
|
3947
4759
|
var imageToText = (input, config) => {
|
|
3948
|
-
return new ImageToTextTask(
|
|
4760
|
+
return new ImageToTextTask(config).run(input);
|
|
3949
4761
|
};
|
|
3950
|
-
|
|
4762
|
+
Workflow25.prototype.imageToText = CreateWorkflow25(ImageToTextTask);
|
|
3951
4763
|
|
|
3952
4764
|
// src/task/ModelInfoTask.ts
|
|
3953
|
-
import { CreateWorkflow as
|
|
3954
|
-
var
|
|
4765
|
+
import { CreateWorkflow as CreateWorkflow26, Workflow as Workflow26 } from "@workglow/task-graph";
|
|
4766
|
+
var modelSchema19 = TypeModel("model");
|
|
3955
4767
|
var ModelInfoInputSchema = {
|
|
3956
4768
|
type: "object",
|
|
3957
4769
|
properties: {
|
|
3958
|
-
model:
|
|
4770
|
+
model: modelSchema19,
|
|
3959
4771
|
detail: {
|
|
3960
4772
|
type: "string",
|
|
3961
4773
|
enum: ["cached_status", "files", "files_with_metadata"],
|
|
@@ -3968,7 +4780,7 @@ var ModelInfoInputSchema = {
|
|
|
3968
4780
|
var ModelInfoOutputSchema = {
|
|
3969
4781
|
type: "object",
|
|
3970
4782
|
properties: {
|
|
3971
|
-
model:
|
|
4783
|
+
model: modelSchema19,
|
|
3972
4784
|
is_local: { type: "boolean" },
|
|
3973
4785
|
is_remote: { type: "boolean" },
|
|
3974
4786
|
supports_browser: { type: "boolean" },
|
|
@@ -4016,12 +4828,12 @@ class ModelInfoTask extends AiTask {
|
|
|
4016
4828
|
}
|
|
4017
4829
|
}
|
|
4018
4830
|
var modelInfo = (input, config) => {
|
|
4019
|
-
return new ModelInfoTask(
|
|
4831
|
+
return new ModelInfoTask(config).run(input);
|
|
4020
4832
|
};
|
|
4021
|
-
|
|
4833
|
+
Workflow26.prototype.modelInfo = CreateWorkflow26(ModelInfoTask);
|
|
4022
4834
|
|
|
4023
4835
|
// src/task/ModelSearchTask.ts
|
|
4024
|
-
import { CreateWorkflow as
|
|
4836
|
+
import { CreateWorkflow as CreateWorkflow27, Task as Task12, Workflow as Workflow27 } from "@workglow/task-graph";
|
|
4025
4837
|
var ModelSearchInputSchema = {
|
|
4026
4838
|
type: "object",
|
|
4027
4839
|
properties: {
|
|
@@ -4086,7 +4898,7 @@ var ModelSearchOutputSchema = {
|
|
|
4086
4898
|
additionalProperties: false
|
|
4087
4899
|
};
|
|
4088
4900
|
|
|
4089
|
-
class ModelSearchTask extends
|
|
4901
|
+
class ModelSearchTask extends Task12 {
|
|
4090
4902
|
static type = "ModelSearchTask";
|
|
4091
4903
|
static category = "AI Model";
|
|
4092
4904
|
static title = "Model Search";
|
|
@@ -4110,13 +4922,13 @@ class ModelSearchTask extends Task11 {
|
|
|
4110
4922
|
}
|
|
4111
4923
|
}
|
|
4112
4924
|
var modelSearch = (input, config) => {
|
|
4113
|
-
return new ModelSearchTask(
|
|
4925
|
+
return new ModelSearchTask(config).run(input);
|
|
4114
4926
|
};
|
|
4115
|
-
|
|
4927
|
+
Workflow27.prototype.modelSearch = CreateWorkflow27(ModelSearchTask);
|
|
4116
4928
|
|
|
4117
4929
|
// src/task/ObjectDetectionTask.ts
|
|
4118
|
-
import { CreateWorkflow as
|
|
4119
|
-
var
|
|
4930
|
+
import { CreateWorkflow as CreateWorkflow28, Workflow as Workflow28 } from "@workglow/task-graph";
|
|
4931
|
+
var modelSchema20 = TypeModel("model:ObjectDetectionTask");
|
|
4120
4932
|
var detectionSchema = {
|
|
4121
4933
|
type: "object",
|
|
4122
4934
|
properties: {
|
|
@@ -4141,7 +4953,7 @@ var ObjectDetectionInputSchema = {
|
|
|
4141
4953
|
type: "object",
|
|
4142
4954
|
properties: {
|
|
4143
4955
|
image: TypeImageInput,
|
|
4144
|
-
model:
|
|
4956
|
+
model: modelSchema20,
|
|
4145
4957
|
labels: {
|
|
4146
4958
|
type: "array",
|
|
4147
4959
|
items: {
|
|
@@ -4193,13 +5005,13 @@ class ObjectDetectionTask extends AiVisionTask {
|
|
|
4193
5005
|
}
|
|
4194
5006
|
}
|
|
4195
5007
|
var objectDetection = (input, config) => {
|
|
4196
|
-
return new ObjectDetectionTask(
|
|
5008
|
+
return new ObjectDetectionTask(config).run(input);
|
|
4197
5009
|
};
|
|
4198
|
-
|
|
5010
|
+
Workflow28.prototype.objectDetection = CreateWorkflow28(ObjectDetectionTask);
|
|
4199
5011
|
|
|
4200
5012
|
// src/task/PoseLandmarkerTask.ts
|
|
4201
|
-
import { CreateWorkflow as
|
|
4202
|
-
var
|
|
5013
|
+
import { CreateWorkflow as CreateWorkflow29, Workflow as Workflow29 } from "@workglow/task-graph";
|
|
5014
|
+
var modelSchema21 = TypeModel("model:PoseLandmarkerTask");
|
|
4203
5015
|
var TypePoseLandmark = {
|
|
4204
5016
|
type: "object",
|
|
4205
5017
|
properties: {
|
|
@@ -4278,7 +5090,7 @@ var PoseLandmarkerInputSchema = {
|
|
|
4278
5090
|
type: "object",
|
|
4279
5091
|
properties: {
|
|
4280
5092
|
image: TypeImageInput,
|
|
4281
|
-
model:
|
|
5093
|
+
model: modelSchema21,
|
|
4282
5094
|
numPoses: {
|
|
4283
5095
|
type: "number",
|
|
4284
5096
|
minimum: 1,
|
|
@@ -4355,12 +5167,12 @@ class PoseLandmarkerTask extends AiVisionTask {
|
|
|
4355
5167
|
}
|
|
4356
5168
|
}
|
|
4357
5169
|
var poseLandmarker = (input, config) => {
|
|
4358
|
-
return new PoseLandmarkerTask(
|
|
5170
|
+
return new PoseLandmarkerTask(config).run(input);
|
|
4359
5171
|
};
|
|
4360
|
-
|
|
5172
|
+
Workflow29.prototype.poseLandmarker = CreateWorkflow29(PoseLandmarkerTask);
|
|
4361
5173
|
|
|
4362
5174
|
// src/task/QueryExpanderTask.ts
|
|
4363
|
-
import { CreateWorkflow as
|
|
5175
|
+
import { CreateWorkflow as CreateWorkflow30, Task as Task13, Workflow as Workflow30 } from "@workglow/task-graph";
|
|
4364
5176
|
var QueryExpansionMethod = {
|
|
4365
5177
|
MULTI_QUERY: "multi-query",
|
|
4366
5178
|
HYDE: "hyde",
|
|
@@ -4428,7 +5240,7 @@ var outputSchema10 = {
|
|
|
4428
5240
|
additionalProperties: false
|
|
4429
5241
|
};
|
|
4430
5242
|
|
|
4431
|
-
class QueryExpanderTask extends
|
|
5243
|
+
class QueryExpanderTask extends Task13 {
|
|
4432
5244
|
static type = "QueryExpanderTask";
|
|
4433
5245
|
static category = "RAG";
|
|
4434
5246
|
static title = "Query Expander";
|
|
@@ -4568,16 +5380,16 @@ class QueryExpanderTask extends Task12 {
|
|
|
4568
5380
|
}
|
|
4569
5381
|
}
|
|
4570
5382
|
var queryExpander = (input, config) => {
|
|
4571
|
-
return new QueryExpanderTask(
|
|
5383
|
+
return new QueryExpanderTask(config).run(input);
|
|
4572
5384
|
};
|
|
4573
|
-
|
|
5385
|
+
Workflow30.prototype.queryExpander = CreateWorkflow30(QueryExpanderTask);
|
|
4574
5386
|
|
|
4575
5387
|
// src/task/RerankerTask.ts
|
|
4576
|
-
import { CreateWorkflow as
|
|
5388
|
+
import { CreateWorkflow as CreateWorkflow32, Task as Task14, Workflow as Workflow32 } from "@workglow/task-graph";
|
|
4577
5389
|
|
|
4578
5390
|
// src/task/TextClassificationTask.ts
|
|
4579
|
-
import { CreateWorkflow as
|
|
4580
|
-
var
|
|
5391
|
+
import { CreateWorkflow as CreateWorkflow31, Workflow as Workflow31 } from "@workglow/task-graph";
|
|
5392
|
+
var modelSchema22 = TypeModel("model:TextClassificationTask");
|
|
4581
5393
|
var TextClassificationInputSchema = {
|
|
4582
5394
|
type: "object",
|
|
4583
5395
|
properties: {
|
|
@@ -4604,7 +5416,7 @@ var TextClassificationInputSchema = {
|
|
|
4604
5416
|
description: "The maximum number of categories to return",
|
|
4605
5417
|
"x-ui-group": "Configuration"
|
|
4606
5418
|
},
|
|
4607
|
-
model:
|
|
5419
|
+
model: modelSchema22
|
|
4608
5420
|
},
|
|
4609
5421
|
required: ["text", "model"],
|
|
4610
5422
|
additionalProperties: false
|
|
@@ -4652,9 +5464,9 @@ class TextClassificationTask extends AiTask {
|
|
|
4652
5464
|
}
|
|
4653
5465
|
}
|
|
4654
5466
|
var textClassification = (input, config) => {
|
|
4655
|
-
return new TextClassificationTask(
|
|
5467
|
+
return new TextClassificationTask(config).run(input);
|
|
4656
5468
|
};
|
|
4657
|
-
|
|
5469
|
+
Workflow31.prototype.textClassification = CreateWorkflow31(TextClassificationTask);
|
|
4658
5470
|
|
|
4659
5471
|
// src/task/RerankerTask.ts
|
|
4660
5472
|
var inputSchema11 = {
|
|
@@ -4749,7 +5561,7 @@ var outputSchema11 = {
|
|
|
4749
5561
|
additionalProperties: false
|
|
4750
5562
|
};
|
|
4751
5563
|
|
|
4752
|
-
class RerankerTask extends
|
|
5564
|
+
class RerankerTask extends Task14 {
|
|
4753
5565
|
static type = "RerankerTask";
|
|
4754
5566
|
static category = "RAG";
|
|
4755
5567
|
static title = "Reranker";
|
|
@@ -4800,8 +5612,8 @@ class RerankerTask extends Task13 {
|
|
|
4800
5612
|
}
|
|
4801
5613
|
const items = await Promise.all(chunks.map(async (chunk, index) => {
|
|
4802
5614
|
const pairText = `${query} [SEP] ${chunk}`;
|
|
4803
|
-
const task = context.own(new TextClassificationTask({
|
|
4804
|
-
const result = await task.run();
|
|
5615
|
+
const task = context.own(new TextClassificationTask({ defaults: { model } }));
|
|
5616
|
+
const result = await task.run({ text: pairText, maxCategories: 2 });
|
|
4805
5617
|
const crossScore = this.extractCrossEncoderScore(result.categories);
|
|
4806
5618
|
return {
|
|
4807
5619
|
chunk,
|
|
@@ -4876,13 +5688,13 @@ class RerankerTask extends Task13 {
|
|
|
4876
5688
|
}
|
|
4877
5689
|
}
|
|
4878
5690
|
var reranker = (input, config) => {
|
|
4879
|
-
return new RerankerTask(
|
|
5691
|
+
return new RerankerTask(config).run(input);
|
|
4880
5692
|
};
|
|
4881
|
-
|
|
5693
|
+
Workflow32.prototype.reranker = CreateWorkflow32(RerankerTask);
|
|
4882
5694
|
|
|
4883
5695
|
// src/task/StructuralParserTask.ts
|
|
4884
5696
|
import { StructuralParser } from "@workglow/knowledge-base";
|
|
4885
|
-
import { CreateWorkflow as
|
|
5697
|
+
import { CreateWorkflow as CreateWorkflow33, Task as Task15, Workflow as Workflow33 } from "@workglow/task-graph";
|
|
4886
5698
|
import { uuid4 as uuid42 } from "@workglow/util";
|
|
4887
5699
|
var inputSchema12 = {
|
|
4888
5700
|
type: "object",
|
|
@@ -4940,7 +5752,7 @@ var outputSchema12 = {
|
|
|
4940
5752
|
additionalProperties: false
|
|
4941
5753
|
};
|
|
4942
5754
|
|
|
4943
|
-
class StructuralParserTask extends
|
|
5755
|
+
class StructuralParserTask extends Task15 {
|
|
4944
5756
|
static type = "StructuralParserTask";
|
|
4945
5757
|
static category = "Document";
|
|
4946
5758
|
static title = "Structural Parser";
|
|
@@ -4981,17 +5793,17 @@ class StructuralParserTask extends Task14 {
|
|
|
4981
5793
|
}
|
|
4982
5794
|
}
|
|
4983
5795
|
var structuralParser = (input, config) => {
|
|
4984
|
-
return new StructuralParserTask(
|
|
5796
|
+
return new StructuralParserTask(config).run(input);
|
|
4985
5797
|
};
|
|
4986
|
-
|
|
5798
|
+
Workflow33.prototype.structuralParser = CreateWorkflow33(StructuralParserTask);
|
|
4987
5799
|
|
|
4988
5800
|
// src/task/StructuredGenerationTask.ts
|
|
4989
|
-
import { CreateWorkflow as
|
|
4990
|
-
var
|
|
5801
|
+
import { CreateWorkflow as CreateWorkflow34, Workflow as Workflow34 } from "@workglow/task-graph";
|
|
5802
|
+
var modelSchema23 = TypeModel("model:StructuredGenerationTask");
|
|
4991
5803
|
var StructuredGenerationInputSchema = {
|
|
4992
5804
|
type: "object",
|
|
4993
5805
|
properties: {
|
|
4994
|
-
model:
|
|
5806
|
+
model: modelSchema23,
|
|
4995
5807
|
prompt: {
|
|
4996
5808
|
type: "string",
|
|
4997
5809
|
title: "Prompt",
|
|
@@ -5052,12 +5864,12 @@ class StructuredGenerationTask extends StreamingAiTask {
|
|
|
5052
5864
|
}
|
|
5053
5865
|
}
|
|
5054
5866
|
var structuredGeneration = (input, config) => {
|
|
5055
|
-
return new StructuredGenerationTask(
|
|
5867
|
+
return new StructuredGenerationTask(config).run(input);
|
|
5056
5868
|
};
|
|
5057
|
-
|
|
5869
|
+
Workflow34.prototype.structuredGeneration = CreateWorkflow34(StructuredGenerationTask);
|
|
5058
5870
|
|
|
5059
5871
|
// src/task/TextChunkerTask.ts
|
|
5060
|
-
import { CreateWorkflow as
|
|
5872
|
+
import { CreateWorkflow as CreateWorkflow35, Task as Task16, Workflow as Workflow35 } from "@workglow/task-graph";
|
|
5061
5873
|
var ChunkingStrategy = {
|
|
5062
5874
|
FIXED: "fixed",
|
|
5063
5875
|
SENTENCE: "sentence",
|
|
@@ -5126,7 +5938,7 @@ var outputSchema13 = {
|
|
|
5126
5938
|
additionalProperties: false
|
|
5127
5939
|
};
|
|
5128
5940
|
|
|
5129
|
-
class TextChunkerTask extends
|
|
5941
|
+
class TextChunkerTask extends Task16 {
|
|
5130
5942
|
static type = "TextChunkerTask";
|
|
5131
5943
|
static category = "Document";
|
|
5132
5944
|
static title = "Text Chunker";
|
|
@@ -5304,13 +6116,13 @@ class TextChunkerTask extends Task15 {
|
|
|
5304
6116
|
}
|
|
5305
6117
|
}
|
|
5306
6118
|
var textChunker = (input, config) => {
|
|
5307
|
-
return new TextChunkerTask(
|
|
6119
|
+
return new TextChunkerTask(config).run(input);
|
|
5308
6120
|
};
|
|
5309
|
-
|
|
6121
|
+
Workflow35.prototype.textChunker = CreateWorkflow35(TextChunkerTask);
|
|
5310
6122
|
|
|
5311
6123
|
// src/task/TextFillMaskTask.ts
|
|
5312
|
-
import { CreateWorkflow as
|
|
5313
|
-
var
|
|
6124
|
+
import { CreateWorkflow as CreateWorkflow36, Workflow as Workflow36 } from "@workglow/task-graph";
|
|
6125
|
+
var modelSchema24 = TypeModel("model:TextFillMaskTask");
|
|
5314
6126
|
var TextFillMaskInputSchema = {
|
|
5315
6127
|
type: "object",
|
|
5316
6128
|
properties: {
|
|
@@ -5319,7 +6131,7 @@ var TextFillMaskInputSchema = {
|
|
|
5319
6131
|
title: "Text",
|
|
5320
6132
|
description: "The text with a mask token to fill"
|
|
5321
6133
|
},
|
|
5322
|
-
model:
|
|
6134
|
+
model: modelSchema24
|
|
5323
6135
|
},
|
|
5324
6136
|
required: ["text", "model"],
|
|
5325
6137
|
additionalProperties: false
|
|
@@ -5372,23 +6184,23 @@ class TextFillMaskTask extends AiTask {
|
|
|
5372
6184
|
}
|
|
5373
6185
|
}
|
|
5374
6186
|
var textFillMask = (input, config) => {
|
|
5375
|
-
return new TextFillMaskTask(
|
|
6187
|
+
return new TextFillMaskTask(config).run(input);
|
|
5376
6188
|
};
|
|
5377
|
-
|
|
6189
|
+
Workflow36.prototype.textFillMask = CreateWorkflow36(TextFillMaskTask);
|
|
5378
6190
|
|
|
5379
6191
|
// src/task/TextGenerationTask.ts
|
|
5380
|
-
import { CreateWorkflow as
|
|
6192
|
+
import { CreateWorkflow as CreateWorkflow37, Workflow as Workflow37 } from "@workglow/task-graph";
|
|
5381
6193
|
var generatedTextSchema2 = {
|
|
5382
6194
|
type: "string",
|
|
5383
6195
|
title: "Text",
|
|
5384
6196
|
description: "The generated text",
|
|
5385
6197
|
"x-stream": "append"
|
|
5386
6198
|
};
|
|
5387
|
-
var
|
|
6199
|
+
var modelSchema25 = TypeModel("model:TextGenerationTask");
|
|
5388
6200
|
var TextGenerationInputSchema = {
|
|
5389
6201
|
type: "object",
|
|
5390
6202
|
properties: {
|
|
5391
|
-
model:
|
|
6203
|
+
model: modelSchema25,
|
|
5392
6204
|
prompt: {
|
|
5393
6205
|
type: "string",
|
|
5394
6206
|
title: "Prompt",
|
|
@@ -5460,13 +6272,13 @@ class TextGenerationTask extends StreamingAiTask {
|
|
|
5460
6272
|
}
|
|
5461
6273
|
}
|
|
5462
6274
|
var textGeneration = (input, config) => {
|
|
5463
|
-
return new TextGenerationTask(
|
|
6275
|
+
return new TextGenerationTask(config).run(input);
|
|
5464
6276
|
};
|
|
5465
|
-
|
|
6277
|
+
Workflow37.prototype.textGeneration = CreateWorkflow37(TextGenerationTask);
|
|
5466
6278
|
|
|
5467
6279
|
// src/task/TextLanguageDetectionTask.ts
|
|
5468
|
-
import { CreateWorkflow as
|
|
5469
|
-
var
|
|
6280
|
+
import { CreateWorkflow as CreateWorkflow38, Workflow as Workflow38 } from "@workglow/task-graph";
|
|
6281
|
+
var modelSchema26 = TypeModel("model:TextLanguageDetectionTask");
|
|
5470
6282
|
var TextLanguageDetectionInputSchema = {
|
|
5471
6283
|
type: "object",
|
|
5472
6284
|
properties: {
|
|
@@ -5483,7 +6295,7 @@ var TextLanguageDetectionInputSchema = {
|
|
|
5483
6295
|
title: "Max Languages",
|
|
5484
6296
|
description: "The maximum number of languages to return"
|
|
5485
6297
|
},
|
|
5486
|
-
model:
|
|
6298
|
+
model: modelSchema26
|
|
5487
6299
|
},
|
|
5488
6300
|
required: ["text", "model"],
|
|
5489
6301
|
additionalProperties: false
|
|
@@ -5531,12 +6343,12 @@ class TextLanguageDetectionTask extends AiTask {
|
|
|
5531
6343
|
}
|
|
5532
6344
|
}
|
|
5533
6345
|
var textLanguageDetection = (input, config) => {
|
|
5534
|
-
return new TextLanguageDetectionTask(
|
|
6346
|
+
return new TextLanguageDetectionTask(config).run(input);
|
|
5535
6347
|
};
|
|
5536
|
-
|
|
6348
|
+
Workflow38.prototype.textLanguageDetection = CreateWorkflow38(TextLanguageDetectionTask);
|
|
5537
6349
|
|
|
5538
6350
|
// src/task/TextQuestionAnswerTask.ts
|
|
5539
|
-
import { CreateWorkflow as
|
|
6351
|
+
import { CreateWorkflow as CreateWorkflow39, Workflow as Workflow39 } from "@workglow/task-graph";
|
|
5540
6352
|
var contextSchema = {
|
|
5541
6353
|
type: "string",
|
|
5542
6354
|
title: "Context",
|
|
@@ -5553,13 +6365,13 @@ var textSchema = {
|
|
|
5553
6365
|
description: "The generated text",
|
|
5554
6366
|
"x-stream": "append"
|
|
5555
6367
|
};
|
|
5556
|
-
var
|
|
6368
|
+
var modelSchema27 = TypeModel("model:TextQuestionAnswerTask");
|
|
5557
6369
|
var TextQuestionAnswerInputSchema = {
|
|
5558
6370
|
type: "object",
|
|
5559
6371
|
properties: {
|
|
5560
6372
|
context: contextSchema,
|
|
5561
6373
|
question: questionSchema,
|
|
5562
|
-
model:
|
|
6374
|
+
model: modelSchema27
|
|
5563
6375
|
},
|
|
5564
6376
|
required: ["context", "question", "model"],
|
|
5565
6377
|
additionalProperties: false
|
|
@@ -5586,13 +6398,13 @@ class TextQuestionAnswerTask extends StreamingAiTask {
|
|
|
5586
6398
|
}
|
|
5587
6399
|
}
|
|
5588
6400
|
var textQuestionAnswer = (input, config) => {
|
|
5589
|
-
return new TextQuestionAnswerTask(
|
|
6401
|
+
return new TextQuestionAnswerTask(config).run(input);
|
|
5590
6402
|
};
|
|
5591
|
-
|
|
6403
|
+
Workflow39.prototype.textQuestionAnswer = CreateWorkflow39(TextQuestionAnswerTask);
|
|
5592
6404
|
|
|
5593
6405
|
// src/task/TextRewriterTask.ts
|
|
5594
|
-
import { CreateWorkflow as
|
|
5595
|
-
var
|
|
6406
|
+
import { CreateWorkflow as CreateWorkflow40, Workflow as Workflow40 } from "@workglow/task-graph";
|
|
6407
|
+
var modelSchema28 = TypeModel("model:TextRewriterTask");
|
|
5596
6408
|
var TextRewriterInputSchema = {
|
|
5597
6409
|
type: "object",
|
|
5598
6410
|
properties: {
|
|
@@ -5606,7 +6418,7 @@ var TextRewriterInputSchema = {
|
|
|
5606
6418
|
title: "Prompt",
|
|
5607
6419
|
description: "The prompt to direct the rewriting"
|
|
5608
6420
|
},
|
|
5609
|
-
model:
|
|
6421
|
+
model: modelSchema28
|
|
5610
6422
|
},
|
|
5611
6423
|
required: ["text", "prompt", "model"],
|
|
5612
6424
|
additionalProperties: false
|
|
@@ -5638,13 +6450,13 @@ class TextRewriterTask extends StreamingAiTask {
|
|
|
5638
6450
|
}
|
|
5639
6451
|
}
|
|
5640
6452
|
var textRewriter = (input, config) => {
|
|
5641
|
-
return new TextRewriterTask(
|
|
6453
|
+
return new TextRewriterTask(config).run(input);
|
|
5642
6454
|
};
|
|
5643
|
-
|
|
6455
|
+
Workflow40.prototype.textRewriter = CreateWorkflow40(TextRewriterTask);
|
|
5644
6456
|
|
|
5645
6457
|
// src/task/TextTranslationTask.ts
|
|
5646
|
-
import { CreateWorkflow as
|
|
5647
|
-
var
|
|
6458
|
+
import { CreateWorkflow as CreateWorkflow41, Workflow as Workflow41 } from "@workglow/task-graph";
|
|
6459
|
+
var modelSchema29 = TypeModel("model:TextTranslationTask");
|
|
5648
6460
|
var translationTextSchema = {
|
|
5649
6461
|
type: "string",
|
|
5650
6462
|
title: "Text",
|
|
@@ -5671,7 +6483,7 @@ var TextTranslationInputSchema = {
|
|
|
5671
6483
|
minLength: 2,
|
|
5672
6484
|
maxLength: 2
|
|
5673
6485
|
}),
|
|
5674
|
-
model:
|
|
6486
|
+
model: modelSchema29
|
|
5675
6487
|
},
|
|
5676
6488
|
required: ["text", "source_lang", "target_lang", "model"],
|
|
5677
6489
|
additionalProperties: false
|
|
@@ -5704,12 +6516,12 @@ class TextTranslationTask extends StreamingAiTask {
|
|
|
5704
6516
|
}
|
|
5705
6517
|
}
|
|
5706
6518
|
var textTranslation = (input, config) => {
|
|
5707
|
-
return new TextTranslationTask(
|
|
6519
|
+
return new TextTranslationTask(config).run(input);
|
|
5708
6520
|
};
|
|
5709
|
-
|
|
6521
|
+
Workflow41.prototype.textTranslation = CreateWorkflow41(TextTranslationTask);
|
|
5710
6522
|
|
|
5711
6523
|
// src/task/TopicSegmenterTask.ts
|
|
5712
|
-
import { CreateWorkflow as
|
|
6524
|
+
import { CreateWorkflow as CreateWorkflow42, Task as Task17, Workflow as Workflow42 } from "@workglow/task-graph";
|
|
5713
6525
|
var SegmentationMethod = {
|
|
5714
6526
|
HEURISTIC: "heuristic",
|
|
5715
6527
|
EMBEDDING_SIMILARITY: "embedding-similarity",
|
|
@@ -5784,7 +6596,7 @@ var outputSchema14 = {
|
|
|
5784
6596
|
additionalProperties: false
|
|
5785
6597
|
};
|
|
5786
6598
|
|
|
5787
|
-
class TopicSegmenterTask extends
|
|
6599
|
+
class TopicSegmenterTask extends Task17 {
|
|
5788
6600
|
static type = "TopicSegmenterTask";
|
|
5789
6601
|
static category = "Document";
|
|
5790
6602
|
static title = "Topic Segmenter";
|
|
@@ -5987,17 +6799,17 @@ class TopicSegmenterTask extends Task16 {
|
|
|
5987
6799
|
}
|
|
5988
6800
|
}
|
|
5989
6801
|
var topicSegmenter = (input, config) => {
|
|
5990
|
-
return new TopicSegmenterTask(
|
|
6802
|
+
return new TopicSegmenterTask(config).run(input);
|
|
5991
6803
|
};
|
|
5992
|
-
|
|
6804
|
+
Workflow42.prototype.topicSegmenter = CreateWorkflow42(TopicSegmenterTask);
|
|
5993
6805
|
|
|
5994
6806
|
// src/task/UnloadModelTask.ts
|
|
5995
|
-
import { CreateWorkflow as
|
|
5996
|
-
var
|
|
6807
|
+
import { CreateWorkflow as CreateWorkflow43, Workflow as Workflow43 } from "@workglow/task-graph";
|
|
6808
|
+
var modelSchema30 = TypeModel("model");
|
|
5997
6809
|
var UnloadModelInputSchema = {
|
|
5998
6810
|
type: "object",
|
|
5999
6811
|
properties: {
|
|
6000
|
-
model:
|
|
6812
|
+
model: modelSchema30
|
|
6001
6813
|
},
|
|
6002
6814
|
required: ["model"],
|
|
6003
6815
|
additionalProperties: false
|
|
@@ -6005,7 +6817,7 @@ var UnloadModelInputSchema = {
|
|
|
6005
6817
|
var UnloadModelOutputSchema = {
|
|
6006
6818
|
type: "object",
|
|
6007
6819
|
properties: {
|
|
6008
|
-
model:
|
|
6820
|
+
model: modelSchema30
|
|
6009
6821
|
},
|
|
6010
6822
|
required: ["model"],
|
|
6011
6823
|
additionalProperties: false
|
|
@@ -6025,12 +6837,12 @@ class UnloadModelTask extends AiTask {
|
|
|
6025
6837
|
static cacheable = false;
|
|
6026
6838
|
}
|
|
6027
6839
|
var unloadModel = (input, config) => {
|
|
6028
|
-
return new UnloadModelTask(
|
|
6840
|
+
return new UnloadModelTask(config).run(input);
|
|
6029
6841
|
};
|
|
6030
|
-
|
|
6842
|
+
Workflow43.prototype.unloadModel = CreateWorkflow43(UnloadModelTask);
|
|
6031
6843
|
|
|
6032
6844
|
// src/task/VectorQuantizeTask.ts
|
|
6033
|
-
import { CreateWorkflow as
|
|
6845
|
+
import { CreateWorkflow as CreateWorkflow44, Task as Task18, Workflow as Workflow44 } from "@workglow/task-graph";
|
|
6034
6846
|
import {
|
|
6035
6847
|
normalizeNumberArray,
|
|
6036
6848
|
TensorType,
|
|
@@ -6110,7 +6922,7 @@ var outputSchema15 = {
|
|
|
6110
6922
|
additionalProperties: false
|
|
6111
6923
|
};
|
|
6112
6924
|
|
|
6113
|
-
class VectorQuantizeTask extends
|
|
6925
|
+
class VectorQuantizeTask extends Task18 {
|
|
6114
6926
|
static type = "VectorQuantizeTask";
|
|
6115
6927
|
static category = "Vector";
|
|
6116
6928
|
static title = "Quantize";
|
|
@@ -6208,12 +7020,12 @@ class VectorQuantizeTask extends Task17 {
|
|
|
6208
7020
|
}
|
|
6209
7021
|
}
|
|
6210
7022
|
var vectorQuantize = (input, config) => {
|
|
6211
|
-
return new VectorQuantizeTask(
|
|
7023
|
+
return new VectorQuantizeTask(config).run(input);
|
|
6212
7024
|
};
|
|
6213
|
-
|
|
7025
|
+
Workflow44.prototype.vectorQuantize = CreateWorkflow44(VectorQuantizeTask);
|
|
6214
7026
|
|
|
6215
7027
|
// src/task/VectorSimilarityTask.ts
|
|
6216
|
-
import { CreateWorkflow as
|
|
7028
|
+
import { CreateWorkflow as CreateWorkflow45, GraphAsTask, Workflow as Workflow45 } from "@workglow/task-graph";
|
|
6217
7029
|
import {
|
|
6218
7030
|
cosineSimilarity,
|
|
6219
7031
|
hammingSimilarity,
|
|
@@ -6317,13 +7129,210 @@ class VectorSimilarityTask extends GraphAsTask {
|
|
|
6317
7129
|
}
|
|
6318
7130
|
}
|
|
6319
7131
|
var similarity = (input, config) => {
|
|
6320
|
-
return new VectorSimilarityTask(
|
|
6321
|
-
};
|
|
6322
|
-
|
|
7132
|
+
return new VectorSimilarityTask(config).run(input);
|
|
7133
|
+
};
|
|
7134
|
+
Workflow45.prototype.similarity = CreateWorkflow45(VectorSimilarityTask);
|
|
7135
|
+
// src/task/MessageConversion.ts
|
|
7136
|
+
function getInputMessages(input) {
|
|
7137
|
+
const messages = input.messages;
|
|
7138
|
+
if (!messages || messages.length === 0)
|
|
7139
|
+
return;
|
|
7140
|
+
return messages;
|
|
7141
|
+
}
|
|
7142
|
+
function toOpenAIMessages(input) {
|
|
7143
|
+
const messages = [];
|
|
7144
|
+
if (input.systemPrompt) {
|
|
7145
|
+
messages.push({ role: "system", content: input.systemPrompt });
|
|
7146
|
+
}
|
|
7147
|
+
const inputMessages = getInputMessages(input);
|
|
7148
|
+
if (!inputMessages) {
|
|
7149
|
+
if (!Array.isArray(input.prompt)) {
|
|
7150
|
+
messages.push({ role: "user", content: input.prompt });
|
|
7151
|
+
} else if (input.prompt.every((item) => typeof item === "string")) {
|
|
7152
|
+
messages.push({ role: "user", content: input.prompt.join(`
|
|
7153
|
+
`) });
|
|
7154
|
+
} else {
|
|
7155
|
+
const parts = [];
|
|
7156
|
+
for (const item of input.prompt) {
|
|
7157
|
+
if (typeof item === "string") {
|
|
7158
|
+
parts.push({ type: "text", text: item });
|
|
7159
|
+
} else {
|
|
7160
|
+
const b = item;
|
|
7161
|
+
if (b.type === "text") {
|
|
7162
|
+
parts.push({ type: "text", text: b.text });
|
|
7163
|
+
} else if (b.type === "image") {
|
|
7164
|
+
parts.push({
|
|
7165
|
+
type: "image_url",
|
|
7166
|
+
image_url: { url: `data:${b.mimeType};base64,${b.data}` }
|
|
7167
|
+
});
|
|
7168
|
+
} else if (b.type === "audio") {
|
|
7169
|
+
const format = b.mimeType.replace(/^audio\//, "");
|
|
7170
|
+
parts.push({
|
|
7171
|
+
type: "input_audio",
|
|
7172
|
+
input_audio: { data: b.data, format }
|
|
7173
|
+
});
|
|
7174
|
+
}
|
|
7175
|
+
}
|
|
7176
|
+
}
|
|
7177
|
+
messages.push({ role: "user", content: parts });
|
|
7178
|
+
}
|
|
7179
|
+
return messages;
|
|
7180
|
+
}
|
|
7181
|
+
for (const msg of inputMessages) {
|
|
7182
|
+
if (msg.role === "user") {
|
|
7183
|
+
if (typeof msg.content === "string") {
|
|
7184
|
+
messages.push({ role: "user", content: msg.content });
|
|
7185
|
+
} else if (Array.isArray(msg.content) && msg.content.length > 0 && typeof msg.content[0]?.type === "string") {
|
|
7186
|
+
const parts = [];
|
|
7187
|
+
for (const block of msg.content) {
|
|
7188
|
+
const b = block;
|
|
7189
|
+
if (b.type === "text") {
|
|
7190
|
+
parts.push({ type: "text", text: b.text });
|
|
7191
|
+
} else if (b.type === "image") {
|
|
7192
|
+
parts.push({
|
|
7193
|
+
type: "image_url",
|
|
7194
|
+
image_url: { url: `data:${b.mimeType};base64,${b.data}` }
|
|
7195
|
+
});
|
|
7196
|
+
} else if (b.type === "audio") {
|
|
7197
|
+
const format = b.mimeType.replace(/^audio\//, "");
|
|
7198
|
+
parts.push({
|
|
7199
|
+
type: "input_audio",
|
|
7200
|
+
input_audio: { data: b.data, format }
|
|
7201
|
+
});
|
|
7202
|
+
}
|
|
7203
|
+
}
|
|
7204
|
+
messages.push({ role: "user", content: parts });
|
|
7205
|
+
} else {
|
|
7206
|
+
try {
|
|
7207
|
+
messages.push({ role: "user", content: JSON.stringify(msg.content) });
|
|
7208
|
+
} catch {
|
|
7209
|
+
messages.push({ role: "user", content: String(msg.content) });
|
|
7210
|
+
}
|
|
7211
|
+
}
|
|
7212
|
+
} else if (msg.role === "assistant") {
|
|
7213
|
+
if (typeof msg.content === "string") {
|
|
7214
|
+
messages.push({ role: "assistant", content: msg.content.length > 0 ? msg.content : null });
|
|
7215
|
+
} else if (Array.isArray(msg.content)) {
|
|
7216
|
+
const textParts = msg.content.filter((b) => b.type === "text").map((b) => b.text).join("");
|
|
7217
|
+
const toolCalls = msg.content.filter((b) => b.type === "tool_use").map((b) => ({
|
|
7218
|
+
id: b.id,
|
|
7219
|
+
type: "function",
|
|
7220
|
+
function: {
|
|
7221
|
+
name: b.name,
|
|
7222
|
+
arguments: JSON.stringify(b.input)
|
|
7223
|
+
}
|
|
7224
|
+
}));
|
|
7225
|
+
const entry = {
|
|
7226
|
+
role: "assistant",
|
|
7227
|
+
content: textParts.length > 0 ? textParts : null
|
|
7228
|
+
};
|
|
7229
|
+
if (toolCalls.length > 0) {
|
|
7230
|
+
entry.tool_calls = toolCalls;
|
|
7231
|
+
}
|
|
7232
|
+
messages.push(entry);
|
|
7233
|
+
}
|
|
7234
|
+
} else if (msg.role === "tool" && Array.isArray(msg.content)) {
|
|
7235
|
+
for (const block of msg.content) {
|
|
7236
|
+
const b = block;
|
|
7237
|
+
let content;
|
|
7238
|
+
if (typeof b.content === "string") {
|
|
7239
|
+
content = b.content;
|
|
7240
|
+
} else if (Array.isArray(b.content)) {
|
|
7241
|
+
const parts = [];
|
|
7242
|
+
for (const inner of b.content) {
|
|
7243
|
+
if (inner.type === "text") {
|
|
7244
|
+
parts.push({ type: "text", text: inner.text });
|
|
7245
|
+
} else if (inner.type === "image") {
|
|
7246
|
+
parts.push({
|
|
7247
|
+
type: "image_url",
|
|
7248
|
+
image_url: { url: `data:${inner.mimeType};base64,${inner.data}` }
|
|
7249
|
+
});
|
|
7250
|
+
}
|
|
7251
|
+
}
|
|
7252
|
+
content = parts;
|
|
7253
|
+
} else {
|
|
7254
|
+
content = "";
|
|
7255
|
+
}
|
|
7256
|
+
messages.push({
|
|
7257
|
+
role: "tool",
|
|
7258
|
+
content,
|
|
7259
|
+
tool_call_id: b.tool_use_id
|
|
7260
|
+
});
|
|
7261
|
+
}
|
|
7262
|
+
}
|
|
7263
|
+
}
|
|
7264
|
+
return messages;
|
|
7265
|
+
}
|
|
7266
|
+
function toTextFlatMessages(input) {
|
|
7267
|
+
const messages = [];
|
|
7268
|
+
if (input.systemPrompt) {
|
|
7269
|
+
messages.push({ role: "system", content: input.systemPrompt });
|
|
7270
|
+
}
|
|
7271
|
+
const inputMessages = getInputMessages(input);
|
|
7272
|
+
if (!inputMessages) {
|
|
7273
|
+
let promptContent;
|
|
7274
|
+
if (!Array.isArray(input.prompt)) {
|
|
7275
|
+
promptContent = input.prompt;
|
|
7276
|
+
} else {
|
|
7277
|
+
promptContent = input.prompt.map((item) => {
|
|
7278
|
+
if (typeof item === "string")
|
|
7279
|
+
return item;
|
|
7280
|
+
const b = item;
|
|
7281
|
+
return b.type === "text" ? b.text : "";
|
|
7282
|
+
}).filter((s) => s !== "").join(`
|
|
7283
|
+
`);
|
|
7284
|
+
}
|
|
7285
|
+
messages.push({ role: "user", content: promptContent });
|
|
7286
|
+
return messages;
|
|
7287
|
+
}
|
|
7288
|
+
for (const msg of inputMessages) {
|
|
7289
|
+
if (msg.role === "user") {
|
|
7290
|
+
let content = "";
|
|
7291
|
+
if (typeof msg.content === "string") {
|
|
7292
|
+
content = msg.content;
|
|
7293
|
+
} else if (Array.isArray(msg.content) && msg.content.length > 0 && typeof msg.content[0]?.type === "string") {
|
|
7294
|
+
content = msg.content.filter((b) => b.type === "text").map((b) => b.text).join("");
|
|
7295
|
+
} else if (msg.content != null) {
|
|
7296
|
+
try {
|
|
7297
|
+
content = JSON.stringify(msg.content);
|
|
7298
|
+
} catch {
|
|
7299
|
+
content = String(msg.content);
|
|
7300
|
+
}
|
|
7301
|
+
}
|
|
7302
|
+
messages.push({ role: "user", content });
|
|
7303
|
+
} else if (msg.role === "assistant") {
|
|
7304
|
+
if (typeof msg.content === "string") {
|
|
7305
|
+
if (msg.content) {
|
|
7306
|
+
messages.push({ role: "assistant", content: msg.content });
|
|
7307
|
+
}
|
|
7308
|
+
} else if (Array.isArray(msg.content)) {
|
|
7309
|
+
const text = msg.content.filter((b) => b.type === "text").map((b) => b.text).join("");
|
|
7310
|
+
if (text) {
|
|
7311
|
+
messages.push({ role: "assistant", content: text });
|
|
7312
|
+
}
|
|
7313
|
+
}
|
|
7314
|
+
} else if (msg.role === "tool" && Array.isArray(msg.content)) {
|
|
7315
|
+
for (const block of msg.content) {
|
|
7316
|
+
const b = block;
|
|
7317
|
+
let content;
|
|
7318
|
+
if (typeof b.content === "string") {
|
|
7319
|
+
content = b.content;
|
|
7320
|
+
} else if (Array.isArray(b.content)) {
|
|
7321
|
+
content = b.content.filter((inner) => inner.type === "text").map((inner) => inner.text).join("");
|
|
7322
|
+
} else {
|
|
7323
|
+
content = "";
|
|
7324
|
+
}
|
|
7325
|
+
messages.push({ role: "tool", content });
|
|
7326
|
+
}
|
|
7327
|
+
}
|
|
7328
|
+
}
|
|
7329
|
+
return messages;
|
|
7330
|
+
}
|
|
6323
7331
|
|
|
6324
7332
|
// src/task/index.ts
|
|
6325
7333
|
var registerAiTasks = () => {
|
|
6326
7334
|
const tasks = [
|
|
7335
|
+
AgentTask,
|
|
6327
7336
|
BackgroundRemovalTask,
|
|
6328
7337
|
ChunkToVectorTask,
|
|
6329
7338
|
CountTokensTask,
|
|
@@ -6363,6 +7372,7 @@ var registerAiTasks = () => {
|
|
|
6363
7372
|
TextRewriterTask,
|
|
6364
7373
|
TextSummaryTask,
|
|
6365
7374
|
TextTranslationTask,
|
|
7375
|
+
ToolCallingTask,
|
|
6366
7376
|
TopicSegmenterTask,
|
|
6367
7377
|
UnloadModelTask,
|
|
6368
7378
|
VectorQuantizeTask,
|
|
@@ -6374,8 +7384,14 @@ var registerAiTasks = () => {
|
|
|
6374
7384
|
export {
|
|
6375
7385
|
vectorStoreSearch,
|
|
6376
7386
|
vectorQuantize,
|
|
7387
|
+
userMessage,
|
|
6377
7388
|
unloadModel,
|
|
6378
7389
|
topicSegmenter,
|
|
7390
|
+
toolSourceDefinitions,
|
|
7391
|
+
toolMessage,
|
|
7392
|
+
toolCalling,
|
|
7393
|
+
toTextFlatMessages,
|
|
7394
|
+
toOpenAIMessages,
|
|
6379
7395
|
textTranslation,
|
|
6380
7396
|
textSummary,
|
|
6381
7397
|
textRewriter,
|
|
@@ -6387,6 +7403,7 @@ export {
|
|
|
6387
7403
|
textEmbedding,
|
|
6388
7404
|
textClassification,
|
|
6389
7405
|
textChunker,
|
|
7406
|
+
taskTypesToTools,
|
|
6390
7407
|
structuredGeneration,
|
|
6391
7408
|
structuralParser,
|
|
6392
7409
|
similarity,
|
|
@@ -6400,27 +7417,42 @@ export {
|
|
|
6400
7417
|
objectDetection,
|
|
6401
7418
|
modelSearch,
|
|
6402
7419
|
modelInfo,
|
|
7420
|
+
isAllowedToolName,
|
|
6403
7421
|
imageToText,
|
|
6404
7422
|
imageSegmentation,
|
|
6405
7423
|
imageEmbedding,
|
|
6406
7424
|
imageClassification,
|
|
7425
|
+
imageBlockFromDataUri,
|
|
7426
|
+
imageBlock,
|
|
6407
7427
|
hybridSearch,
|
|
6408
7428
|
hierarchyJoin,
|
|
6409
7429
|
hierarchicalChunker,
|
|
7430
|
+
hasToolCalls,
|
|
6410
7431
|
handLandmarker,
|
|
6411
7432
|
getGlobalModelRepository,
|
|
6412
7433
|
getAiProviderRegistry,
|
|
6413
7434
|
gestureRecognizer,
|
|
7435
|
+
findToolSource,
|
|
7436
|
+
filterValidToolCalls,
|
|
6414
7437
|
faceLandmarker,
|
|
6415
7438
|
faceDetector,
|
|
7439
|
+
executeToolCalls,
|
|
7440
|
+
executeToolCall,
|
|
6416
7441
|
downloadModel,
|
|
6417
7442
|
documentEnricher,
|
|
6418
7443
|
countTokens,
|
|
7444
|
+
countAssistantToolUses,
|
|
6419
7445
|
contextBuilder,
|
|
6420
7446
|
chunkVectorUpsert,
|
|
6421
7447
|
chunkToVector,
|
|
6422
7448
|
chunkRetrieval,
|
|
7449
|
+
buildToolSources,
|
|
7450
|
+
buildToolDescription,
|
|
6423
7451
|
backgroundRemoval,
|
|
7452
|
+
audioBlockFromDataUri,
|
|
7453
|
+
audioBlock,
|
|
7454
|
+
assistantMessage,
|
|
7455
|
+
agent,
|
|
6424
7456
|
VectorSimilarityTask,
|
|
6425
7457
|
VectorQuantizeTask,
|
|
6426
7458
|
UnloadModelTask,
|
|
@@ -6434,6 +7466,10 @@ export {
|
|
|
6434
7466
|
TypeBoundingBox,
|
|
6435
7467
|
TypeAudioInput,
|
|
6436
7468
|
TopicSegmenterTask,
|
|
7469
|
+
ToolDefinitionSchema,
|
|
7470
|
+
ToolCallingTask,
|
|
7471
|
+
ToolCallingOutputSchema,
|
|
7472
|
+
ToolCallingInputSchema,
|
|
6437
7473
|
TextTranslationTask,
|
|
6438
7474
|
TextTranslationOutputSchema,
|
|
6439
7475
|
TextTranslationInputSchema,
|
|
@@ -6537,7 +7573,10 @@ export {
|
|
|
6537
7573
|
AiTask,
|
|
6538
7574
|
AiProviderRegistry,
|
|
6539
7575
|
AiProvider,
|
|
6540
|
-
AiJob
|
|
7576
|
+
AiJob,
|
|
7577
|
+
AgentTask,
|
|
7578
|
+
AgentOutputSchema,
|
|
7579
|
+
AgentInputSchema
|
|
6541
7580
|
};
|
|
6542
7581
|
|
|
6543
|
-
//# debugId=
|
|
7582
|
+
//# debugId=8A77F7A6C0C5C65D64756E2164756E21
|