@workglow/ai 0.1.2 → 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 +1422 -397
- package/dist/browser.js.map +64 -58
- package/dist/bun.js +1422 -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/node.js +1422 -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 -4
- 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 -4
- package/dist/task/ChunkToVectorTask.d.ts.map +1 -1
- package/dist/task/ChunkVectorHybridSearchTask.d.ts +6 -4
- package/dist/task/ChunkVectorHybridSearchTask.d.ts.map +1 -1
- package/dist/task/ChunkVectorSearchTask.d.ts +6 -4
- package/dist/task/ChunkVectorSearchTask.d.ts.map +1 -1
- package/dist/task/ChunkVectorUpsertTask.d.ts +6 -4
- package/dist/task/ChunkVectorUpsertTask.d.ts.map +1 -1
- package/dist/task/ContextBuilderTask.d.ts +6 -4
- package/dist/task/ContextBuilderTask.d.ts.map +1 -1
- package/dist/task/CountTokensTask.d.ts +6 -4
- package/dist/task/CountTokensTask.d.ts.map +1 -1
- package/dist/task/DocumentEnricherTask.d.ts +6 -4
- package/dist/task/DocumentEnricherTask.d.ts.map +1 -1
- package/dist/task/DownloadModelTask.d.ts +7 -5
- package/dist/task/DownloadModelTask.d.ts.map +1 -1
- package/dist/task/FaceDetectorTask.d.ts +6 -4
- package/dist/task/FaceDetectorTask.d.ts.map +1 -1
- package/dist/task/FaceLandmarkerTask.d.ts +6 -4
- package/dist/task/FaceLandmarkerTask.d.ts.map +1 -1
- package/dist/task/GestureRecognizerTask.d.ts +6 -4
- package/dist/task/GestureRecognizerTask.d.ts.map +1 -1
- package/dist/task/HandLandmarkerTask.d.ts +6 -4
- package/dist/task/HandLandmarkerTask.d.ts.map +1 -1
- package/dist/task/HierarchicalChunkerTask.d.ts +6 -4
- package/dist/task/HierarchicalChunkerTask.d.ts.map +1 -1
- package/dist/task/HierarchyJoinTask.d.ts +6 -4
- package/dist/task/HierarchyJoinTask.d.ts.map +1 -1
- package/dist/task/ImageClassificationTask.d.ts +6 -4
- package/dist/task/ImageClassificationTask.d.ts.map +1 -1
- package/dist/task/ImageEmbeddingTask.d.ts +6 -4
- package/dist/task/ImageEmbeddingTask.d.ts.map +1 -1
- package/dist/task/ImageSegmentationTask.d.ts +6 -4
- package/dist/task/ImageSegmentationTask.d.ts.map +1 -1
- package/dist/task/ImageToTextTask.d.ts +6 -4
- 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 -5
- package/dist/task/ModelInfoTask.d.ts.map +1 -1
- package/dist/task/ModelSearchTask.d.ts +6 -4
- package/dist/task/ModelSearchTask.d.ts.map +1 -1
- package/dist/task/ObjectDetectionTask.d.ts +6 -4
- package/dist/task/ObjectDetectionTask.d.ts.map +1 -1
- package/dist/task/PoseLandmarkerTask.d.ts +6 -4
- package/dist/task/PoseLandmarkerTask.d.ts.map +1 -1
- package/dist/task/QueryExpanderTask.d.ts +6 -4
- package/dist/task/QueryExpanderTask.d.ts.map +1 -1
- package/dist/task/RerankerTask.d.ts +6 -4
- package/dist/task/RerankerTask.d.ts.map +1 -1
- package/dist/task/StructuralParserTask.d.ts +6 -4
- package/dist/task/StructuralParserTask.d.ts.map +1 -1
- package/dist/task/StructuredGenerationTask.d.ts +6 -4
- package/dist/task/StructuredGenerationTask.d.ts.map +1 -1
- package/dist/task/TextChunkerTask.d.ts +6 -4
- package/dist/task/TextChunkerTask.d.ts.map +1 -1
- package/dist/task/TextClassificationTask.d.ts +6 -4
- package/dist/task/TextClassificationTask.d.ts.map +1 -1
- package/dist/task/TextEmbeddingTask.d.ts +6 -4
- package/dist/task/TextEmbeddingTask.d.ts.map +1 -1
- package/dist/task/TextFillMaskTask.d.ts +6 -4
- package/dist/task/TextFillMaskTask.d.ts.map +1 -1
- package/dist/task/TextGenerationTask.d.ts +6 -4
- package/dist/task/TextGenerationTask.d.ts.map +1 -1
- package/dist/task/TextLanguageDetectionTask.d.ts +6 -4
- package/dist/task/TextLanguageDetectionTask.d.ts.map +1 -1
- package/dist/task/TextNamedEntityRecognitionTask.d.ts +6 -4
- package/dist/task/TextNamedEntityRecognitionTask.d.ts.map +1 -1
- package/dist/task/TextQuestionAnswerTask.d.ts +6 -4
- package/dist/task/TextQuestionAnswerTask.d.ts.map +1 -1
- package/dist/task/TextRewriterTask.d.ts +6 -4
- package/dist/task/TextRewriterTask.d.ts.map +1 -1
- package/dist/task/TextSummaryTask.d.ts +6 -4
- package/dist/task/TextSummaryTask.d.ts.map +1 -1
- package/dist/task/TextTranslationTask.d.ts +6 -4
- 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 -4
- package/dist/task/TopicSegmenterTask.d.ts.map +1 -1
- package/dist/task/UnloadModelTask.d.ts +6 -4
- package/dist/task/UnloadModelTask.d.ts.map +1 -1
- package/dist/task/VectorQuantizeTask.d.ts +6 -4
- package/dist/task/VectorQuantizeTask.d.ts.map +1 -1
- package/dist/task/VectorSimilarityTask.d.ts +6 -4
- 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/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/bun.js
CHANGED
|
@@ -5,7 +5,8 @@ import {
|
|
|
5
5
|
Job,
|
|
6
6
|
JobStatus,
|
|
7
7
|
PermanentJobError,
|
|
8
|
-
RetryableJobError
|
|
8
|
+
RetryableJobError,
|
|
9
|
+
withJobErrorDiagnostics
|
|
9
10
|
} from "@workglow/job-queue";
|
|
10
11
|
import { getLogger } from "@workglow/util/worker";
|
|
11
12
|
|
|
@@ -138,16 +139,13 @@ function setAiProviderRegistry(pr) {
|
|
|
138
139
|
|
|
139
140
|
// src/job/AiJob.ts
|
|
140
141
|
var DEFAULT_AI_TIMEOUT_MS = 120000;
|
|
141
|
-
var
|
|
142
|
+
var LOCAL_INFERENCE_DEFAULT_TIMEOUT_MS = 300000;
|
|
142
143
|
function resolveAiJobTimeoutMs(aiProvider, explicitMs) {
|
|
143
144
|
if (explicitMs !== undefined) {
|
|
144
145
|
return explicitMs;
|
|
145
146
|
}
|
|
146
|
-
if (aiProvider === "LOCAL_LLAMACPP") {
|
|
147
|
-
return
|
|
148
|
-
}
|
|
149
|
-
if (aiProvider === "HF_TRANSFORMERS_ONNX" || aiProvider.startsWith("HF_TRANSFORMERS_ONNX")) {
|
|
150
|
-
return LOCAL_MODEL_DEFAULT_TIMEOUT_MS;
|
|
147
|
+
if (aiProvider === "LOCAL_LLAMACPP" || aiProvider === "HF_TRANSFORMERS_ONNX") {
|
|
148
|
+
return LOCAL_INFERENCE_DEFAULT_TIMEOUT_MS;
|
|
151
149
|
}
|
|
152
150
|
return DEFAULT_AI_TIMEOUT_MS;
|
|
153
151
|
}
|
|
@@ -160,39 +158,39 @@ function classifyProviderError(err, taskType, provider) {
|
|
|
160
158
|
const m = message.match(/\b([45]\d{2})\b/);
|
|
161
159
|
return m ? parseInt(m[1], 10) : undefined;
|
|
162
160
|
})();
|
|
163
|
-
if (err instanceof
|
|
164
|
-
return new AbortSignalJobError(`Provider call aborted for ${taskType} (${provider})
|
|
161
|
+
if (err instanceof Error && err.name === "AbortError") {
|
|
162
|
+
return new AbortSignalJobError(withJobErrorDiagnostics(`Provider call aborted for ${taskType} (${provider})`, err));
|
|
165
163
|
}
|
|
166
|
-
if (err instanceof
|
|
167
|
-
return new AbortSignalJobError(`Provider call timed out for ${taskType} (${provider})
|
|
164
|
+
if (err instanceof Error && err.name === "TimeoutError") {
|
|
165
|
+
return new AbortSignalJobError(withJobErrorDiagnostics(`Provider call timed out for ${taskType} (${provider})`, err));
|
|
168
166
|
}
|
|
169
167
|
if (message.includes("Pipeline download aborted") || message.includes("Operation aborted") || message.includes("operation was aborted") || message.includes("The operation was aborted")) {
|
|
170
|
-
return new AbortSignalJobError(`Provider call aborted for ${taskType} (${provider}): ${message}
|
|
168
|
+
return new AbortSignalJobError(withJobErrorDiagnostics(`Provider call aborted for ${taskType} (${provider}): ${message}`, err));
|
|
171
169
|
}
|
|
172
170
|
if (message.startsWith("HFT_NULL_PROCESSOR:")) {
|
|
173
|
-
return new RetryableJobError(message);
|
|
171
|
+
return new RetryableJobError(withJobErrorDiagnostics(message, err));
|
|
174
172
|
}
|
|
175
173
|
if (status === 429) {
|
|
176
174
|
const retryAfterMatch = message.match(/retry.after[:\s]*(\d+)/i);
|
|
177
175
|
const retryMs = retryAfterMatch ? parseInt(retryAfterMatch[1], 10) * 1000 : 30000;
|
|
178
|
-
return new RetryableJobError(`Rate limited by ${provider} for ${taskType}: ${message}`, new Date(Date.now() + retryMs));
|
|
176
|
+
return new RetryableJobError(withJobErrorDiagnostics(`Rate limited by ${provider} for ${taskType}: ${message}`, err), new Date(Date.now() + retryMs));
|
|
179
177
|
}
|
|
180
178
|
if (status === 401 || status === 403) {
|
|
181
|
-
return new PermanentJobError(`Authentication failed for ${provider} (${taskType}): ${message}
|
|
179
|
+
return new PermanentJobError(withJobErrorDiagnostics(`Authentication failed for ${provider} (${taskType}): ${message}`, err));
|
|
182
180
|
}
|
|
183
181
|
if (status === 400 || status === 404) {
|
|
184
|
-
return new PermanentJobError(`Invalid request to ${provider} for ${taskType}: ${message}
|
|
182
|
+
return new PermanentJobError(withJobErrorDiagnostics(`Invalid request to ${provider} for ${taskType}: ${message}`, err));
|
|
185
183
|
}
|
|
186
184
|
if (status && status >= 500) {
|
|
187
|
-
return new RetryableJobError(`Server error from ${provider} for ${taskType} (HTTP ${status}): ${message}
|
|
185
|
+
return new RetryableJobError(withJobErrorDiagnostics(`Server error from ${provider} for ${taskType} (HTTP ${status}): ${message}`, err));
|
|
188
186
|
}
|
|
189
187
|
if (message.includes("ECONNREFUSED") || message.includes("ECONNRESET") || message.includes("ETIMEDOUT") || message.includes("fetch failed") || message.includes("network") || err instanceof TypeError && message.includes("fetch")) {
|
|
190
|
-
return new RetryableJobError(`Network error calling ${provider} for ${taskType}: ${message}
|
|
188
|
+
return new RetryableJobError(withJobErrorDiagnostics(`Network error calling ${provider} for ${taskType}: ${message}`, err));
|
|
191
189
|
}
|
|
192
190
|
if (message.includes("timed out") || message.includes("timeout")) {
|
|
193
|
-
return new RetryableJobError(`Timeout calling ${provider} for ${taskType}: ${message}
|
|
191
|
+
return new RetryableJobError(withJobErrorDiagnostics(`Timeout calling ${provider} for ${taskType}: ${message}`, err));
|
|
194
192
|
}
|
|
195
|
-
return new PermanentJobError(`Provider ${provider} failed for ${taskType}: ${message}
|
|
193
|
+
return new PermanentJobError(withJobErrorDiagnostics(`Provider ${provider} failed for ${taskType}: ${message}`, err));
|
|
196
194
|
}
|
|
197
195
|
|
|
198
196
|
class AiJob extends Job {
|
|
@@ -298,12 +296,14 @@ class DirectExecutionStrategy {
|
|
|
298
296
|
}
|
|
299
297
|
|
|
300
298
|
// src/execution/QueuedExecutionStrategy.ts
|
|
301
|
-
import { ConcurrencyLimiter, JobQueueClient, JobQueueServer } from "@workglow/job-queue";
|
|
302
|
-
import { InMemoryQueueStorage } from "@workglow/storage";
|
|
303
299
|
import {
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
300
|
+
AbortSignalJobError as AbortSignalJobError2,
|
|
301
|
+
ConcurrencyLimiter,
|
|
302
|
+
JobQueueClient,
|
|
303
|
+
JobQueueServer
|
|
304
|
+
} from "@workglow/job-queue";
|
|
305
|
+
import { InMemoryQueueStorage } from "@workglow/storage";
|
|
306
|
+
import { getTaskQueueRegistry, TaskConfigurationError } from "@workglow/task-graph";
|
|
307
307
|
class QueuedExecutionStrategy {
|
|
308
308
|
queueName;
|
|
309
309
|
concurrency;
|
|
@@ -316,7 +316,7 @@ class QueuedExecutionStrategy {
|
|
|
316
316
|
}
|
|
317
317
|
async execute(jobInput, context, runnerId) {
|
|
318
318
|
if (context.signal.aborted) {
|
|
319
|
-
throw context.signal.reason ?? new
|
|
319
|
+
throw context.signal.reason ?? new AbortSignalJobError2("The operation was aborted");
|
|
320
320
|
}
|
|
321
321
|
const registeredQueue = await this.ensureQueue();
|
|
322
322
|
const { client } = registeredQueue;
|
|
@@ -335,7 +335,7 @@ class QueuedExecutionStrategy {
|
|
|
335
335
|
});
|
|
336
336
|
try {
|
|
337
337
|
if (context.signal.aborted) {
|
|
338
|
-
throw context.signal.reason ?? new
|
|
338
|
+
throw context.signal.reason ?? new AbortSignalJobError2("The operation was aborted");
|
|
339
339
|
}
|
|
340
340
|
const output = await handle.waitFor();
|
|
341
341
|
return output;
|
|
@@ -409,11 +409,101 @@ class QueuedExecutionStrategy {
|
|
|
409
409
|
}
|
|
410
410
|
}
|
|
411
411
|
|
|
412
|
+
// src/task/ToolCallingUtils.ts
|
|
413
|
+
import { getLogger as getLogger2 } from "@workglow/util/worker";
|
|
414
|
+
function buildToolDescription(tool) {
|
|
415
|
+
let desc = tool.description;
|
|
416
|
+
if (tool.outputSchema && typeof tool.outputSchema === "object") {
|
|
417
|
+
desc += `
|
|
418
|
+
|
|
419
|
+
Returns: ${JSON.stringify(tool.outputSchema)}`;
|
|
420
|
+
}
|
|
421
|
+
return desc;
|
|
422
|
+
}
|
|
423
|
+
function isAllowedToolName(name, allowedTools) {
|
|
424
|
+
return allowedTools.some((t) => t.name === name);
|
|
425
|
+
}
|
|
426
|
+
function filterValidToolCalls(toolCalls, allowedTools) {
|
|
427
|
+
return toolCalls.filter((tc) => {
|
|
428
|
+
if (tc.name && isAllowedToolName(tc.name, allowedTools)) {
|
|
429
|
+
return true;
|
|
430
|
+
}
|
|
431
|
+
getLogger2().warn(`Filtered out tool call with unknown name "${tc.name ?? "(missing)"}"`, {
|
|
432
|
+
callId: tc.id,
|
|
433
|
+
toolName: tc.name
|
|
434
|
+
});
|
|
435
|
+
return false;
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
|
|
412
439
|
// src/model/InMemoryModelRepository.ts
|
|
413
440
|
import { InMemoryTabularStorage } from "@workglow/storage";
|
|
414
441
|
|
|
415
442
|
// src/model/ModelRepository.ts
|
|
416
443
|
import { EventEmitter } from "@workglow/util";
|
|
444
|
+
import { compileSchema } from "@workglow/util/schema";
|
|
445
|
+
|
|
446
|
+
// src/model/ModelSchema.ts
|
|
447
|
+
var ModelConfigSchema = {
|
|
448
|
+
type: "object",
|
|
449
|
+
properties: {
|
|
450
|
+
model_id: { type: "string" },
|
|
451
|
+
tasks: { type: "array", items: { type: "string" }, "x-ui-editor": "multiselect" },
|
|
452
|
+
title: { type: "string" },
|
|
453
|
+
description: { type: "string", "x-ui-editor": "textarea" },
|
|
454
|
+
provider: { type: "string" },
|
|
455
|
+
provider_config: {
|
|
456
|
+
type: "object",
|
|
457
|
+
properties: {
|
|
458
|
+
credential_key: { type: "string", format: "credential", "x-ui-hidden": true }
|
|
459
|
+
},
|
|
460
|
+
additionalProperties: true,
|
|
461
|
+
default: {}
|
|
462
|
+
},
|
|
463
|
+
metadata: { type: "object", default: {}, "x-ui-hidden": true }
|
|
464
|
+
},
|
|
465
|
+
required: ["provider", "provider_config"],
|
|
466
|
+
format: "model",
|
|
467
|
+
additionalProperties: true
|
|
468
|
+
};
|
|
469
|
+
var ModelRecordSchema = {
|
|
470
|
+
type: "object",
|
|
471
|
+
properties: {
|
|
472
|
+
...ModelConfigSchema.properties
|
|
473
|
+
},
|
|
474
|
+
required: [
|
|
475
|
+
"model_id",
|
|
476
|
+
"tasks",
|
|
477
|
+
"provider",
|
|
478
|
+
"title",
|
|
479
|
+
"description",
|
|
480
|
+
"provider_config",
|
|
481
|
+
"metadata"
|
|
482
|
+
],
|
|
483
|
+
format: "model",
|
|
484
|
+
additionalProperties: false
|
|
485
|
+
};
|
|
486
|
+
var ModelPrimaryKeyNames = ["model_id"];
|
|
487
|
+
|
|
488
|
+
// src/model/ModelRepository.ts
|
|
489
|
+
var compiledModelRecordSchema;
|
|
490
|
+
function getModelRecordSchemaNode() {
|
|
491
|
+
if (!compiledModelRecordSchema) {
|
|
492
|
+
compiledModelRecordSchema = compileSchema(ModelRecordSchema);
|
|
493
|
+
}
|
|
494
|
+
return compiledModelRecordSchema;
|
|
495
|
+
}
|
|
496
|
+
function validateModelRecord(model) {
|
|
497
|
+
const schemaNode = getModelRecordSchemaNode();
|
|
498
|
+
const result = schemaNode.validate(model);
|
|
499
|
+
if (!result.valid) {
|
|
500
|
+
const errorMessages = result.errors.map((e) => {
|
|
501
|
+
const path = e.data?.pointer || "";
|
|
502
|
+
return `${e.message}${path ? ` (${path})` : ""}`;
|
|
503
|
+
});
|
|
504
|
+
throw new Error(`Invalid model record: ${errorMessages.join(", ")}`);
|
|
505
|
+
}
|
|
506
|
+
}
|
|
417
507
|
|
|
418
508
|
class ModelRepository {
|
|
419
509
|
modelTabularRepository;
|
|
@@ -437,10 +527,25 @@ class ModelRepository {
|
|
|
437
527
|
return this.events.waitOn(name);
|
|
438
528
|
}
|
|
439
529
|
async addModel(model) {
|
|
530
|
+
validateModelRecord(model);
|
|
531
|
+
const existing = await this.modelTabularRepository.get({ model_id: model.model_id });
|
|
532
|
+
if (existing) {
|
|
533
|
+
throw new Error(`Model with id "${model.model_id}" already exists`);
|
|
534
|
+
}
|
|
440
535
|
await this.modelTabularRepository.put(model);
|
|
441
536
|
this.events.emit("model_added", model);
|
|
442
537
|
return model;
|
|
443
538
|
}
|
|
539
|
+
async updateModel(model) {
|
|
540
|
+
validateModelRecord(model);
|
|
541
|
+
const existing = await this.modelTabularRepository.get({ model_id: model.model_id });
|
|
542
|
+
if (!existing) {
|
|
543
|
+
throw new Error(`Model with id "${model.model_id}" not found`);
|
|
544
|
+
}
|
|
545
|
+
await this.modelTabularRepository.put(model);
|
|
546
|
+
this.events.emit("model_updated", model);
|
|
547
|
+
return model;
|
|
548
|
+
}
|
|
444
549
|
async removeModel(model_id) {
|
|
445
550
|
const model = await this.modelTabularRepository.get({ model_id });
|
|
446
551
|
if (!model) {
|
|
@@ -499,48 +604,6 @@ class ModelRepository {
|
|
|
499
604
|
}
|
|
500
605
|
}
|
|
501
606
|
|
|
502
|
-
// src/model/ModelSchema.ts
|
|
503
|
-
var ModelConfigSchema = {
|
|
504
|
-
type: "object",
|
|
505
|
-
properties: {
|
|
506
|
-
model_id: { type: "string" },
|
|
507
|
-
tasks: { type: "array", items: { type: "string" }, "x-ui-editor": "multiselect" },
|
|
508
|
-
title: { type: "string" },
|
|
509
|
-
description: { type: "string", "x-ui-editor": "textarea" },
|
|
510
|
-
provider: { type: "string" },
|
|
511
|
-
provider_config: {
|
|
512
|
-
type: "object",
|
|
513
|
-
properties: {
|
|
514
|
-
credential_key: { type: "string", format: "credential", "x-ui-hidden": true }
|
|
515
|
-
},
|
|
516
|
-
additionalProperties: true,
|
|
517
|
-
default: {}
|
|
518
|
-
},
|
|
519
|
-
metadata: { type: "object", default: {}, "x-ui-hidden": true }
|
|
520
|
-
},
|
|
521
|
-
required: ["provider", "provider_config"],
|
|
522
|
-
format: "model",
|
|
523
|
-
additionalProperties: true
|
|
524
|
-
};
|
|
525
|
-
var ModelRecordSchema = {
|
|
526
|
-
type: "object",
|
|
527
|
-
properties: {
|
|
528
|
-
...ModelConfigSchema.properties
|
|
529
|
-
},
|
|
530
|
-
required: [
|
|
531
|
-
"model_id",
|
|
532
|
-
"tasks",
|
|
533
|
-
"provider",
|
|
534
|
-
"title",
|
|
535
|
-
"description",
|
|
536
|
-
"provider_config",
|
|
537
|
-
"metadata"
|
|
538
|
-
],
|
|
539
|
-
format: "model",
|
|
540
|
-
additionalProperties: false
|
|
541
|
-
};
|
|
542
|
-
var ModelPrimaryKeyNames = ["model_id"];
|
|
543
|
-
|
|
544
607
|
// src/model/InMemoryModelRepository.ts
|
|
545
608
|
class InMemoryModelRepository extends ModelRepository {
|
|
546
609
|
constructor() {
|
|
@@ -556,9 +619,7 @@ import {
|
|
|
556
619
|
registerInputResolver
|
|
557
620
|
} from "@workglow/util";
|
|
558
621
|
var MODEL_REPOSITORY = createServiceToken("model.repository");
|
|
559
|
-
|
|
560
|
-
globalServiceRegistry2.register(MODEL_REPOSITORY, () => new InMemoryModelRepository, true);
|
|
561
|
-
}
|
|
622
|
+
globalServiceRegistry2.registerIfAbsent(MODEL_REPOSITORY, () => new InMemoryModelRepository, true);
|
|
562
623
|
function getGlobalModelRepository() {
|
|
563
624
|
return globalServiceRegistry2.get(MODEL_REPOSITORY);
|
|
564
625
|
}
|
|
@@ -589,10 +650,7 @@ registerInputCompactor("model", async (value, _format, registry) => {
|
|
|
589
650
|
});
|
|
590
651
|
|
|
591
652
|
// src/provider/AiProvider.ts
|
|
592
|
-
import {
|
|
593
|
-
globalServiceRegistry as globalServiceRegistry3,
|
|
594
|
-
WORKER_MANAGER as WORKER_MANAGER2
|
|
595
|
-
} from "@workglow/util/worker";
|
|
653
|
+
import { globalServiceRegistry as globalServiceRegistry3, WORKER_MANAGER as WORKER_MANAGER2 } from "@workglow/util/worker";
|
|
596
654
|
function resolveAiProviderGpuQueueConcurrency(concurrency) {
|
|
597
655
|
if (concurrency === undefined) {
|
|
598
656
|
return 1;
|
|
@@ -712,8 +770,74 @@ class QueuedAiProvider extends AiProvider {
|
|
|
712
770
|
// src/task/index.ts
|
|
713
771
|
import { TaskRegistry } from "@workglow/task-graph";
|
|
714
772
|
|
|
715
|
-
// src/task/
|
|
716
|
-
import { CreateWorkflow, Workflow } from "@workglow/task-graph";
|
|
773
|
+
// src/task/AgentTask.ts
|
|
774
|
+
import { CreateWorkflow as CreateWorkflow2, Task as Task2, Workflow as Workflow2 } from "@workglow/task-graph";
|
|
775
|
+
import { getLogger as getLogger4 } from "@workglow/util";
|
|
776
|
+
|
|
777
|
+
// src/task/AgentTypes.ts
|
|
778
|
+
import { parseDataUri } from "@workglow/util/media";
|
|
779
|
+
function imageBlock(mimeType, data) {
|
|
780
|
+
return { type: "image", mimeType, data };
|
|
781
|
+
}
|
|
782
|
+
function audioBlock(mimeType, data) {
|
|
783
|
+
return { type: "audio", mimeType, data };
|
|
784
|
+
}
|
|
785
|
+
function imageBlockFromDataUri(dataUri) {
|
|
786
|
+
const { mimeType, base64 } = parseDataUri(dataUri);
|
|
787
|
+
return { type: "image", mimeType, data: base64 };
|
|
788
|
+
}
|
|
789
|
+
function audioBlockFromDataUri(dataUri) {
|
|
790
|
+
const { mimeType, base64 } = parseDataUri(dataUri);
|
|
791
|
+
return { type: "audio", mimeType, data: base64 };
|
|
792
|
+
}
|
|
793
|
+
function userMessage(prompt) {
|
|
794
|
+
return { role: "user", content: prompt };
|
|
795
|
+
}
|
|
796
|
+
function assistantMessage(text, toolCalls) {
|
|
797
|
+
const content = [];
|
|
798
|
+
if (text) {
|
|
799
|
+
content.push({ type: "text", text });
|
|
800
|
+
}
|
|
801
|
+
if (toolCalls) {
|
|
802
|
+
for (const tc of toolCalls) {
|
|
803
|
+
content.push({
|
|
804
|
+
type: "tool_use",
|
|
805
|
+
id: tc.id,
|
|
806
|
+
name: tc.name,
|
|
807
|
+
input: tc.input
|
|
808
|
+
});
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
return { role: "assistant", content };
|
|
812
|
+
}
|
|
813
|
+
function toolMessage(results) {
|
|
814
|
+
return {
|
|
815
|
+
role: "tool",
|
|
816
|
+
content: results.map((r) => {
|
|
817
|
+
const jsonText = JSON.stringify(r.output);
|
|
818
|
+
const content = r.mediaContent && r.mediaContent.length > 0 ? [{ type: "text", text: jsonText }, ...r.mediaContent] : jsonText;
|
|
819
|
+
return {
|
|
820
|
+
type: "tool_result",
|
|
821
|
+
tool_use_id: r.toolCallId,
|
|
822
|
+
content,
|
|
823
|
+
is_error: r.isError || undefined
|
|
824
|
+
};
|
|
825
|
+
})
|
|
826
|
+
};
|
|
827
|
+
}
|
|
828
|
+
function toolSourceDefinitions(sources) {
|
|
829
|
+
return sources.map((s) => s.definition);
|
|
830
|
+
}
|
|
831
|
+
function findToolSource(sources, name) {
|
|
832
|
+
return sources.find((s) => s.definition.name === name);
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
// src/task/AgentUtils.ts
|
|
836
|
+
import { getTaskConstructors as getTaskConstructors2, TaskAbortedError } from "@workglow/task-graph";
|
|
837
|
+
import { getLogger as getLogger3 } from "@workglow/util";
|
|
838
|
+
|
|
839
|
+
// src/task/ToolCallingTask.ts
|
|
840
|
+
import { CreateWorkflow, getTaskConstructors, Workflow } from "@workglow/task-graph";
|
|
717
841
|
|
|
718
842
|
// src/task/base/AiTaskSchemas.ts
|
|
719
843
|
var TypeLanguage = (annotations = {}) => ({
|
|
@@ -872,11 +996,12 @@ var TypeCategory = {
|
|
|
872
996
|
description: "Classification category with label and score"
|
|
873
997
|
};
|
|
874
998
|
|
|
875
|
-
// src/task/base/
|
|
876
|
-
import {
|
|
999
|
+
// src/task/base/StreamingAiTask.ts
|
|
1000
|
+
import { getStreamingPorts, TaskConfigurationError as TaskConfigurationError3 } from "@workglow/task-graph";
|
|
877
1001
|
|
|
878
1002
|
// src/task/base/AiTask.ts
|
|
879
1003
|
import {
|
|
1004
|
+
Entitlements,
|
|
880
1005
|
Task,
|
|
881
1006
|
TaskConfigSchema,
|
|
882
1007
|
TaskConfigurationError as TaskConfigurationError2,
|
|
@@ -895,6 +1020,27 @@ var aiTaskConfigSchema = {
|
|
|
895
1020
|
|
|
896
1021
|
class AiTask extends Task {
|
|
897
1022
|
static type = "AiTask";
|
|
1023
|
+
static hasDynamicEntitlements = true;
|
|
1024
|
+
static entitlements() {
|
|
1025
|
+
return {
|
|
1026
|
+
entitlements: [{ id: Entitlements.AI_INFERENCE, reason: "Runs AI model inference" }]
|
|
1027
|
+
};
|
|
1028
|
+
}
|
|
1029
|
+
entitlements() {
|
|
1030
|
+
const base = [
|
|
1031
|
+
{ id: Entitlements.AI_INFERENCE, reason: "Runs AI model inference" }
|
|
1032
|
+
];
|
|
1033
|
+
const runModel = this.runInputData?.model;
|
|
1034
|
+
const modelId = typeof runModel === "string" ? runModel : typeof this.defaults.model === "string" ? this.defaults.model : undefined;
|
|
1035
|
+
if (modelId) {
|
|
1036
|
+
base.push({
|
|
1037
|
+
id: Entitlements.AI_MODEL,
|
|
1038
|
+
reason: `Uses model ${modelId}`,
|
|
1039
|
+
resources: [modelId]
|
|
1040
|
+
});
|
|
1041
|
+
}
|
|
1042
|
+
return { entitlements: base };
|
|
1043
|
+
}
|
|
898
1044
|
static configSchema() {
|
|
899
1045
|
return aiTaskConfigSchema;
|
|
900
1046
|
}
|
|
@@ -957,71 +1103,773 @@ class AiTask extends Task {
|
|
|
957
1103
|
return reactiveFn(input, output, model);
|
|
958
1104
|
}
|
|
959
1105
|
}
|
|
960
|
-
return super.executeReactive(input, output, context);
|
|
1106
|
+
return super.executeReactive(input, output, context);
|
|
1107
|
+
}
|
|
1108
|
+
async validateInput(input) {
|
|
1109
|
+
const inputSchema = this.inputSchema();
|
|
1110
|
+
if (typeof inputSchema === "boolean") {
|
|
1111
|
+
if (inputSchema === false) {
|
|
1112
|
+
throw new TaskConfigurationError2(`AiTask: Input schema is 'false' and accepts no inputs`);
|
|
1113
|
+
}
|
|
1114
|
+
return true;
|
|
1115
|
+
}
|
|
1116
|
+
const modelTaskProperties = Object.entries(inputSchema.properties || {}).filter(([key, schema]) => schemaFormat(schema)?.startsWith("model:"));
|
|
1117
|
+
for (const [key] of modelTaskProperties) {
|
|
1118
|
+
const model = input[key];
|
|
1119
|
+
if (typeof model === "object" && model !== null) {
|
|
1120
|
+
const tasks = model.tasks;
|
|
1121
|
+
if (Array.isArray(tasks) && tasks.length > 0 && !tasks.includes(this.type)) {
|
|
1122
|
+
const modelId = model.model_id ?? "(inline config)";
|
|
1123
|
+
throw new TaskConfigurationError2(`AiTask: Model "${modelId}" for '${key}' is not compatible with task '${this.type}'. ` + `Model supports: [${tasks.join(", ")}]`);
|
|
1124
|
+
}
|
|
1125
|
+
} else if (model !== undefined && model !== null) {
|
|
1126
|
+
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.`);
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
const modelPlainProperties = Object.entries(inputSchema.properties || {}).filter(([key, schema]) => schemaFormat(schema) === "model");
|
|
1130
|
+
for (const [key] of modelPlainProperties) {
|
|
1131
|
+
const model = input[key];
|
|
1132
|
+
if (model !== undefined && model !== null && typeof model !== "object") {
|
|
1133
|
+
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.`);
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
return super.validateInput(input);
|
|
1137
|
+
}
|
|
1138
|
+
async narrowInput(input, registry) {
|
|
1139
|
+
const inputSchema = this.inputSchema();
|
|
1140
|
+
if (typeof inputSchema === "boolean") {
|
|
1141
|
+
if (inputSchema === false) {
|
|
1142
|
+
throw new TaskConfigurationError2(`AiTask: Input schema is 'false' and accepts no inputs`);
|
|
1143
|
+
}
|
|
1144
|
+
return input;
|
|
1145
|
+
}
|
|
1146
|
+
const modelTaskProperties = Object.entries(inputSchema.properties || {}).filter(([key, schema]) => schemaFormat(schema)?.startsWith("model:"));
|
|
1147
|
+
if (modelTaskProperties.length > 0) {
|
|
1148
|
+
const modelRepo = registry.get(MODEL_REPOSITORY);
|
|
1149
|
+
const taskModels = await modelRepo.findModelsByTask(this.type) ?? [];
|
|
1150
|
+
for (const [key, propSchema] of modelTaskProperties) {
|
|
1151
|
+
const requestedModel = input[key];
|
|
1152
|
+
if (typeof requestedModel === "string") {
|
|
1153
|
+
const found = taskModels?.find((m) => m.model_id === requestedModel);
|
|
1154
|
+
if (!found) {
|
|
1155
|
+
input[key] = undefined;
|
|
1156
|
+
}
|
|
1157
|
+
} else if (typeof requestedModel === "object" && requestedModel !== null) {
|
|
1158
|
+
const model = requestedModel;
|
|
1159
|
+
const tasks = model.tasks;
|
|
1160
|
+
if (Array.isArray(tasks) && tasks.length > 0 && !tasks.includes(this.type)) {
|
|
1161
|
+
input[key] = undefined;
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1166
|
+
return input;
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
|
|
1170
|
+
// src/task/base/StreamingAiTask.ts
|
|
1171
|
+
class StreamingAiTask extends AiTask {
|
|
1172
|
+
static type = "StreamingAiTask";
|
|
1173
|
+
async* executeStream(input, context) {
|
|
1174
|
+
const model = input.model;
|
|
1175
|
+
if (!model || typeof model !== "object") {
|
|
1176
|
+
throw new TaskConfigurationError3("StreamingAiTask: Model was not resolved to ModelConfig - this indicates a bug in the resolution system");
|
|
1177
|
+
}
|
|
1178
|
+
const jobInput = await this.getJobInput(input);
|
|
1179
|
+
const strategy = getAiProviderRegistry().getStrategy(model);
|
|
1180
|
+
const outSchema = this.outputSchema();
|
|
1181
|
+
const ports = getStreamingPorts(outSchema);
|
|
1182
|
+
let defaultPort = "text";
|
|
1183
|
+
if (ports.length > 0) {
|
|
1184
|
+
defaultPort = ports[0].port;
|
|
1185
|
+
} else {
|
|
1186
|
+
if (typeof outSchema === "object" && outSchema.properties) {
|
|
1187
|
+
const firstProp = Object.keys(outSchema.properties)[0];
|
|
1188
|
+
if (firstProp)
|
|
1189
|
+
defaultPort = firstProp;
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
for await (const event of strategy.executeStream(jobInput, context, this.runConfig.runnerId)) {
|
|
1193
|
+
if (event.type === "text-delta") {
|
|
1194
|
+
yield { ...event, port: event.port ?? defaultPort };
|
|
1195
|
+
} else if (event.type === "object-delta") {
|
|
1196
|
+
yield { ...event, port: event.port ?? defaultPort };
|
|
1197
|
+
} else {
|
|
1198
|
+
yield event;
|
|
1199
|
+
}
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1204
|
+
// src/task/ToolCallingTask.ts
|
|
1205
|
+
function taskTypesToTools(taskNames, registry) {
|
|
1206
|
+
const constructors = getTaskConstructors(registry);
|
|
1207
|
+
return taskNames.map((name) => {
|
|
1208
|
+
const ctor = constructors.get(name);
|
|
1209
|
+
if (!ctor) {
|
|
1210
|
+
throw new Error(`taskTypesToTools: Unknown task type "${name}" \u2014 not found in task constructors registry (ServiceRegistry: ${registry ? "custom" : "default"})`);
|
|
1211
|
+
}
|
|
1212
|
+
const configSchema = "configSchema" in ctor && typeof ctor.configSchema === "function" ? ctor.configSchema() : undefined;
|
|
1213
|
+
return {
|
|
1214
|
+
name: ctor.type,
|
|
1215
|
+
description: ctor.description ?? "",
|
|
1216
|
+
inputSchema: ctor.inputSchema(),
|
|
1217
|
+
outputSchema: ctor.outputSchema(),
|
|
1218
|
+
...configSchema ? { configSchema } : {},
|
|
1219
|
+
taskType: name
|
|
1220
|
+
};
|
|
1221
|
+
});
|
|
1222
|
+
}
|
|
1223
|
+
var ToolDefinitionSchema = {
|
|
1224
|
+
type: "object",
|
|
1225
|
+
properties: {
|
|
1226
|
+
name: {
|
|
1227
|
+
type: "string",
|
|
1228
|
+
title: "Name",
|
|
1229
|
+
description: "The tool name"
|
|
1230
|
+
},
|
|
1231
|
+
description: {
|
|
1232
|
+
type: "string",
|
|
1233
|
+
title: "Description",
|
|
1234
|
+
description: "A description of what the tool does"
|
|
1235
|
+
},
|
|
1236
|
+
inputSchema: {
|
|
1237
|
+
type: "object",
|
|
1238
|
+
title: "Input Schema",
|
|
1239
|
+
description: "JSON Schema describing the tool's input parameters",
|
|
1240
|
+
additionalProperties: true
|
|
1241
|
+
},
|
|
1242
|
+
outputSchema: {
|
|
1243
|
+
type: "object",
|
|
1244
|
+
title: "Output Schema",
|
|
1245
|
+
description: "JSON Schema describing what the tool returns",
|
|
1246
|
+
additionalProperties: true
|
|
1247
|
+
},
|
|
1248
|
+
configSchema: {
|
|
1249
|
+
type: "object",
|
|
1250
|
+
title: "Config Schema",
|
|
1251
|
+
description: "JSON Schema describing the task's configuration options (not sent to the LLM)",
|
|
1252
|
+
additionalProperties: true
|
|
1253
|
+
},
|
|
1254
|
+
config: {
|
|
1255
|
+
type: "object",
|
|
1256
|
+
title: "Config",
|
|
1257
|
+
description: "Concrete configuration values for the backing task (not sent to the LLM)",
|
|
1258
|
+
additionalProperties: true
|
|
1259
|
+
}
|
|
1260
|
+
},
|
|
1261
|
+
required: ["name", "description", "inputSchema"],
|
|
1262
|
+
additionalProperties: true
|
|
1263
|
+
};
|
|
1264
|
+
var ToolCallSchema = {
|
|
1265
|
+
type: "object",
|
|
1266
|
+
properties: {
|
|
1267
|
+
id: {
|
|
1268
|
+
type: "string",
|
|
1269
|
+
title: "ID",
|
|
1270
|
+
description: "Unique identifier for this tool call"
|
|
1271
|
+
},
|
|
1272
|
+
name: {
|
|
1273
|
+
type: "string",
|
|
1274
|
+
title: "Name",
|
|
1275
|
+
description: "The name of the tool to invoke"
|
|
1276
|
+
},
|
|
1277
|
+
input: {
|
|
1278
|
+
type: "object",
|
|
1279
|
+
title: "Input",
|
|
1280
|
+
description: "The input arguments for the tool call",
|
|
1281
|
+
additionalProperties: true
|
|
1282
|
+
}
|
|
1283
|
+
},
|
|
1284
|
+
required: ["id", "name", "input"],
|
|
1285
|
+
additionalProperties: false
|
|
1286
|
+
};
|
|
1287
|
+
var modelSchema = TypeModel("model:ToolCallingTask");
|
|
1288
|
+
var ToolCallingInputSchema = {
|
|
1289
|
+
type: "object",
|
|
1290
|
+
properties: {
|
|
1291
|
+
model: modelSchema,
|
|
1292
|
+
prompt: {
|
|
1293
|
+
oneOf: [
|
|
1294
|
+
{ type: "string", title: "Prompt", description: "The prompt to send to the model" },
|
|
1295
|
+
{
|
|
1296
|
+
type: "array",
|
|
1297
|
+
title: "Prompt",
|
|
1298
|
+
description: "The prompt as an array of strings or content blocks",
|
|
1299
|
+
items: {
|
|
1300
|
+
oneOf: [
|
|
1301
|
+
{ type: "string" },
|
|
1302
|
+
{
|
|
1303
|
+
type: "object",
|
|
1304
|
+
properties: {
|
|
1305
|
+
type: { type: "string", enum: ["text", "image", "audio"] }
|
|
1306
|
+
},
|
|
1307
|
+
required: ["type"],
|
|
1308
|
+
additionalProperties: true
|
|
1309
|
+
}
|
|
1310
|
+
]
|
|
1311
|
+
}
|
|
1312
|
+
}
|
|
1313
|
+
],
|
|
1314
|
+
title: "Prompt",
|
|
1315
|
+
description: "The prompt to send to the model"
|
|
1316
|
+
},
|
|
1317
|
+
systemPrompt: {
|
|
1318
|
+
type: "string",
|
|
1319
|
+
title: "System Prompt",
|
|
1320
|
+
description: "Optional system instructions for the model"
|
|
1321
|
+
},
|
|
1322
|
+
messages: {
|
|
1323
|
+
type: "array",
|
|
1324
|
+
title: "Messages",
|
|
1325
|
+
description: "Full conversation history for multi-turn interactions. When provided, used instead of prompt to construct the messages array sent to the provider.",
|
|
1326
|
+
items: {
|
|
1327
|
+
type: "object",
|
|
1328
|
+
properties: {
|
|
1329
|
+
role: { type: "string", enum: ["user", "assistant", "tool"] },
|
|
1330
|
+
content: {}
|
|
1331
|
+
},
|
|
1332
|
+
required: ["role", "content"],
|
|
1333
|
+
additionalProperties: true
|
|
1334
|
+
}
|
|
1335
|
+
},
|
|
1336
|
+
tools: {
|
|
1337
|
+
type: "array",
|
|
1338
|
+
format: "tasks",
|
|
1339
|
+
title: "Tools",
|
|
1340
|
+
description: "Tool definitions available for the model to call",
|
|
1341
|
+
items: {
|
|
1342
|
+
oneOf: [
|
|
1343
|
+
{ type: "string", format: "tasks", description: "Task type name" },
|
|
1344
|
+
ToolDefinitionSchema
|
|
1345
|
+
]
|
|
1346
|
+
}
|
|
1347
|
+
},
|
|
1348
|
+
toolChoice: {
|
|
1349
|
+
type: "string",
|
|
1350
|
+
title: "Tool Choice",
|
|
1351
|
+
description: 'Controls tool selection: "auto" (model decides), "none" (no tools), "required" (must call a tool), or a specific tool name',
|
|
1352
|
+
"x-ui-group": "Configuration"
|
|
1353
|
+
},
|
|
1354
|
+
maxTokens: {
|
|
1355
|
+
type: "number",
|
|
1356
|
+
title: "Max Tokens",
|
|
1357
|
+
description: "The maximum number of tokens to generate",
|
|
1358
|
+
minimum: 1,
|
|
1359
|
+
"x-ui-group": "Configuration"
|
|
1360
|
+
},
|
|
1361
|
+
temperature: {
|
|
1362
|
+
type: "number",
|
|
1363
|
+
title: "Temperature",
|
|
1364
|
+
description: "The temperature to use for sampling",
|
|
1365
|
+
minimum: 0,
|
|
1366
|
+
maximum: 2,
|
|
1367
|
+
"x-ui-group": "Configuration"
|
|
1368
|
+
}
|
|
1369
|
+
},
|
|
1370
|
+
required: ["model", "prompt", "tools"],
|
|
1371
|
+
additionalProperties: false
|
|
1372
|
+
};
|
|
1373
|
+
var ToolCallingOutputSchema = {
|
|
1374
|
+
type: "object",
|
|
1375
|
+
properties: {
|
|
1376
|
+
text: {
|
|
1377
|
+
type: "string",
|
|
1378
|
+
title: "Text",
|
|
1379
|
+
description: "Any text content generated by the model",
|
|
1380
|
+
"x-stream": "append"
|
|
1381
|
+
},
|
|
1382
|
+
toolCalls: {
|
|
1383
|
+
type: "array",
|
|
1384
|
+
items: ToolCallSchema,
|
|
1385
|
+
title: "Tool Calls",
|
|
1386
|
+
description: "Tool calls requested by the model",
|
|
1387
|
+
"x-stream": "object"
|
|
1388
|
+
}
|
|
1389
|
+
},
|
|
1390
|
+
required: ["text", "toolCalls"],
|
|
1391
|
+
additionalProperties: false
|
|
1392
|
+
};
|
|
1393
|
+
|
|
1394
|
+
class ToolCallingTask extends StreamingAiTask {
|
|
1395
|
+
static type = "ToolCallingTask";
|
|
1396
|
+
static category = "AI Text Model";
|
|
1397
|
+
static title = "Tool Calling";
|
|
1398
|
+
static description = "Sends a prompt with tool definitions to a language model and returns text along with any tool calls the model requests";
|
|
1399
|
+
static inputSchema() {
|
|
1400
|
+
return ToolCallingInputSchema;
|
|
1401
|
+
}
|
|
1402
|
+
static outputSchema() {
|
|
1403
|
+
return ToolCallingOutputSchema;
|
|
1404
|
+
}
|
|
1405
|
+
}
|
|
1406
|
+
var toolCalling = (input, config) => {
|
|
1407
|
+
return new ToolCallingTask(config).run(input);
|
|
1408
|
+
};
|
|
1409
|
+
Workflow.prototype.toolCalling = CreateWorkflow(ToolCallingTask);
|
|
1410
|
+
|
|
1411
|
+
// src/task/AgentUtils.ts
|
|
1412
|
+
function resolveToolConfig(toolName, config, taskConfigSchema) {
|
|
1413
|
+
if (config && !taskConfigSchema) {
|
|
1414
|
+
getLogger3().warn(`AgentTask: Tool "${toolName}" provided config but task has no configSchema \u2014 config ignored`);
|
|
1415
|
+
return {};
|
|
1416
|
+
}
|
|
1417
|
+
return config;
|
|
1418
|
+
}
|
|
1419
|
+
function buildToolSources(tools, registry) {
|
|
1420
|
+
if (!tools || tools.length === 0)
|
|
1421
|
+
return [];
|
|
1422
|
+
const stringNames = tools.filter((t) => typeof t === "string");
|
|
1423
|
+
const resolvedDefs = new Map(taskTypesToTools(stringNames, registry).map((d) => [d.taskType, d]));
|
|
1424
|
+
const constructors = getTaskConstructors2(registry);
|
|
1425
|
+
const sources = [];
|
|
1426
|
+
for (const tool of tools) {
|
|
1427
|
+
if (typeof tool === "string") {
|
|
1428
|
+
const def = resolvedDefs.get(tool);
|
|
1429
|
+
if (def) {
|
|
1430
|
+
const { taskType, ...definition } = def;
|
|
1431
|
+
sources.push({
|
|
1432
|
+
type: "registry",
|
|
1433
|
+
definition,
|
|
1434
|
+
taskType
|
|
1435
|
+
});
|
|
1436
|
+
}
|
|
1437
|
+
} else if (tool.type === "function" || !tool.type && tool.execute) {
|
|
1438
|
+
if (!tool.execute) {
|
|
1439
|
+
getLogger3().warn(`AgentTask: Tool "${tool.name}" has type "function" but no execute function \u2014 will throw on invocation`);
|
|
1440
|
+
}
|
|
1441
|
+
const { execute, configSchema: _cs, config: _c, type: _t, ...definition } = tool;
|
|
1442
|
+
sources.push({
|
|
1443
|
+
type: "function",
|
|
1444
|
+
definition,
|
|
1445
|
+
run: execute ?? (async () => {
|
|
1446
|
+
throw new Error(`No execute function for tool "${tool.name}"`);
|
|
1447
|
+
})
|
|
1448
|
+
});
|
|
1449
|
+
} else if (tool.type === "task") {
|
|
1450
|
+
const ctor = constructors.get(tool.name);
|
|
1451
|
+
if (!ctor) {
|
|
1452
|
+
getLogger3().warn(`AgentTask: Tool "${tool.name}" has type "task" but is not in TaskRegistry \u2014 will throw on invocation`);
|
|
1453
|
+
const { execute: _e, configSchema: _cs, config: _c, type: _t, ...definition } = tool;
|
|
1454
|
+
sources.push({
|
|
1455
|
+
type: "function",
|
|
1456
|
+
definition,
|
|
1457
|
+
run: async () => {
|
|
1458
|
+
throw new Error(`Task "${tool.name}" not found in TaskRegistry`);
|
|
1459
|
+
}
|
|
1460
|
+
});
|
|
1461
|
+
} else {
|
|
1462
|
+
const safeConfig = resolveToolConfig(tool.name, tool.config, ctor.configSchema?.());
|
|
1463
|
+
const { execute: _e, configSchema: _cs, config: _c, type: _t, ...definition } = tool;
|
|
1464
|
+
sources.push({
|
|
1465
|
+
type: "registry",
|
|
1466
|
+
definition,
|
|
1467
|
+
taskType: tool.name,
|
|
1468
|
+
config: safeConfig
|
|
1469
|
+
});
|
|
1470
|
+
}
|
|
1471
|
+
} else {
|
|
1472
|
+
const ctor = constructors.get(tool.name);
|
|
1473
|
+
if (ctor) {
|
|
1474
|
+
const safeConfig = resolveToolConfig(tool.name, tool.config, ctor.configSchema?.());
|
|
1475
|
+
const { execute: _e, configSchema: _cs, config: _c, type: _t, ...definition } = tool;
|
|
1476
|
+
sources.push({
|
|
1477
|
+
type: "registry",
|
|
1478
|
+
definition,
|
|
1479
|
+
taskType: tool.name,
|
|
1480
|
+
config: safeConfig
|
|
1481
|
+
});
|
|
1482
|
+
} else {
|
|
1483
|
+
const { execute: _e, configSchema: _cs, config: _c, type: _t, ...definition } = tool;
|
|
1484
|
+
sources.push({
|
|
1485
|
+
type: "function",
|
|
1486
|
+
definition,
|
|
1487
|
+
run: async () => {
|
|
1488
|
+
throw new Error(`No executor registered for tool "${tool.name}"`);
|
|
1489
|
+
}
|
|
1490
|
+
});
|
|
1491
|
+
}
|
|
1492
|
+
}
|
|
1493
|
+
}
|
|
1494
|
+
return sources;
|
|
1495
|
+
}
|
|
1496
|
+
async function executeToolCall(toolCall, sources, context, hooks) {
|
|
1497
|
+
const source = findToolSource(sources, toolCall.name);
|
|
1498
|
+
if (!source) {
|
|
1499
|
+
getLogger3().warn(`AgentTask: Unknown tool "${toolCall.name}" \u2014 not found in tool sources`);
|
|
1500
|
+
return {
|
|
1501
|
+
toolCallId: toolCall.id,
|
|
1502
|
+
toolName: toolCall.name,
|
|
1503
|
+
output: { error: `Unknown tool: ${toolCall.name}` },
|
|
1504
|
+
isError: true
|
|
1505
|
+
};
|
|
1506
|
+
}
|
|
1507
|
+
let effectiveCall = toolCall;
|
|
1508
|
+
if (hooks?.beforeToolCall) {
|
|
1509
|
+
const decision = await hooks.beforeToolCall(toolCall, source);
|
|
1510
|
+
if (decision.action === "deny") {
|
|
1511
|
+
return {
|
|
1512
|
+
toolCallId: toolCall.id,
|
|
1513
|
+
toolName: toolCall.name,
|
|
1514
|
+
output: { error: decision.reason ?? "Tool call denied by hook" },
|
|
1515
|
+
isError: true
|
|
1516
|
+
};
|
|
1517
|
+
}
|
|
1518
|
+
if (decision.action === "modify") {
|
|
1519
|
+
effectiveCall = { ...toolCall, input: decision.input };
|
|
1520
|
+
}
|
|
1521
|
+
}
|
|
1522
|
+
try {
|
|
1523
|
+
let output;
|
|
1524
|
+
switch (source.type) {
|
|
1525
|
+
case "registry": {
|
|
1526
|
+
const ctor = getTaskConstructors2(context.registry).get(source.taskType);
|
|
1527
|
+
if (!ctor) {
|
|
1528
|
+
throw new Error(`Task type "${source.taskType}" not found in TaskRegistry`);
|
|
1529
|
+
}
|
|
1530
|
+
const taskConfig = source.config ?? {};
|
|
1531
|
+
const task = context.own(new ctor({}, taskConfig));
|
|
1532
|
+
output = await task.run(effectiveCall.input) ?? {};
|
|
1533
|
+
break;
|
|
1534
|
+
}
|
|
1535
|
+
case "function": {
|
|
1536
|
+
output = await source.run(effectiveCall.input);
|
|
1537
|
+
break;
|
|
1538
|
+
}
|
|
1539
|
+
}
|
|
1540
|
+
let result = {
|
|
1541
|
+
toolCallId: toolCall.id,
|
|
1542
|
+
toolName: toolCall.name,
|
|
1543
|
+
output,
|
|
1544
|
+
isError: false
|
|
1545
|
+
};
|
|
1546
|
+
if (hooks?.afterToolCall) {
|
|
1547
|
+
result = await hooks.afterToolCall(toolCall, result);
|
|
1548
|
+
}
|
|
1549
|
+
return result;
|
|
1550
|
+
} catch (err) {
|
|
1551
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
1552
|
+
if (hooks?.onToolError) {
|
|
1553
|
+
const action = await hooks.onToolError(toolCall, error);
|
|
1554
|
+
if (action.action === "result") {
|
|
1555
|
+
return {
|
|
1556
|
+
toolCallId: toolCall.id,
|
|
1557
|
+
toolName: toolCall.name,
|
|
1558
|
+
output: action.output,
|
|
1559
|
+
isError: false
|
|
1560
|
+
};
|
|
1561
|
+
}
|
|
1562
|
+
}
|
|
1563
|
+
getLogger3().warn(`AgentTask: Tool "${toolCall.name}" failed: ${error.message}`);
|
|
1564
|
+
return {
|
|
1565
|
+
toolCallId: toolCall.id,
|
|
1566
|
+
toolName: toolCall.name,
|
|
1567
|
+
output: { error: error.message },
|
|
1568
|
+
isError: true
|
|
1569
|
+
};
|
|
1570
|
+
}
|
|
1571
|
+
}
|
|
1572
|
+
async function executeToolCalls(toolCalls, sources, context, hooks, maxConcurrency = 5) {
|
|
1573
|
+
const calls = toolCalls;
|
|
1574
|
+
if (calls.length === 0)
|
|
1575
|
+
return [];
|
|
1576
|
+
const concurrency = Math.max(1, Math.min(maxConcurrency, calls.length));
|
|
1577
|
+
const results = new Array(calls.length);
|
|
1578
|
+
let cursor = 0;
|
|
1579
|
+
const workers = Array.from({ length: concurrency }, async () => {
|
|
1580
|
+
while (true) {
|
|
1581
|
+
if (context.signal.aborted) {
|
|
1582
|
+
throw context.signal.reason ?? new TaskAbortedError("The operation was aborted");
|
|
1583
|
+
}
|
|
1584
|
+
const position = cursor;
|
|
1585
|
+
cursor += 1;
|
|
1586
|
+
if (position >= calls.length)
|
|
1587
|
+
return;
|
|
1588
|
+
results[position] = await executeToolCall(calls[position], sources, context, hooks);
|
|
1589
|
+
}
|
|
1590
|
+
});
|
|
1591
|
+
await Promise.all(workers);
|
|
1592
|
+
return results;
|
|
1593
|
+
}
|
|
1594
|
+
function hasToolCalls(toolCalls) {
|
|
1595
|
+
return toolCalls !== undefined && toolCalls.length > 0;
|
|
1596
|
+
}
|
|
1597
|
+
function countAssistantToolUses(messages) {
|
|
1598
|
+
let n = 0;
|
|
1599
|
+
for (const m of messages) {
|
|
1600
|
+
if (m.role !== "assistant")
|
|
1601
|
+
continue;
|
|
1602
|
+
for (const block of m.content) {
|
|
1603
|
+
if (block.type === "tool_use")
|
|
1604
|
+
n += 1;
|
|
1605
|
+
}
|
|
1606
|
+
}
|
|
1607
|
+
return n;
|
|
1608
|
+
}
|
|
1609
|
+
|
|
1610
|
+
// src/task/AgentTask.ts
|
|
1611
|
+
var MAX_CONTEXT_MESSAGES = 1000;
|
|
1612
|
+
var modelSchema2 = TypeModel("model:ToolCallingTask");
|
|
1613
|
+
var AgentInputSchema = {
|
|
1614
|
+
type: "object",
|
|
1615
|
+
properties: {
|
|
1616
|
+
model: modelSchema2,
|
|
1617
|
+
prompt: {
|
|
1618
|
+
oneOf: [
|
|
1619
|
+
{ type: "string" },
|
|
1620
|
+
{
|
|
1621
|
+
type: "array",
|
|
1622
|
+
items: {
|
|
1623
|
+
type: "object",
|
|
1624
|
+
properties: {
|
|
1625
|
+
type: { type: "string", enum: ["text", "image", "audio"] }
|
|
1626
|
+
},
|
|
1627
|
+
required: ["type"],
|
|
1628
|
+
additionalProperties: true
|
|
1629
|
+
}
|
|
1630
|
+
}
|
|
1631
|
+
],
|
|
1632
|
+
title: "Prompt",
|
|
1633
|
+
description: "The user prompt to start the agent loop. Can be a string or an array of content blocks (text, image, audio)."
|
|
1634
|
+
},
|
|
1635
|
+
systemPrompt: {
|
|
1636
|
+
type: "string",
|
|
1637
|
+
title: "System Prompt",
|
|
1638
|
+
description: "Optional system instructions for the agent"
|
|
1639
|
+
},
|
|
1640
|
+
tools: {
|
|
1641
|
+
type: "array",
|
|
1642
|
+
format: "tasks",
|
|
1643
|
+
title: "Tools",
|
|
1644
|
+
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.",
|
|
1645
|
+
items: {
|
|
1646
|
+
oneOf: [
|
|
1647
|
+
{ type: "string", format: "tasks", description: "Task type name" },
|
|
1648
|
+
ToolDefinitionSchema
|
|
1649
|
+
]
|
|
1650
|
+
}
|
|
1651
|
+
},
|
|
1652
|
+
stopTool: {
|
|
1653
|
+
type: "string",
|
|
1654
|
+
title: "Stop Tool",
|
|
1655
|
+
description: "Name of a tool that signals agent completion. When called, the loop ends and the tool input becomes structuredOutput.",
|
|
1656
|
+
"x-ui-group": "Configuration"
|
|
1657
|
+
},
|
|
1658
|
+
maxIterations: {
|
|
1659
|
+
type: "number",
|
|
1660
|
+
title: "Max Iterations",
|
|
1661
|
+
description: "Maximum number of agent loop iterations (default: 10)",
|
|
1662
|
+
minimum: 1,
|
|
1663
|
+
"x-ui-group": "Configuration"
|
|
1664
|
+
},
|
|
1665
|
+
maxContextMessages: {
|
|
1666
|
+
type: "number",
|
|
1667
|
+
title: "Max Context Messages",
|
|
1668
|
+
description: "Maximum messages in conversation history. Older messages are trimmed to prevent context overflow.",
|
|
1669
|
+
minimum: 3,
|
|
1670
|
+
"x-ui-group": "Configuration"
|
|
1671
|
+
},
|
|
1672
|
+
maxTokens: {
|
|
1673
|
+
type: "number",
|
|
1674
|
+
title: "Max Tokens",
|
|
1675
|
+
description: "Maximum tokens per LLM call",
|
|
1676
|
+
minimum: 1,
|
|
1677
|
+
"x-ui-group": "Configuration"
|
|
1678
|
+
},
|
|
1679
|
+
temperature: {
|
|
1680
|
+
type: "number",
|
|
1681
|
+
title: "Temperature",
|
|
1682
|
+
description: "Sampling temperature for LLM calls",
|
|
1683
|
+
minimum: 0,
|
|
1684
|
+
maximum: 2,
|
|
1685
|
+
"x-ui-group": "Configuration"
|
|
1686
|
+
}
|
|
1687
|
+
},
|
|
1688
|
+
required: ["model", "prompt"],
|
|
1689
|
+
additionalProperties: false
|
|
1690
|
+
};
|
|
1691
|
+
var AgentOutputSchema = {
|
|
1692
|
+
type: "object",
|
|
1693
|
+
properties: {
|
|
1694
|
+
text: {
|
|
1695
|
+
type: "string",
|
|
1696
|
+
title: "Text",
|
|
1697
|
+
description: "The final text response from the agent",
|
|
1698
|
+
"x-stream": "append"
|
|
1699
|
+
},
|
|
1700
|
+
messages: {
|
|
1701
|
+
type: "array",
|
|
1702
|
+
title: "Messages",
|
|
1703
|
+
description: "Full conversation history including all tool calls and results",
|
|
1704
|
+
items: {
|
|
1705
|
+
type: "object",
|
|
1706
|
+
additionalProperties: true
|
|
1707
|
+
}
|
|
1708
|
+
},
|
|
1709
|
+
iterations: {
|
|
1710
|
+
type: "number",
|
|
1711
|
+
title: "Iterations",
|
|
1712
|
+
description: "Number of LLM calls made during the agent loop"
|
|
1713
|
+
},
|
|
1714
|
+
toolCallCount: {
|
|
1715
|
+
type: "number",
|
|
1716
|
+
title: "Tool Call Count",
|
|
1717
|
+
description: "Total number of tool calls the assistant requested (tool_use blocks in assistant messages)"
|
|
1718
|
+
},
|
|
1719
|
+
structuredOutput: {
|
|
1720
|
+
type: "object",
|
|
1721
|
+
title: "Structured Output",
|
|
1722
|
+
description: "Present when the agent terminated via a stop tool",
|
|
1723
|
+
additionalProperties: true
|
|
1724
|
+
}
|
|
1725
|
+
},
|
|
1726
|
+
required: ["text", "messages", "iterations", "toolCallCount"],
|
|
1727
|
+
additionalProperties: false
|
|
1728
|
+
};
|
|
1729
|
+
|
|
1730
|
+
class AgentTask extends Task2 {
|
|
1731
|
+
static type = "AgentTask";
|
|
1732
|
+
static category = "AI Agent";
|
|
1733
|
+
static title = "Agent";
|
|
1734
|
+
static description = "Multi-turn agentic loop that calls an LLM with tools, executes tool calls, and iterates until done";
|
|
1735
|
+
static cacheable = false;
|
|
1736
|
+
static inputSchema() {
|
|
1737
|
+
return AgentInputSchema;
|
|
961
1738
|
}
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
const modelTaskProperties = Object.entries(inputSchema.properties || {}).filter(([key, schema]) => schemaFormat(schema)?.startsWith("model:"));
|
|
971
|
-
for (const [key] of modelTaskProperties) {
|
|
972
|
-
const model = input[key];
|
|
973
|
-
if (typeof model === "object" && model !== null) {
|
|
974
|
-
const tasks = model.tasks;
|
|
975
|
-
if (Array.isArray(tasks) && tasks.length > 0 && !tasks.includes(this.type)) {
|
|
976
|
-
const modelId = model.model_id ?? "(inline config)";
|
|
977
|
-
throw new TaskConfigurationError2(`AiTask: Model "${modelId}" for '${key}' is not compatible with task '${this.type}'. ` + `Model supports: [${tasks.join(", ")}]`);
|
|
978
|
-
}
|
|
979
|
-
} else if (model !== undefined && model !== null) {
|
|
980
|
-
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.`);
|
|
1739
|
+
static outputSchema() {
|
|
1740
|
+
return AgentOutputSchema;
|
|
1741
|
+
}
|
|
1742
|
+
async execute(input, context) {
|
|
1743
|
+
let result;
|
|
1744
|
+
for await (const event of this.agentLoop(input, context)) {
|
|
1745
|
+
if (event.type === "finish") {
|
|
1746
|
+
result = event.data;
|
|
981
1747
|
}
|
|
982
1748
|
}
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
const model = input[key];
|
|
986
|
-
if (model !== undefined && model !== null && typeof model !== "object") {
|
|
987
|
-
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.`);
|
|
988
|
-
}
|
|
1749
|
+
if (!result) {
|
|
1750
|
+
throw new Error("AgentTask: loop ended without producing output");
|
|
989
1751
|
}
|
|
990
|
-
return
|
|
1752
|
+
return result;
|
|
991
1753
|
}
|
|
992
|
-
async
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
1754
|
+
async* executeStream(input, context) {
|
|
1755
|
+
yield* this.agentLoop(input, context);
|
|
1756
|
+
}
|
|
1757
|
+
async* agentLoop(input, context) {
|
|
1758
|
+
const maxIterations = input.maxIterations ?? 10;
|
|
1759
|
+
const hooks = this.config.hooks;
|
|
1760
|
+
const maxConcurrency = this.config.maxConcurrency ?? 5;
|
|
1761
|
+
const toolSources = this.resolveToolSources(input, context);
|
|
1762
|
+
const toolDefs = this.resolveToolDefs(toolSources, input.stopTool);
|
|
1763
|
+
const messages = [userMessage(input.prompt)];
|
|
1764
|
+
let finalText = "";
|
|
1765
|
+
let structuredOutput;
|
|
1766
|
+
for (let iteration = 0;iteration < maxIterations; iteration++) {
|
|
1767
|
+
if (context.signal.aborted)
|
|
1768
|
+
break;
|
|
1769
|
+
if (hooks?.onIteration) {
|
|
1770
|
+
const action = await hooks.onIteration(iteration, messages, {
|
|
1771
|
+
totalToolCalls: countAssistantToolUses(messages)
|
|
1772
|
+
});
|
|
1773
|
+
if (action.action === "stop")
|
|
1774
|
+
break;
|
|
997
1775
|
}
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
const
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1776
|
+
await context.updateProgress(Math.round(iteration / maxIterations * 100), `Agent iteration ${iteration + 1}`);
|
|
1777
|
+
const contextMessages = this.trimMessages(messages, input.maxContextMessages ?? MAX_CONTEXT_MESSAGES);
|
|
1778
|
+
const llmTask = context.own(new ToolCallingTask);
|
|
1779
|
+
let iterationText = "";
|
|
1780
|
+
let toolCalls = [];
|
|
1781
|
+
for await (const event of llmTask.executeStream({
|
|
1782
|
+
model: input.model,
|
|
1783
|
+
prompt: input.prompt,
|
|
1784
|
+
systemPrompt: input.systemPrompt,
|
|
1785
|
+
tools: toolDefs,
|
|
1786
|
+
messages: contextMessages,
|
|
1787
|
+
maxTokens: input.maxTokens,
|
|
1788
|
+
temperature: input.temperature
|
|
1789
|
+
}, context)) {
|
|
1790
|
+
if (event.type === "text-delta") {
|
|
1791
|
+
yield { type: "text-delta", port: "text", textDelta: event.textDelta };
|
|
1792
|
+
iterationText += event.textDelta;
|
|
1793
|
+
} else if (event.type === "object-delta" && event.port === "toolCalls") {
|
|
1794
|
+
const items = event.objectDelta;
|
|
1795
|
+
for (const item of items) {
|
|
1796
|
+
const idx = toolCalls.findIndex((tc) => tc.id === item.id);
|
|
1797
|
+
if (idx >= 0)
|
|
1798
|
+
toolCalls[idx] = item;
|
|
1799
|
+
else
|
|
1800
|
+
toolCalls.push(item);
|
|
1010
1801
|
}
|
|
1011
|
-
} else if (
|
|
1012
|
-
const
|
|
1013
|
-
|
|
1014
|
-
if (
|
|
1015
|
-
|
|
1802
|
+
} else if (event.type === "finish") {
|
|
1803
|
+
const data = event.data;
|
|
1804
|
+
iterationText = data?.text ?? iterationText;
|
|
1805
|
+
if (data?.toolCalls && data.toolCalls.length > 0) {
|
|
1806
|
+
toolCalls = data.toolCalls;
|
|
1016
1807
|
}
|
|
1017
1808
|
}
|
|
1018
1809
|
}
|
|
1810
|
+
finalText = iterationText;
|
|
1811
|
+
messages.push(assistantMessage(iterationText, toolCalls));
|
|
1812
|
+
if (input.stopTool) {
|
|
1813
|
+
const stopCall = toolCalls.find((tc) => tc.name === input.stopTool);
|
|
1814
|
+
if (stopCall) {
|
|
1815
|
+
structuredOutput = stopCall.input;
|
|
1816
|
+
break;
|
|
1817
|
+
}
|
|
1818
|
+
}
|
|
1819
|
+
if (!hasToolCalls(toolCalls)) {
|
|
1820
|
+
break;
|
|
1821
|
+
}
|
|
1822
|
+
const results = await executeToolCalls(toolCalls, toolSources, context, hooks, maxConcurrency);
|
|
1823
|
+
messages.push(toolMessage(results));
|
|
1019
1824
|
}
|
|
1020
|
-
|
|
1825
|
+
const output = {
|
|
1826
|
+
text: finalText,
|
|
1827
|
+
messages,
|
|
1828
|
+
iterations: messages.filter((m) => m.role === "assistant").length,
|
|
1829
|
+
toolCallCount: countAssistantToolUses(messages),
|
|
1830
|
+
...structuredOutput !== undefined ? { structuredOutput } : {}
|
|
1831
|
+
};
|
|
1832
|
+
yield { type: "finish", data: output };
|
|
1833
|
+
}
|
|
1834
|
+
resolveToolSources(input, context) {
|
|
1835
|
+
return buildToolSources(input.tools, context.registry);
|
|
1836
|
+
}
|
|
1837
|
+
resolveToolDefs(toolSources, stopTool) {
|
|
1838
|
+
const defs = toolSourceDefinitions(toolSources);
|
|
1839
|
+
if (stopTool && !defs.some((d) => d.name === stopTool)) {
|
|
1840
|
+
defs.push({
|
|
1841
|
+
name: stopTool,
|
|
1842
|
+
description: "Call this tool when you have completed the task. Pass your final structured result as the input.",
|
|
1843
|
+
inputSchema: { type: "object", additionalProperties: true }
|
|
1844
|
+
});
|
|
1845
|
+
}
|
|
1846
|
+
return defs;
|
|
1847
|
+
}
|
|
1848
|
+
trimMessages(messages, maxContextMessages) {
|
|
1849
|
+
if (!maxContextMessages || messages.length <= maxContextMessages) {
|
|
1850
|
+
return messages;
|
|
1851
|
+
}
|
|
1852
|
+
getLogger4().debug(`AgentTask: Trimming context from ${messages.length} to ${maxContextMessages} messages`);
|
|
1853
|
+
const tail = messages.slice(1);
|
|
1854
|
+
let startIdx = tail.length - (maxContextMessages - 1);
|
|
1855
|
+
if (startIdx < 0)
|
|
1856
|
+
startIdx = 0;
|
|
1857
|
+
while (startIdx > 0 && startIdx < tail.length && tail[startIdx].role === "tool") {
|
|
1858
|
+
startIdx -= 1;
|
|
1859
|
+
}
|
|
1860
|
+
return [messages[0], ...tail.slice(startIdx)];
|
|
1021
1861
|
}
|
|
1022
1862
|
}
|
|
1863
|
+
var agent = (input, config) => {
|
|
1864
|
+
return new AgentTask(config).run(input);
|
|
1865
|
+
};
|
|
1866
|
+
Workflow2.prototype.agent = CreateWorkflow2(AgentTask);
|
|
1867
|
+
|
|
1868
|
+
// src/task/BackgroundRemovalTask.ts
|
|
1869
|
+
import { CreateWorkflow as CreateWorkflow3, Workflow as Workflow3 } from "@workglow/task-graph";
|
|
1023
1870
|
|
|
1024
1871
|
// src/task/base/AiVisionTask.ts
|
|
1872
|
+
import { convertImageDataToUseableForm } from "@workglow/util/media";
|
|
1025
1873
|
class AiVisionTask extends AiTask {
|
|
1026
1874
|
static type = "AiVisionTask";
|
|
1027
1875
|
async getJobInput(input) {
|
|
@@ -1042,7 +1890,7 @@ class AiVisionTask extends AiTask {
|
|
|
1042
1890
|
}
|
|
1043
1891
|
|
|
1044
1892
|
// src/task/BackgroundRemovalTask.ts
|
|
1045
|
-
var
|
|
1893
|
+
var modelSchema3 = TypeModel("model:BackgroundRemovalTask");
|
|
1046
1894
|
var processedImageSchema = {
|
|
1047
1895
|
type: "string",
|
|
1048
1896
|
contentEncoding: "base64",
|
|
@@ -1054,7 +1902,7 @@ var BackgroundRemovalInputSchema = {
|
|
|
1054
1902
|
type: "object",
|
|
1055
1903
|
properties: {
|
|
1056
1904
|
image: TypeImageInput,
|
|
1057
|
-
model:
|
|
1905
|
+
model: modelSchema3
|
|
1058
1906
|
},
|
|
1059
1907
|
required: ["image", "model"],
|
|
1060
1908
|
additionalProperties: false
|
|
@@ -1081,24 +1929,24 @@ class BackgroundRemovalTask extends AiVisionTask {
|
|
|
1081
1929
|
}
|
|
1082
1930
|
}
|
|
1083
1931
|
var backgroundRemoval = (input, config) => {
|
|
1084
|
-
return new BackgroundRemovalTask(
|
|
1932
|
+
return new BackgroundRemovalTask(config).run(input);
|
|
1085
1933
|
};
|
|
1086
|
-
|
|
1934
|
+
Workflow3.prototype.backgroundRemoval = CreateWorkflow3(BackgroundRemovalTask);
|
|
1087
1935
|
|
|
1088
1936
|
// src/task/ChunkRetrievalTask.ts
|
|
1089
1937
|
import { TypeKnowledgeBase } from "@workglow/knowledge-base";
|
|
1090
|
-
import { CreateWorkflow as
|
|
1938
|
+
import { CreateWorkflow as CreateWorkflow5, Task as Task3, Workflow as Workflow5 } from "@workglow/task-graph";
|
|
1091
1939
|
import {
|
|
1092
1940
|
isTypedArray,
|
|
1093
1941
|
TypedArraySchema as TypedArraySchema2
|
|
1094
1942
|
} from "@workglow/util/schema";
|
|
1095
1943
|
|
|
1096
1944
|
// src/task/TextEmbeddingTask.ts
|
|
1097
|
-
import { CreateWorkflow as
|
|
1945
|
+
import { CreateWorkflow as CreateWorkflow4, Workflow as Workflow4 } from "@workglow/task-graph";
|
|
1098
1946
|
import {
|
|
1099
1947
|
TypedArraySchema
|
|
1100
1948
|
} from "@workglow/util/schema";
|
|
1101
|
-
var
|
|
1949
|
+
var modelSchema4 = TypeModel("model:TextEmbeddingTask");
|
|
1102
1950
|
var TextEmbeddingInputSchema = {
|
|
1103
1951
|
type: "object",
|
|
1104
1952
|
properties: {
|
|
@@ -1107,7 +1955,7 @@ var TextEmbeddingInputSchema = {
|
|
|
1107
1955
|
title: "Text",
|
|
1108
1956
|
description: "The text to embed"
|
|
1109
1957
|
}),
|
|
1110
|
-
model:
|
|
1958
|
+
model: modelSchema4
|
|
1111
1959
|
},
|
|
1112
1960
|
required: ["text", "model"],
|
|
1113
1961
|
additionalProperties: false
|
|
@@ -1137,9 +1985,9 @@ class TextEmbeddingTask extends AiTask {
|
|
|
1137
1985
|
}
|
|
1138
1986
|
}
|
|
1139
1987
|
var textEmbedding = async (input, config) => {
|
|
1140
|
-
return new TextEmbeddingTask(
|
|
1988
|
+
return new TextEmbeddingTask(config).run(input);
|
|
1141
1989
|
};
|
|
1142
|
-
|
|
1990
|
+
Workflow4.prototype.textEmbedding = CreateWorkflow4(TextEmbeddingTask);
|
|
1143
1991
|
|
|
1144
1992
|
// src/task/ChunkRetrievalTask.ts
|
|
1145
1993
|
var inputSchema = {
|
|
@@ -1264,7 +2112,7 @@ var outputSchema = {
|
|
|
1264
2112
|
additionalProperties: false
|
|
1265
2113
|
};
|
|
1266
2114
|
|
|
1267
|
-
class ChunkRetrievalTask extends
|
|
2115
|
+
class ChunkRetrievalTask extends Task3 {
|
|
1268
2116
|
static type = "ChunkRetrievalTask";
|
|
1269
2117
|
static category = "RAG";
|
|
1270
2118
|
static title = "Chunk Retrieval";
|
|
@@ -1292,8 +2140,8 @@ class ChunkRetrievalTask extends Task2 {
|
|
|
1292
2140
|
if (!model) {
|
|
1293
2141
|
throw new Error("Model is required when query is a string. Please provide a model with format 'model:TextEmbeddingTask'.");
|
|
1294
2142
|
}
|
|
1295
|
-
const embeddingTask = context.own(new TextEmbeddingTask
|
|
1296
|
-
const embeddingResult = await embeddingTask.run();
|
|
2143
|
+
const embeddingTask = context.own(new TextEmbeddingTask);
|
|
2144
|
+
const embeddingResult = await embeddingTask.run({ text: query, model });
|
|
1297
2145
|
queryVectors = Array.isArray(embeddingResult.vector) ? embeddingResult.vector : [embeddingResult.vector];
|
|
1298
2146
|
} else if (isTypedArray(query) || Array.isArray(query) && query.every(isTypedArray)) {
|
|
1299
2147
|
queryVectors = Array.isArray(query) ? query : [query];
|
|
@@ -1329,13 +2177,13 @@ class ChunkRetrievalTask extends Task2 {
|
|
|
1329
2177
|
}
|
|
1330
2178
|
}
|
|
1331
2179
|
var chunkRetrieval = (input, config) => {
|
|
1332
|
-
return new ChunkRetrievalTask(
|
|
2180
|
+
return new ChunkRetrievalTask(config).run(input);
|
|
1333
2181
|
};
|
|
1334
|
-
|
|
2182
|
+
Workflow5.prototype.chunkRetrieval = CreateWorkflow5(ChunkRetrievalTask);
|
|
1335
2183
|
|
|
1336
2184
|
// src/task/ChunkToVectorTask.ts
|
|
1337
2185
|
import { ChunkRecordSchema } from "@workglow/knowledge-base";
|
|
1338
|
-
import { CreateWorkflow as
|
|
2186
|
+
import { CreateWorkflow as CreateWorkflow6, Task as Task4, Workflow as Workflow6 } from "@workglow/task-graph";
|
|
1339
2187
|
import {
|
|
1340
2188
|
TypedArraySchema as TypedArraySchema3
|
|
1341
2189
|
} from "@workglow/util/schema";
|
|
@@ -1410,7 +2258,7 @@ var outputSchema2 = {
|
|
|
1410
2258
|
additionalProperties: false
|
|
1411
2259
|
};
|
|
1412
2260
|
|
|
1413
|
-
class ChunkToVectorTask extends
|
|
2261
|
+
class ChunkToVectorTask extends Task4 {
|
|
1414
2262
|
static type = "ChunkToVectorTask";
|
|
1415
2263
|
static category = "Document";
|
|
1416
2264
|
static title = "Chunk to Vector";
|
|
@@ -1459,13 +2307,13 @@ class ChunkToVectorTask extends Task3 {
|
|
|
1459
2307
|
}
|
|
1460
2308
|
}
|
|
1461
2309
|
var chunkToVector = (input, config) => {
|
|
1462
|
-
return new ChunkToVectorTask(
|
|
2310
|
+
return new ChunkToVectorTask(config).run(input);
|
|
1463
2311
|
};
|
|
1464
|
-
|
|
2312
|
+
Workflow6.prototype.chunkToVector = CreateWorkflow6(ChunkToVectorTask);
|
|
1465
2313
|
|
|
1466
2314
|
// src/task/ChunkVectorHybridSearchTask.ts
|
|
1467
2315
|
import { TypeKnowledgeBase as TypeKnowledgeBase2 } from "@workglow/knowledge-base";
|
|
1468
|
-
import { CreateWorkflow as
|
|
2316
|
+
import { CreateWorkflow as CreateWorkflow7, Task as Task5, Workflow as Workflow7 } from "@workglow/task-graph";
|
|
1469
2317
|
import {
|
|
1470
2318
|
TypedArraySchema as TypedArraySchema4
|
|
1471
2319
|
} from "@workglow/util/schema";
|
|
@@ -1578,7 +2426,7 @@ var outputSchema3 = {
|
|
|
1578
2426
|
additionalProperties: false
|
|
1579
2427
|
};
|
|
1580
2428
|
|
|
1581
|
-
class ChunkVectorHybridSearchTask extends
|
|
2429
|
+
class ChunkVectorHybridSearchTask extends Task5 {
|
|
1582
2430
|
static type = "ChunkVectorHybridSearchTask";
|
|
1583
2431
|
static category = "RAG";
|
|
1584
2432
|
static title = "Hybrid Search";
|
|
@@ -1629,13 +2477,13 @@ class ChunkVectorHybridSearchTask extends Task4 {
|
|
|
1629
2477
|
}
|
|
1630
2478
|
}
|
|
1631
2479
|
var hybridSearch = async (input, config) => {
|
|
1632
|
-
return new ChunkVectorHybridSearchTask(
|
|
2480
|
+
return new ChunkVectorHybridSearchTask(config).run(input);
|
|
1633
2481
|
};
|
|
1634
|
-
|
|
2482
|
+
Workflow7.prototype.hybridSearch = CreateWorkflow7(ChunkVectorHybridSearchTask);
|
|
1635
2483
|
|
|
1636
2484
|
// src/task/ChunkVectorSearchTask.ts
|
|
1637
2485
|
import { TypeKnowledgeBase as TypeKnowledgeBase3 } from "@workglow/knowledge-base";
|
|
1638
|
-
import { CreateWorkflow as
|
|
2486
|
+
import { CreateWorkflow as CreateWorkflow8, Task as Task6, Workflow as Workflow8 } from "@workglow/task-graph";
|
|
1639
2487
|
import {
|
|
1640
2488
|
TypedArraySchema as TypedArraySchema5
|
|
1641
2489
|
} from "@workglow/util/schema";
|
|
@@ -1718,7 +2566,7 @@ var outputSchema4 = {
|
|
|
1718
2566
|
additionalProperties: false
|
|
1719
2567
|
};
|
|
1720
2568
|
|
|
1721
|
-
class ChunkVectorSearchTask extends
|
|
2569
|
+
class ChunkVectorSearchTask extends Task6 {
|
|
1722
2570
|
static type = "ChunkVectorSearchTask";
|
|
1723
2571
|
static category = "Vector Store";
|
|
1724
2572
|
static title = "Vector Store Search";
|
|
@@ -1748,13 +2596,13 @@ class ChunkVectorSearchTask extends Task5 {
|
|
|
1748
2596
|
}
|
|
1749
2597
|
}
|
|
1750
2598
|
var vectorStoreSearch = (input, config) => {
|
|
1751
|
-
return new ChunkVectorSearchTask(
|
|
2599
|
+
return new ChunkVectorSearchTask(config).run(input);
|
|
1752
2600
|
};
|
|
1753
|
-
|
|
2601
|
+
Workflow8.prototype.vectorStoreSearch = CreateWorkflow8(ChunkVectorSearchTask);
|
|
1754
2602
|
|
|
1755
2603
|
// src/task/ChunkVectorUpsertTask.ts
|
|
1756
2604
|
import { TypeKnowledgeBase as TypeKnowledgeBase4 } from "@workglow/knowledge-base";
|
|
1757
|
-
import { CreateWorkflow as
|
|
2605
|
+
import { CreateWorkflow as CreateWorkflow9, Task as Task7, Workflow as Workflow9 } from "@workglow/task-graph";
|
|
1758
2606
|
import {
|
|
1759
2607
|
TypedArraySchema as TypedArraySchema6
|
|
1760
2608
|
} from "@workglow/util/schema";
|
|
@@ -1808,7 +2656,7 @@ var outputSchema5 = {
|
|
|
1808
2656
|
additionalProperties: false
|
|
1809
2657
|
};
|
|
1810
2658
|
|
|
1811
|
-
class ChunkVectorUpsertTask extends
|
|
2659
|
+
class ChunkVectorUpsertTask extends Task7 {
|
|
1812
2660
|
static type = "ChunkVectorUpsertTask";
|
|
1813
2661
|
static category = "Vector Store";
|
|
1814
2662
|
static title = "Add to Vector Store";
|
|
@@ -1866,21 +2714,17 @@ class ChunkVectorUpsertTask extends Task6 {
|
|
|
1866
2714
|
}
|
|
1867
2715
|
}
|
|
1868
2716
|
var chunkVectorUpsert = (input, config) => {
|
|
1869
|
-
return new ChunkVectorUpsertTask(
|
|
2717
|
+
return new ChunkVectorUpsertTask(config).run(input);
|
|
1870
2718
|
};
|
|
1871
|
-
|
|
2719
|
+
Workflow9.prototype.chunkVectorUpsert = CreateWorkflow9(ChunkVectorUpsertTask);
|
|
1872
2720
|
|
|
1873
2721
|
// src/task/ContextBuilderTask.ts
|
|
1874
2722
|
import { estimateTokens } from "@workglow/knowledge-base";
|
|
1875
|
-
import {
|
|
1876
|
-
CreateWorkflow as CreateWorkflow9,
|
|
1877
|
-
Task as Task7,
|
|
1878
|
-
Workflow as Workflow9
|
|
1879
|
-
} from "@workglow/task-graph";
|
|
2723
|
+
import { CreateWorkflow as CreateWorkflow11, Task as Task8, Workflow as Workflow11 } from "@workglow/task-graph";
|
|
1880
2724
|
|
|
1881
2725
|
// src/task/CountTokensTask.ts
|
|
1882
|
-
import { CreateWorkflow as
|
|
1883
|
-
var
|
|
2726
|
+
import { CreateWorkflow as CreateWorkflow10, Workflow as Workflow10 } from "@workglow/task-graph";
|
|
2727
|
+
var modelSchema5 = TypeModel("model");
|
|
1884
2728
|
var CountTokensInputSchema = {
|
|
1885
2729
|
type: "object",
|
|
1886
2730
|
properties: {
|
|
@@ -1889,7 +2733,7 @@ var CountTokensInputSchema = {
|
|
|
1889
2733
|
title: "Text",
|
|
1890
2734
|
description: "The text to count tokens for"
|
|
1891
2735
|
},
|
|
1892
|
-
model:
|
|
2736
|
+
model: modelSchema5
|
|
1893
2737
|
},
|
|
1894
2738
|
required: ["text", "model"],
|
|
1895
2739
|
additionalProperties: false
|
|
@@ -1921,9 +2765,9 @@ class CountTokensTask extends AiTask {
|
|
|
1921
2765
|
}
|
|
1922
2766
|
}
|
|
1923
2767
|
var countTokens = async (input, config) => {
|
|
1924
|
-
return new CountTokensTask(
|
|
2768
|
+
return new CountTokensTask(config).run(input);
|
|
1925
2769
|
};
|
|
1926
|
-
|
|
2770
|
+
Workflow10.prototype.countTokens = CreateWorkflow10(CountTokensTask);
|
|
1927
2771
|
|
|
1928
2772
|
// src/task/ContextBuilderTask.ts
|
|
1929
2773
|
var ContextFormat = {
|
|
@@ -1933,7 +2777,7 @@ var ContextFormat = {
|
|
|
1933
2777
|
MARKDOWN: "markdown",
|
|
1934
2778
|
JSON: "json"
|
|
1935
2779
|
};
|
|
1936
|
-
var
|
|
2780
|
+
var modelSchema6 = TypeModel("model", {
|
|
1937
2781
|
title: "Model",
|
|
1938
2782
|
description: "Model to use for token counting (optional, falls back to estimation)"
|
|
1939
2783
|
});
|
|
@@ -1997,7 +2841,7 @@ var inputSchema6 = {
|
|
|
1997
2841
|
|
|
1998
2842
|
`
|
|
1999
2843
|
},
|
|
2000
|
-
model:
|
|
2844
|
+
model: modelSchema6
|
|
2001
2845
|
},
|
|
2002
2846
|
required: ["chunks"],
|
|
2003
2847
|
additionalProperties: false
|
|
@@ -2030,7 +2874,7 @@ var outputSchema6 = {
|
|
|
2030
2874
|
additionalProperties: false
|
|
2031
2875
|
};
|
|
2032
2876
|
|
|
2033
|
-
class ContextBuilderTask extends
|
|
2877
|
+
class ContextBuilderTask extends Task8 {
|
|
2034
2878
|
static type = "ContextBuilderTask";
|
|
2035
2879
|
static category = "RAG";
|
|
2036
2880
|
static title = "Context Builder";
|
|
@@ -2057,7 +2901,7 @@ class ContextBuilderTask extends Task7 {
|
|
|
2057
2901
|
} = input;
|
|
2058
2902
|
let countFn = async (text) => estimateTokens(text);
|
|
2059
2903
|
if (input.model) {
|
|
2060
|
-
const countTask = context.own(new CountTokensTask({ model: input.model }));
|
|
2904
|
+
const countTask = context.own(new CountTokensTask({ defaults: { model: input.model } }));
|
|
2061
2905
|
countFn = async (text) => {
|
|
2062
2906
|
try {
|
|
2063
2907
|
const result = await countTask.run({ text });
|
|
@@ -2221,20 +3065,17 @@ class ContextBuilderTask extends Task7 {
|
|
|
2221
3065
|
}
|
|
2222
3066
|
}
|
|
2223
3067
|
var contextBuilder = (input, config) => {
|
|
2224
|
-
return new ContextBuilderTask(
|
|
3068
|
+
return new ContextBuilderTask(config).run(input);
|
|
2225
3069
|
};
|
|
2226
|
-
|
|
3070
|
+
Workflow11.prototype.contextBuilder = CreateWorkflow11(ContextBuilderTask);
|
|
2227
3071
|
|
|
2228
3072
|
// src/task/DocumentEnricherTask.ts
|
|
2229
|
-
import {
|
|
2230
|
-
|
|
2231
|
-
hasChildren
|
|
2232
|
-
} from "@workglow/knowledge-base";
|
|
2233
|
-
import { CreateWorkflow as CreateWorkflow12, Task as Task8, Workflow as Workflow12 } from "@workglow/task-graph";
|
|
3073
|
+
import { getChildren, hasChildren } from "@workglow/knowledge-base";
|
|
3074
|
+
import { CreateWorkflow as CreateWorkflow14, Task as Task9, Workflow as Workflow14 } from "@workglow/task-graph";
|
|
2234
3075
|
|
|
2235
3076
|
// src/task/TextNamedEntityRecognitionTask.ts
|
|
2236
|
-
import { CreateWorkflow as
|
|
2237
|
-
var
|
|
3077
|
+
import { CreateWorkflow as CreateWorkflow12, Workflow as Workflow12 } from "@workglow/task-graph";
|
|
3078
|
+
var modelSchema7 = TypeModel("model:TextNamedEntityRecognitionTask");
|
|
2238
3079
|
var TextNamedEntityRecognitionInputSchema = {
|
|
2239
3080
|
type: "object",
|
|
2240
3081
|
properties: {
|
|
@@ -2253,7 +3094,7 @@ var TextNamedEntityRecognitionInputSchema = {
|
|
|
2253
3094
|
"x-ui-group": "Configuration",
|
|
2254
3095
|
"x-ui-group-open": false
|
|
2255
3096
|
},
|
|
2256
|
-
model:
|
|
3097
|
+
model: modelSchema7
|
|
2257
3098
|
},
|
|
2258
3099
|
required: ["text", "model"],
|
|
2259
3100
|
additionalProperties: false
|
|
@@ -2306,53 +3147,13 @@ class TextNamedEntityRecognitionTask extends AiTask {
|
|
|
2306
3147
|
}
|
|
2307
3148
|
}
|
|
2308
3149
|
var textNamedEntityRecognition = (input, config) => {
|
|
2309
|
-
return new TextNamedEntityRecognitionTask(
|
|
3150
|
+
return new TextNamedEntityRecognitionTask(config).run(input);
|
|
2310
3151
|
};
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
// src/task/TextSummaryTask.ts
|
|
2314
|
-
import { CreateWorkflow as CreateWorkflow11, Workflow as Workflow11 } from "@workglow/task-graph";
|
|
2315
|
-
|
|
2316
|
-
// src/task/base/StreamingAiTask.ts
|
|
2317
|
-
import {
|
|
2318
|
-
getStreamingPorts,
|
|
2319
|
-
TaskConfigurationError as TaskConfigurationError3
|
|
2320
|
-
} from "@workglow/task-graph";
|
|
2321
|
-
class StreamingAiTask extends AiTask {
|
|
2322
|
-
static type = "StreamingAiTask";
|
|
2323
|
-
async* executeStream(input, context) {
|
|
2324
|
-
const model = input.model;
|
|
2325
|
-
if (!model || typeof model !== "object") {
|
|
2326
|
-
throw new TaskConfigurationError3("StreamingAiTask: Model was not resolved to ModelConfig - this indicates a bug in the resolution system");
|
|
2327
|
-
}
|
|
2328
|
-
const jobInput = await this.getJobInput(input);
|
|
2329
|
-
const strategy = getAiProviderRegistry().getStrategy(model);
|
|
2330
|
-
const outSchema = this.outputSchema();
|
|
2331
|
-
const ports = getStreamingPorts(outSchema);
|
|
2332
|
-
let defaultPort = "text";
|
|
2333
|
-
if (ports.length > 0) {
|
|
2334
|
-
defaultPort = ports[0].port;
|
|
2335
|
-
} else {
|
|
2336
|
-
if (typeof outSchema === "object" && outSchema.properties) {
|
|
2337
|
-
const firstProp = Object.keys(outSchema.properties)[0];
|
|
2338
|
-
if (firstProp)
|
|
2339
|
-
defaultPort = firstProp;
|
|
2340
|
-
}
|
|
2341
|
-
}
|
|
2342
|
-
for await (const event of strategy.executeStream(jobInput, context, this.runConfig.runnerId)) {
|
|
2343
|
-
if (event.type === "text-delta") {
|
|
2344
|
-
yield { ...event, port: event.port ?? defaultPort };
|
|
2345
|
-
} else if (event.type === "object-delta") {
|
|
2346
|
-
yield { ...event, port: event.port ?? defaultPort };
|
|
2347
|
-
} else {
|
|
2348
|
-
yield event;
|
|
2349
|
-
}
|
|
2350
|
-
}
|
|
2351
|
-
}
|
|
2352
|
-
}
|
|
3152
|
+
Workflow12.prototype.textNamedEntityRecognition = CreateWorkflow12(TextNamedEntityRecognitionTask);
|
|
2353
3153
|
|
|
2354
3154
|
// src/task/TextSummaryTask.ts
|
|
2355
|
-
|
|
3155
|
+
import { CreateWorkflow as CreateWorkflow13, Workflow as Workflow13 } from "@workglow/task-graph";
|
|
3156
|
+
var modelSchema8 = TypeModel("model:TextSummaryTask");
|
|
2356
3157
|
var TextSummaryInputSchema = {
|
|
2357
3158
|
type: "object",
|
|
2358
3159
|
properties: {
|
|
@@ -2361,7 +3162,7 @@ var TextSummaryInputSchema = {
|
|
|
2361
3162
|
title: "Text",
|
|
2362
3163
|
description: "The text to summarize"
|
|
2363
3164
|
},
|
|
2364
|
-
model:
|
|
3165
|
+
model: modelSchema8
|
|
2365
3166
|
},
|
|
2366
3167
|
required: ["text", "model"],
|
|
2367
3168
|
additionalProperties: false
|
|
@@ -2393,9 +3194,9 @@ class TextSummaryTask extends StreamingAiTask {
|
|
|
2393
3194
|
}
|
|
2394
3195
|
}
|
|
2395
3196
|
var textSummary = async (input, config) => {
|
|
2396
|
-
return new TextSummaryTask(
|
|
3197
|
+
return new TextSummaryTask(config).run(input);
|
|
2397
3198
|
};
|
|
2398
|
-
|
|
3199
|
+
Workflow13.prototype.textSummary = CreateWorkflow13(TextSummaryTask);
|
|
2399
3200
|
|
|
2400
3201
|
// src/task/DocumentEnricherTask.ts
|
|
2401
3202
|
var inputSchema7 = {
|
|
@@ -2467,7 +3268,7 @@ var outputSchema7 = {
|
|
|
2467
3268
|
additionalProperties: false
|
|
2468
3269
|
};
|
|
2469
3270
|
|
|
2470
|
-
class DocumentEnricherTask extends
|
|
3271
|
+
class DocumentEnricherTask extends Task9 {
|
|
2471
3272
|
static type = "DocumentEnricherTask";
|
|
2472
3273
|
static category = "Document";
|
|
2473
3274
|
static title = "Document Enricher";
|
|
@@ -2495,7 +3296,7 @@ class DocumentEnricherTask extends Task8 {
|
|
|
2495
3296
|
let summaryCount = 0;
|
|
2496
3297
|
let entityCount = 0;
|
|
2497
3298
|
const extract = extractEntities && nerModel ? async (text) => {
|
|
2498
|
-
const result = await context.own(new TextNamedEntityRecognitionTask({ text, model: nerModel })
|
|
3299
|
+
const result = await context.own(new TextNamedEntityRecognitionTask).run({ text, model: nerModel });
|
|
2499
3300
|
return result.entities.map((e) => ({
|
|
2500
3301
|
type: e.entity,
|
|
2501
3302
|
text: e.word,
|
|
@@ -2624,17 +3425,17 @@ class DocumentEnricherTask extends Task8 {
|
|
|
2624
3425
|
}
|
|
2625
3426
|
}
|
|
2626
3427
|
var documentEnricher = (input, config) => {
|
|
2627
|
-
return new DocumentEnricherTask(
|
|
3428
|
+
return new DocumentEnricherTask(config).run(input);
|
|
2628
3429
|
};
|
|
2629
|
-
|
|
3430
|
+
Workflow14.prototype.documentEnricher = CreateWorkflow14(DocumentEnricherTask);
|
|
2630
3431
|
|
|
2631
3432
|
// src/task/DownloadModelTask.ts
|
|
2632
|
-
import { CreateWorkflow as
|
|
2633
|
-
var
|
|
3433
|
+
import { CreateWorkflow as CreateWorkflow15, Workflow as Workflow15 } from "@workglow/task-graph";
|
|
3434
|
+
var modelSchema9 = TypeModel("model");
|
|
2634
3435
|
var DownloadModelInputSchema = {
|
|
2635
3436
|
type: "object",
|
|
2636
3437
|
properties: {
|
|
2637
|
-
model:
|
|
3438
|
+
model: modelSchema9
|
|
2638
3439
|
},
|
|
2639
3440
|
required: ["model"],
|
|
2640
3441
|
additionalProperties: false
|
|
@@ -2642,7 +3443,7 @@ var DownloadModelInputSchema = {
|
|
|
2642
3443
|
var DownloadModelOutputSchema = {
|
|
2643
3444
|
type: "object",
|
|
2644
3445
|
properties: {
|
|
2645
|
-
model:
|
|
3446
|
+
model: modelSchema9
|
|
2646
3447
|
},
|
|
2647
3448
|
required: ["model"],
|
|
2648
3449
|
additionalProperties: false
|
|
@@ -2661,8 +3462,8 @@ class DownloadModelTask extends AiTask {
|
|
|
2661
3462
|
}
|
|
2662
3463
|
static cacheable = false;
|
|
2663
3464
|
files = [];
|
|
2664
|
-
constructor(
|
|
2665
|
-
super(
|
|
3465
|
+
constructor(config = {}) {
|
|
3466
|
+
super(config);
|
|
2666
3467
|
this.on("progress", this.processProgress.bind(this));
|
|
2667
3468
|
this.on("start", () => {
|
|
2668
3469
|
this.files = [];
|
|
@@ -2694,13 +3495,13 @@ class DownloadModelTask extends AiTask {
|
|
|
2694
3495
|
}
|
|
2695
3496
|
}
|
|
2696
3497
|
var downloadModel = (input, config) => {
|
|
2697
|
-
return new DownloadModelTask(
|
|
3498
|
+
return new DownloadModelTask(config).run(input);
|
|
2698
3499
|
};
|
|
2699
|
-
|
|
3500
|
+
Workflow15.prototype.downloadModel = CreateWorkflow15(DownloadModelTask);
|
|
2700
3501
|
|
|
2701
3502
|
// src/task/FaceDetectorTask.ts
|
|
2702
|
-
import { CreateWorkflow as
|
|
2703
|
-
var
|
|
3503
|
+
import { CreateWorkflow as CreateWorkflow16, Workflow as Workflow16 } from "@workglow/task-graph";
|
|
3504
|
+
var modelSchema10 = TypeModel("model:FaceDetectorTask");
|
|
2704
3505
|
var TypeBoundingBox2 = {
|
|
2705
3506
|
type: "object",
|
|
2706
3507
|
properties: {
|
|
@@ -2773,7 +3574,7 @@ var FaceDetectorInputSchema = {
|
|
|
2773
3574
|
type: "object",
|
|
2774
3575
|
properties: {
|
|
2775
3576
|
image: TypeImageInput,
|
|
2776
|
-
model:
|
|
3577
|
+
model: modelSchema10,
|
|
2777
3578
|
minDetectionConfidence: {
|
|
2778
3579
|
type: "number",
|
|
2779
3580
|
minimum: 0,
|
|
@@ -2825,13 +3626,13 @@ class FaceDetectorTask extends AiVisionTask {
|
|
|
2825
3626
|
}
|
|
2826
3627
|
}
|
|
2827
3628
|
var faceDetector = (input, config) => {
|
|
2828
|
-
return new FaceDetectorTask(
|
|
3629
|
+
return new FaceDetectorTask(config).run(input);
|
|
2829
3630
|
};
|
|
2830
|
-
|
|
3631
|
+
Workflow16.prototype.faceDetector = CreateWorkflow16(FaceDetectorTask);
|
|
2831
3632
|
|
|
2832
3633
|
// src/task/FaceLandmarkerTask.ts
|
|
2833
|
-
import { CreateWorkflow as
|
|
2834
|
-
var
|
|
3634
|
+
import { CreateWorkflow as CreateWorkflow17, Workflow as Workflow17 } from "@workglow/task-graph";
|
|
3635
|
+
var modelSchema11 = TypeModel("model:FaceLandmarkerTask");
|
|
2835
3636
|
var TypeLandmark = {
|
|
2836
3637
|
type: "object",
|
|
2837
3638
|
properties: {
|
|
@@ -2903,7 +3704,7 @@ var FaceLandmarkerInputSchema = {
|
|
|
2903
3704
|
type: "object",
|
|
2904
3705
|
properties: {
|
|
2905
3706
|
image: TypeImageInput,
|
|
2906
|
-
model:
|
|
3707
|
+
model: modelSchema11,
|
|
2907
3708
|
numFaces: {
|
|
2908
3709
|
type: "number",
|
|
2909
3710
|
minimum: 1,
|
|
@@ -2987,13 +3788,13 @@ class FaceLandmarkerTask extends AiVisionTask {
|
|
|
2987
3788
|
}
|
|
2988
3789
|
}
|
|
2989
3790
|
var faceLandmarker = (input, config) => {
|
|
2990
|
-
return new FaceLandmarkerTask(
|
|
3791
|
+
return new FaceLandmarkerTask(config).run(input);
|
|
2991
3792
|
};
|
|
2992
|
-
|
|
3793
|
+
Workflow17.prototype.faceLandmarker = CreateWorkflow17(FaceLandmarkerTask);
|
|
2993
3794
|
|
|
2994
3795
|
// src/task/GestureRecognizerTask.ts
|
|
2995
|
-
import { CreateWorkflow as
|
|
2996
|
-
var
|
|
3796
|
+
import { CreateWorkflow as CreateWorkflow18, Workflow as Workflow18 } from "@workglow/task-graph";
|
|
3797
|
+
var modelSchema12 = TypeModel("model:GestureRecognizerTask");
|
|
2997
3798
|
var TypeLandmark2 = {
|
|
2998
3799
|
type: "object",
|
|
2999
3800
|
properties: {
|
|
@@ -3085,7 +3886,7 @@ var GestureRecognizerInputSchema = {
|
|
|
3085
3886
|
type: "object",
|
|
3086
3887
|
properties: {
|
|
3087
3888
|
image: TypeImageInput,
|
|
3088
|
-
model:
|
|
3889
|
+
model: modelSchema12,
|
|
3089
3890
|
numHands: {
|
|
3090
3891
|
type: "number",
|
|
3091
3892
|
minimum: 1,
|
|
@@ -3155,13 +3956,13 @@ class GestureRecognizerTask extends AiVisionTask {
|
|
|
3155
3956
|
}
|
|
3156
3957
|
}
|
|
3157
3958
|
var gestureRecognizer = (input, config) => {
|
|
3158
|
-
return new GestureRecognizerTask(
|
|
3959
|
+
return new GestureRecognizerTask(config).run(input);
|
|
3159
3960
|
};
|
|
3160
|
-
|
|
3961
|
+
Workflow18.prototype.gestureRecognizer = CreateWorkflow18(GestureRecognizerTask);
|
|
3161
3962
|
|
|
3162
3963
|
// src/task/HandLandmarkerTask.ts
|
|
3163
|
-
import { CreateWorkflow as
|
|
3164
|
-
var
|
|
3964
|
+
import { CreateWorkflow as CreateWorkflow19, Workflow as Workflow19 } from "@workglow/task-graph";
|
|
3965
|
+
var modelSchema13 = TypeModel("model:HandLandmarkerTask");
|
|
3165
3966
|
var TypeLandmark3 = {
|
|
3166
3967
|
type: "object",
|
|
3167
3968
|
properties: {
|
|
@@ -3230,7 +4031,7 @@ var HandLandmarkerInputSchema = {
|
|
|
3230
4031
|
type: "object",
|
|
3231
4032
|
properties: {
|
|
3232
4033
|
image: TypeImageInput,
|
|
3233
|
-
model:
|
|
4034
|
+
model: modelSchema13,
|
|
3234
4035
|
numHands: {
|
|
3235
4036
|
type: "number",
|
|
3236
4037
|
minimum: 1,
|
|
@@ -3300,9 +4101,9 @@ class HandLandmarkerTask extends AiVisionTask {
|
|
|
3300
4101
|
}
|
|
3301
4102
|
}
|
|
3302
4103
|
var handLandmarker = (input, config) => {
|
|
3303
|
-
return new HandLandmarkerTask(
|
|
4104
|
+
return new HandLandmarkerTask(config).run(input);
|
|
3304
4105
|
};
|
|
3305
|
-
|
|
4106
|
+
Workflow19.prototype.handLandmarker = CreateWorkflow19(HandLandmarkerTask);
|
|
3306
4107
|
|
|
3307
4108
|
// src/task/HierarchicalChunkerTask.ts
|
|
3308
4109
|
import {
|
|
@@ -3311,9 +4112,9 @@ import {
|
|
|
3311
4112
|
getChildren as getChildren2,
|
|
3312
4113
|
hasChildren as hasChildren2
|
|
3313
4114
|
} from "@workglow/knowledge-base";
|
|
3314
|
-
import { CreateWorkflow as
|
|
4115
|
+
import { CreateWorkflow as CreateWorkflow20, Task as Task10, Workflow as Workflow20 } from "@workglow/task-graph";
|
|
3315
4116
|
import { uuid4 } from "@workglow/util";
|
|
3316
|
-
var
|
|
4117
|
+
var modelSchema14 = TypeModel("model", {
|
|
3317
4118
|
title: "Model",
|
|
3318
4119
|
description: "Model to use for token counting"
|
|
3319
4120
|
});
|
|
@@ -3357,7 +4158,7 @@ var inputSchema8 = {
|
|
|
3357
4158
|
description: "Strategy for chunking",
|
|
3358
4159
|
default: "hierarchical"
|
|
3359
4160
|
},
|
|
3360
|
-
model:
|
|
4161
|
+
model: modelSchema14
|
|
3361
4162
|
},
|
|
3362
4163
|
required: ["doc_id", "documentTree"],
|
|
3363
4164
|
additionalProperties: false
|
|
@@ -3392,7 +4193,7 @@ var outputSchema8 = {
|
|
|
3392
4193
|
additionalProperties: false
|
|
3393
4194
|
};
|
|
3394
4195
|
|
|
3395
|
-
class HierarchicalChunkerTask extends
|
|
4196
|
+
class HierarchicalChunkerTask extends Task10 {
|
|
3396
4197
|
static type = "HierarchicalChunkerTask";
|
|
3397
4198
|
static category = "Document";
|
|
3398
4199
|
static title = "Hierarchical Chunker";
|
|
@@ -3427,7 +4228,7 @@ class HierarchicalChunkerTask extends Task9 {
|
|
|
3427
4228
|
};
|
|
3428
4229
|
let countFn = async (text) => estimateTokens2(text);
|
|
3429
4230
|
if (input.model) {
|
|
3430
|
-
const countTask = context.own(new CountTokensTask({ model: input.model }));
|
|
4231
|
+
const countTask = context.own(new CountTokensTask({ defaults: { model: input.model } }));
|
|
3431
4232
|
countFn = async (text) => {
|
|
3432
4233
|
try {
|
|
3433
4234
|
const result = await countTask.run({ text });
|
|
@@ -3534,16 +4335,13 @@ class HierarchicalChunkerTask extends Task9 {
|
|
|
3534
4335
|
}
|
|
3535
4336
|
}
|
|
3536
4337
|
var hierarchicalChunker = (input, config) => {
|
|
3537
|
-
return new HierarchicalChunkerTask(
|
|
4338
|
+
return new HierarchicalChunkerTask(config).run(input);
|
|
3538
4339
|
};
|
|
3539
|
-
|
|
4340
|
+
Workflow20.prototype.hierarchicalChunker = CreateWorkflow20(HierarchicalChunkerTask);
|
|
3540
4341
|
|
|
3541
4342
|
// src/task/HierarchyJoinTask.ts
|
|
3542
|
-
import {
|
|
3543
|
-
|
|
3544
|
-
TypeKnowledgeBase as TypeKnowledgeBase5
|
|
3545
|
-
} from "@workglow/knowledge-base";
|
|
3546
|
-
import { CreateWorkflow as CreateWorkflow19, Task as Task10, Workflow as Workflow19 } from "@workglow/task-graph";
|
|
4343
|
+
import { ChunkRecordArraySchema, TypeKnowledgeBase as TypeKnowledgeBase5 } from "@workglow/knowledge-base";
|
|
4344
|
+
import { CreateWorkflow as CreateWorkflow21, Task as Task11, Workflow as Workflow21 } from "@workglow/task-graph";
|
|
3547
4345
|
var inputSchema9 = {
|
|
3548
4346
|
type: "object",
|
|
3549
4347
|
properties: {
|
|
@@ -3618,7 +4416,7 @@ var outputSchema9 = {
|
|
|
3618
4416
|
additionalProperties: false
|
|
3619
4417
|
};
|
|
3620
4418
|
|
|
3621
|
-
class HierarchyJoinTask extends
|
|
4419
|
+
class HierarchyJoinTask extends Task11 {
|
|
3622
4420
|
static type = "HierarchyJoinTask";
|
|
3623
4421
|
static category = "RAG";
|
|
3624
4422
|
static title = "Hierarchy Join";
|
|
@@ -3710,18 +4508,18 @@ class HierarchyJoinTask extends Task10 {
|
|
|
3710
4508
|
}
|
|
3711
4509
|
}
|
|
3712
4510
|
var hierarchyJoin = (input, config) => {
|
|
3713
|
-
return new HierarchyJoinTask(
|
|
4511
|
+
return new HierarchyJoinTask(config).run(input);
|
|
3714
4512
|
};
|
|
3715
|
-
|
|
4513
|
+
Workflow21.prototype.hierarchyJoin = CreateWorkflow21(HierarchyJoinTask);
|
|
3716
4514
|
|
|
3717
4515
|
// src/task/ImageClassificationTask.ts
|
|
3718
|
-
import { CreateWorkflow as
|
|
3719
|
-
var
|
|
4516
|
+
import { CreateWorkflow as CreateWorkflow22, Workflow as Workflow22 } from "@workglow/task-graph";
|
|
4517
|
+
var modelSchema15 = TypeModel("model:ImageClassificationTask");
|
|
3720
4518
|
var ImageClassificationInputSchema = {
|
|
3721
4519
|
type: "object",
|
|
3722
4520
|
properties: {
|
|
3723
4521
|
image: TypeImageInput,
|
|
3724
|
-
model:
|
|
4522
|
+
model: modelSchema15,
|
|
3725
4523
|
categories: {
|
|
3726
4524
|
type: "array",
|
|
3727
4525
|
items: {
|
|
@@ -3773,21 +4571,21 @@ class ImageClassificationTask extends AiVisionTask {
|
|
|
3773
4571
|
}
|
|
3774
4572
|
}
|
|
3775
4573
|
var imageClassification = (input, config) => {
|
|
3776
|
-
return new ImageClassificationTask(
|
|
4574
|
+
return new ImageClassificationTask(config).run(input);
|
|
3777
4575
|
};
|
|
3778
|
-
|
|
4576
|
+
Workflow22.prototype.imageClassification = CreateWorkflow22(ImageClassificationTask);
|
|
3779
4577
|
|
|
3780
4578
|
// src/task/ImageEmbeddingTask.ts
|
|
3781
|
-
import { CreateWorkflow as
|
|
4579
|
+
import { CreateWorkflow as CreateWorkflow23, Workflow as Workflow23 } from "@workglow/task-graph";
|
|
3782
4580
|
import {
|
|
3783
4581
|
TypedArraySchema as TypedArraySchema7
|
|
3784
4582
|
} from "@workglow/util/schema";
|
|
3785
|
-
var
|
|
4583
|
+
var modelSchema16 = TypeModel("model:ImageEmbeddingTask");
|
|
3786
4584
|
var ImageEmbeddingInputSchema = {
|
|
3787
4585
|
type: "object",
|
|
3788
4586
|
properties: {
|
|
3789
4587
|
image: TypeSingleOrArray(TypeImageInput),
|
|
3790
|
-
model:
|
|
4588
|
+
model: modelSchema16
|
|
3791
4589
|
},
|
|
3792
4590
|
required: ["image", "model"],
|
|
3793
4591
|
additionalProperties: false
|
|
@@ -3817,18 +4615,18 @@ class ImageEmbeddingTask extends AiVisionTask {
|
|
|
3817
4615
|
}
|
|
3818
4616
|
}
|
|
3819
4617
|
var imageEmbedding = (input, config) => {
|
|
3820
|
-
return new ImageEmbeddingTask(
|
|
4618
|
+
return new ImageEmbeddingTask(config).run(input);
|
|
3821
4619
|
};
|
|
3822
|
-
|
|
4620
|
+
Workflow23.prototype.imageEmbedding = CreateWorkflow23(ImageEmbeddingTask);
|
|
3823
4621
|
|
|
3824
4622
|
// src/task/ImageSegmentationTask.ts
|
|
3825
|
-
import { CreateWorkflow as
|
|
3826
|
-
var
|
|
4623
|
+
import { CreateWorkflow as CreateWorkflow24, Workflow as Workflow24 } from "@workglow/task-graph";
|
|
4624
|
+
var modelSchema17 = TypeModel("model:ImageSegmentationTask");
|
|
3827
4625
|
var ImageSegmentationInputSchema = {
|
|
3828
4626
|
type: "object",
|
|
3829
4627
|
properties: {
|
|
3830
4628
|
image: TypeImageInput,
|
|
3831
|
-
model:
|
|
4629
|
+
model: modelSchema17,
|
|
3832
4630
|
threshold: {
|
|
3833
4631
|
type: "number",
|
|
3834
4632
|
title: "Threshold",
|
|
@@ -3905,13 +4703,13 @@ class ImageSegmentationTask extends AiVisionTask {
|
|
|
3905
4703
|
}
|
|
3906
4704
|
}
|
|
3907
4705
|
var imageSegmentation = (input, config) => {
|
|
3908
|
-
return new ImageSegmentationTask(
|
|
4706
|
+
return new ImageSegmentationTask(config).run(input);
|
|
3909
4707
|
};
|
|
3910
|
-
|
|
4708
|
+
Workflow24.prototype.imageSegmentation = CreateWorkflow24(ImageSegmentationTask);
|
|
3911
4709
|
|
|
3912
4710
|
// src/task/ImageToTextTask.ts
|
|
3913
|
-
import { CreateWorkflow as
|
|
3914
|
-
var
|
|
4711
|
+
import { CreateWorkflow as CreateWorkflow25, Workflow as Workflow25 } from "@workglow/task-graph";
|
|
4712
|
+
var modelSchema18 = TypeModel("model:ImageToTextTask");
|
|
3915
4713
|
var generatedTextSchema = {
|
|
3916
4714
|
type: "string",
|
|
3917
4715
|
title: "Text",
|
|
@@ -3921,7 +4719,7 @@ var ImageToTextInputSchema = {
|
|
|
3921
4719
|
type: "object",
|
|
3922
4720
|
properties: {
|
|
3923
4721
|
image: TypeImageInput,
|
|
3924
|
-
model:
|
|
4722
|
+
model: modelSchema18,
|
|
3925
4723
|
maxTokens: {
|
|
3926
4724
|
type: "number",
|
|
3927
4725
|
title: "Max Tokens",
|
|
@@ -3960,17 +4758,17 @@ class ImageToTextTask extends AiVisionTask {
|
|
|
3960
4758
|
}
|
|
3961
4759
|
}
|
|
3962
4760
|
var imageToText = (input, config) => {
|
|
3963
|
-
return new ImageToTextTask(
|
|
4761
|
+
return new ImageToTextTask(config).run(input);
|
|
3964
4762
|
};
|
|
3965
|
-
|
|
4763
|
+
Workflow25.prototype.imageToText = CreateWorkflow25(ImageToTextTask);
|
|
3966
4764
|
|
|
3967
4765
|
// src/task/ModelInfoTask.ts
|
|
3968
|
-
import { CreateWorkflow as
|
|
3969
|
-
var
|
|
4766
|
+
import { CreateWorkflow as CreateWorkflow26, Workflow as Workflow26 } from "@workglow/task-graph";
|
|
4767
|
+
var modelSchema19 = TypeModel("model");
|
|
3970
4768
|
var ModelInfoInputSchema = {
|
|
3971
4769
|
type: "object",
|
|
3972
4770
|
properties: {
|
|
3973
|
-
model:
|
|
4771
|
+
model: modelSchema19,
|
|
3974
4772
|
detail: {
|
|
3975
4773
|
type: "string",
|
|
3976
4774
|
enum: ["cached_status", "files", "files_with_metadata"],
|
|
@@ -3983,7 +4781,7 @@ var ModelInfoInputSchema = {
|
|
|
3983
4781
|
var ModelInfoOutputSchema = {
|
|
3984
4782
|
type: "object",
|
|
3985
4783
|
properties: {
|
|
3986
|
-
model:
|
|
4784
|
+
model: modelSchema19,
|
|
3987
4785
|
is_local: { type: "boolean" },
|
|
3988
4786
|
is_remote: { type: "boolean" },
|
|
3989
4787
|
supports_browser: { type: "boolean" },
|
|
@@ -4031,12 +4829,12 @@ class ModelInfoTask extends AiTask {
|
|
|
4031
4829
|
}
|
|
4032
4830
|
}
|
|
4033
4831
|
var modelInfo = (input, config) => {
|
|
4034
|
-
return new ModelInfoTask(
|
|
4832
|
+
return new ModelInfoTask(config).run(input);
|
|
4035
4833
|
};
|
|
4036
|
-
|
|
4834
|
+
Workflow26.prototype.modelInfo = CreateWorkflow26(ModelInfoTask);
|
|
4037
4835
|
|
|
4038
4836
|
// src/task/ModelSearchTask.ts
|
|
4039
|
-
import { CreateWorkflow as
|
|
4837
|
+
import { CreateWorkflow as CreateWorkflow27, Task as Task12, Workflow as Workflow27 } from "@workglow/task-graph";
|
|
4040
4838
|
var ModelSearchInputSchema = {
|
|
4041
4839
|
type: "object",
|
|
4042
4840
|
properties: {
|
|
@@ -4101,7 +4899,7 @@ var ModelSearchOutputSchema = {
|
|
|
4101
4899
|
additionalProperties: false
|
|
4102
4900
|
};
|
|
4103
4901
|
|
|
4104
|
-
class ModelSearchTask extends
|
|
4902
|
+
class ModelSearchTask extends Task12 {
|
|
4105
4903
|
static type = "ModelSearchTask";
|
|
4106
4904
|
static category = "AI Model";
|
|
4107
4905
|
static title = "Model Search";
|
|
@@ -4125,13 +4923,13 @@ class ModelSearchTask extends Task11 {
|
|
|
4125
4923
|
}
|
|
4126
4924
|
}
|
|
4127
4925
|
var modelSearch = (input, config) => {
|
|
4128
|
-
return new ModelSearchTask(
|
|
4926
|
+
return new ModelSearchTask(config).run(input);
|
|
4129
4927
|
};
|
|
4130
|
-
|
|
4928
|
+
Workflow27.prototype.modelSearch = CreateWorkflow27(ModelSearchTask);
|
|
4131
4929
|
|
|
4132
4930
|
// src/task/ObjectDetectionTask.ts
|
|
4133
|
-
import { CreateWorkflow as
|
|
4134
|
-
var
|
|
4931
|
+
import { CreateWorkflow as CreateWorkflow28, Workflow as Workflow28 } from "@workglow/task-graph";
|
|
4932
|
+
var modelSchema20 = TypeModel("model:ObjectDetectionTask");
|
|
4135
4933
|
var detectionSchema = {
|
|
4136
4934
|
type: "object",
|
|
4137
4935
|
properties: {
|
|
@@ -4156,7 +4954,7 @@ var ObjectDetectionInputSchema = {
|
|
|
4156
4954
|
type: "object",
|
|
4157
4955
|
properties: {
|
|
4158
4956
|
image: TypeImageInput,
|
|
4159
|
-
model:
|
|
4957
|
+
model: modelSchema20,
|
|
4160
4958
|
labels: {
|
|
4161
4959
|
type: "array",
|
|
4162
4960
|
items: {
|
|
@@ -4208,13 +5006,13 @@ class ObjectDetectionTask extends AiVisionTask {
|
|
|
4208
5006
|
}
|
|
4209
5007
|
}
|
|
4210
5008
|
var objectDetection = (input, config) => {
|
|
4211
|
-
return new ObjectDetectionTask(
|
|
5009
|
+
return new ObjectDetectionTask(config).run(input);
|
|
4212
5010
|
};
|
|
4213
|
-
|
|
5011
|
+
Workflow28.prototype.objectDetection = CreateWorkflow28(ObjectDetectionTask);
|
|
4214
5012
|
|
|
4215
5013
|
// src/task/PoseLandmarkerTask.ts
|
|
4216
|
-
import { CreateWorkflow as
|
|
4217
|
-
var
|
|
5014
|
+
import { CreateWorkflow as CreateWorkflow29, Workflow as Workflow29 } from "@workglow/task-graph";
|
|
5015
|
+
var modelSchema21 = TypeModel("model:PoseLandmarkerTask");
|
|
4218
5016
|
var TypePoseLandmark = {
|
|
4219
5017
|
type: "object",
|
|
4220
5018
|
properties: {
|
|
@@ -4293,7 +5091,7 @@ var PoseLandmarkerInputSchema = {
|
|
|
4293
5091
|
type: "object",
|
|
4294
5092
|
properties: {
|
|
4295
5093
|
image: TypeImageInput,
|
|
4296
|
-
model:
|
|
5094
|
+
model: modelSchema21,
|
|
4297
5095
|
numPoses: {
|
|
4298
5096
|
type: "number",
|
|
4299
5097
|
minimum: 1,
|
|
@@ -4370,12 +5168,12 @@ class PoseLandmarkerTask extends AiVisionTask {
|
|
|
4370
5168
|
}
|
|
4371
5169
|
}
|
|
4372
5170
|
var poseLandmarker = (input, config) => {
|
|
4373
|
-
return new PoseLandmarkerTask(
|
|
5171
|
+
return new PoseLandmarkerTask(config).run(input);
|
|
4374
5172
|
};
|
|
4375
|
-
|
|
5173
|
+
Workflow29.prototype.poseLandmarker = CreateWorkflow29(PoseLandmarkerTask);
|
|
4376
5174
|
|
|
4377
5175
|
// src/task/QueryExpanderTask.ts
|
|
4378
|
-
import { CreateWorkflow as
|
|
5176
|
+
import { CreateWorkflow as CreateWorkflow30, Task as Task13, Workflow as Workflow30 } from "@workglow/task-graph";
|
|
4379
5177
|
var QueryExpansionMethod = {
|
|
4380
5178
|
MULTI_QUERY: "multi-query",
|
|
4381
5179
|
HYDE: "hyde",
|
|
@@ -4443,7 +5241,7 @@ var outputSchema10 = {
|
|
|
4443
5241
|
additionalProperties: false
|
|
4444
5242
|
};
|
|
4445
5243
|
|
|
4446
|
-
class QueryExpanderTask extends
|
|
5244
|
+
class QueryExpanderTask extends Task13 {
|
|
4447
5245
|
static type = "QueryExpanderTask";
|
|
4448
5246
|
static category = "RAG";
|
|
4449
5247
|
static title = "Query Expander";
|
|
@@ -4583,16 +5381,16 @@ class QueryExpanderTask extends Task12 {
|
|
|
4583
5381
|
}
|
|
4584
5382
|
}
|
|
4585
5383
|
var queryExpander = (input, config) => {
|
|
4586
|
-
return new QueryExpanderTask(
|
|
5384
|
+
return new QueryExpanderTask(config).run(input);
|
|
4587
5385
|
};
|
|
4588
|
-
|
|
5386
|
+
Workflow30.prototype.queryExpander = CreateWorkflow30(QueryExpanderTask);
|
|
4589
5387
|
|
|
4590
5388
|
// src/task/RerankerTask.ts
|
|
4591
|
-
import { CreateWorkflow as
|
|
5389
|
+
import { CreateWorkflow as CreateWorkflow32, Task as Task14, Workflow as Workflow32 } from "@workglow/task-graph";
|
|
4592
5390
|
|
|
4593
5391
|
// src/task/TextClassificationTask.ts
|
|
4594
|
-
import { CreateWorkflow as
|
|
4595
|
-
var
|
|
5392
|
+
import { CreateWorkflow as CreateWorkflow31, Workflow as Workflow31 } from "@workglow/task-graph";
|
|
5393
|
+
var modelSchema22 = TypeModel("model:TextClassificationTask");
|
|
4596
5394
|
var TextClassificationInputSchema = {
|
|
4597
5395
|
type: "object",
|
|
4598
5396
|
properties: {
|
|
@@ -4619,7 +5417,7 @@ var TextClassificationInputSchema = {
|
|
|
4619
5417
|
description: "The maximum number of categories to return",
|
|
4620
5418
|
"x-ui-group": "Configuration"
|
|
4621
5419
|
},
|
|
4622
|
-
model:
|
|
5420
|
+
model: modelSchema22
|
|
4623
5421
|
},
|
|
4624
5422
|
required: ["text", "model"],
|
|
4625
5423
|
additionalProperties: false
|
|
@@ -4667,9 +5465,9 @@ class TextClassificationTask extends AiTask {
|
|
|
4667
5465
|
}
|
|
4668
5466
|
}
|
|
4669
5467
|
var textClassification = (input, config) => {
|
|
4670
|
-
return new TextClassificationTask(
|
|
5468
|
+
return new TextClassificationTask(config).run(input);
|
|
4671
5469
|
};
|
|
4672
|
-
|
|
5470
|
+
Workflow31.prototype.textClassification = CreateWorkflow31(TextClassificationTask);
|
|
4673
5471
|
|
|
4674
5472
|
// src/task/RerankerTask.ts
|
|
4675
5473
|
var inputSchema11 = {
|
|
@@ -4764,7 +5562,7 @@ var outputSchema11 = {
|
|
|
4764
5562
|
additionalProperties: false
|
|
4765
5563
|
};
|
|
4766
5564
|
|
|
4767
|
-
class RerankerTask extends
|
|
5565
|
+
class RerankerTask extends Task14 {
|
|
4768
5566
|
static type = "RerankerTask";
|
|
4769
5567
|
static category = "RAG";
|
|
4770
5568
|
static title = "Reranker";
|
|
@@ -4815,8 +5613,8 @@ class RerankerTask extends Task13 {
|
|
|
4815
5613
|
}
|
|
4816
5614
|
const items = await Promise.all(chunks.map(async (chunk, index) => {
|
|
4817
5615
|
const pairText = `${query} [SEP] ${chunk}`;
|
|
4818
|
-
const task = context.own(new TextClassificationTask({
|
|
4819
|
-
const result = await task.run();
|
|
5616
|
+
const task = context.own(new TextClassificationTask({ defaults: { model } }));
|
|
5617
|
+
const result = await task.run({ text: pairText, maxCategories: 2 });
|
|
4820
5618
|
const crossScore = this.extractCrossEncoderScore(result.categories);
|
|
4821
5619
|
return {
|
|
4822
5620
|
chunk,
|
|
@@ -4891,13 +5689,13 @@ class RerankerTask extends Task13 {
|
|
|
4891
5689
|
}
|
|
4892
5690
|
}
|
|
4893
5691
|
var reranker = (input, config) => {
|
|
4894
|
-
return new RerankerTask(
|
|
5692
|
+
return new RerankerTask(config).run(input);
|
|
4895
5693
|
};
|
|
4896
|
-
|
|
5694
|
+
Workflow32.prototype.reranker = CreateWorkflow32(RerankerTask);
|
|
4897
5695
|
|
|
4898
5696
|
// src/task/StructuralParserTask.ts
|
|
4899
5697
|
import { StructuralParser } from "@workglow/knowledge-base";
|
|
4900
|
-
import { CreateWorkflow as
|
|
5698
|
+
import { CreateWorkflow as CreateWorkflow33, Task as Task15, Workflow as Workflow33 } from "@workglow/task-graph";
|
|
4901
5699
|
import { uuid4 as uuid42 } from "@workglow/util";
|
|
4902
5700
|
var inputSchema12 = {
|
|
4903
5701
|
type: "object",
|
|
@@ -4955,7 +5753,7 @@ var outputSchema12 = {
|
|
|
4955
5753
|
additionalProperties: false
|
|
4956
5754
|
};
|
|
4957
5755
|
|
|
4958
|
-
class StructuralParserTask extends
|
|
5756
|
+
class StructuralParserTask extends Task15 {
|
|
4959
5757
|
static type = "StructuralParserTask";
|
|
4960
5758
|
static category = "Document";
|
|
4961
5759
|
static title = "Structural Parser";
|
|
@@ -4996,17 +5794,17 @@ class StructuralParserTask extends Task14 {
|
|
|
4996
5794
|
}
|
|
4997
5795
|
}
|
|
4998
5796
|
var structuralParser = (input, config) => {
|
|
4999
|
-
return new StructuralParserTask(
|
|
5797
|
+
return new StructuralParserTask(config).run(input);
|
|
5000
5798
|
};
|
|
5001
|
-
|
|
5799
|
+
Workflow33.prototype.structuralParser = CreateWorkflow33(StructuralParserTask);
|
|
5002
5800
|
|
|
5003
5801
|
// src/task/StructuredGenerationTask.ts
|
|
5004
|
-
import { CreateWorkflow as
|
|
5005
|
-
var
|
|
5802
|
+
import { CreateWorkflow as CreateWorkflow34, Workflow as Workflow34 } from "@workglow/task-graph";
|
|
5803
|
+
var modelSchema23 = TypeModel("model:StructuredGenerationTask");
|
|
5006
5804
|
var StructuredGenerationInputSchema = {
|
|
5007
5805
|
type: "object",
|
|
5008
5806
|
properties: {
|
|
5009
|
-
model:
|
|
5807
|
+
model: modelSchema23,
|
|
5010
5808
|
prompt: {
|
|
5011
5809
|
type: "string",
|
|
5012
5810
|
title: "Prompt",
|
|
@@ -5067,12 +5865,12 @@ class StructuredGenerationTask extends StreamingAiTask {
|
|
|
5067
5865
|
}
|
|
5068
5866
|
}
|
|
5069
5867
|
var structuredGeneration = (input, config) => {
|
|
5070
|
-
return new StructuredGenerationTask(
|
|
5868
|
+
return new StructuredGenerationTask(config).run(input);
|
|
5071
5869
|
};
|
|
5072
|
-
|
|
5870
|
+
Workflow34.prototype.structuredGeneration = CreateWorkflow34(StructuredGenerationTask);
|
|
5073
5871
|
|
|
5074
5872
|
// src/task/TextChunkerTask.ts
|
|
5075
|
-
import { CreateWorkflow as
|
|
5873
|
+
import { CreateWorkflow as CreateWorkflow35, Task as Task16, Workflow as Workflow35 } from "@workglow/task-graph";
|
|
5076
5874
|
var ChunkingStrategy = {
|
|
5077
5875
|
FIXED: "fixed",
|
|
5078
5876
|
SENTENCE: "sentence",
|
|
@@ -5141,7 +5939,7 @@ var outputSchema13 = {
|
|
|
5141
5939
|
additionalProperties: false
|
|
5142
5940
|
};
|
|
5143
5941
|
|
|
5144
|
-
class TextChunkerTask extends
|
|
5942
|
+
class TextChunkerTask extends Task16 {
|
|
5145
5943
|
static type = "TextChunkerTask";
|
|
5146
5944
|
static category = "Document";
|
|
5147
5945
|
static title = "Text Chunker";
|
|
@@ -5319,13 +6117,13 @@ class TextChunkerTask extends Task15 {
|
|
|
5319
6117
|
}
|
|
5320
6118
|
}
|
|
5321
6119
|
var textChunker = (input, config) => {
|
|
5322
|
-
return new TextChunkerTask(
|
|
6120
|
+
return new TextChunkerTask(config).run(input);
|
|
5323
6121
|
};
|
|
5324
|
-
|
|
6122
|
+
Workflow35.prototype.textChunker = CreateWorkflow35(TextChunkerTask);
|
|
5325
6123
|
|
|
5326
6124
|
// src/task/TextFillMaskTask.ts
|
|
5327
|
-
import { CreateWorkflow as
|
|
5328
|
-
var
|
|
6125
|
+
import { CreateWorkflow as CreateWorkflow36, Workflow as Workflow36 } from "@workglow/task-graph";
|
|
6126
|
+
var modelSchema24 = TypeModel("model:TextFillMaskTask");
|
|
5329
6127
|
var TextFillMaskInputSchema = {
|
|
5330
6128
|
type: "object",
|
|
5331
6129
|
properties: {
|
|
@@ -5334,7 +6132,7 @@ var TextFillMaskInputSchema = {
|
|
|
5334
6132
|
title: "Text",
|
|
5335
6133
|
description: "The text with a mask token to fill"
|
|
5336
6134
|
},
|
|
5337
|
-
model:
|
|
6135
|
+
model: modelSchema24
|
|
5338
6136
|
},
|
|
5339
6137
|
required: ["text", "model"],
|
|
5340
6138
|
additionalProperties: false
|
|
@@ -5387,23 +6185,23 @@ class TextFillMaskTask extends AiTask {
|
|
|
5387
6185
|
}
|
|
5388
6186
|
}
|
|
5389
6187
|
var textFillMask = (input, config) => {
|
|
5390
|
-
return new TextFillMaskTask(
|
|
6188
|
+
return new TextFillMaskTask(config).run(input);
|
|
5391
6189
|
};
|
|
5392
|
-
|
|
6190
|
+
Workflow36.prototype.textFillMask = CreateWorkflow36(TextFillMaskTask);
|
|
5393
6191
|
|
|
5394
6192
|
// src/task/TextGenerationTask.ts
|
|
5395
|
-
import { CreateWorkflow as
|
|
6193
|
+
import { CreateWorkflow as CreateWorkflow37, Workflow as Workflow37 } from "@workglow/task-graph";
|
|
5396
6194
|
var generatedTextSchema2 = {
|
|
5397
6195
|
type: "string",
|
|
5398
6196
|
title: "Text",
|
|
5399
6197
|
description: "The generated text",
|
|
5400
6198
|
"x-stream": "append"
|
|
5401
6199
|
};
|
|
5402
|
-
var
|
|
6200
|
+
var modelSchema25 = TypeModel("model:TextGenerationTask");
|
|
5403
6201
|
var TextGenerationInputSchema = {
|
|
5404
6202
|
type: "object",
|
|
5405
6203
|
properties: {
|
|
5406
|
-
model:
|
|
6204
|
+
model: modelSchema25,
|
|
5407
6205
|
prompt: {
|
|
5408
6206
|
type: "string",
|
|
5409
6207
|
title: "Prompt",
|
|
@@ -5475,13 +6273,13 @@ class TextGenerationTask extends StreamingAiTask {
|
|
|
5475
6273
|
}
|
|
5476
6274
|
}
|
|
5477
6275
|
var textGeneration = (input, config) => {
|
|
5478
|
-
return new TextGenerationTask(
|
|
6276
|
+
return new TextGenerationTask(config).run(input);
|
|
5479
6277
|
};
|
|
5480
|
-
|
|
6278
|
+
Workflow37.prototype.textGeneration = CreateWorkflow37(TextGenerationTask);
|
|
5481
6279
|
|
|
5482
6280
|
// src/task/TextLanguageDetectionTask.ts
|
|
5483
|
-
import { CreateWorkflow as
|
|
5484
|
-
var
|
|
6281
|
+
import { CreateWorkflow as CreateWorkflow38, Workflow as Workflow38 } from "@workglow/task-graph";
|
|
6282
|
+
var modelSchema26 = TypeModel("model:TextLanguageDetectionTask");
|
|
5485
6283
|
var TextLanguageDetectionInputSchema = {
|
|
5486
6284
|
type: "object",
|
|
5487
6285
|
properties: {
|
|
@@ -5498,7 +6296,7 @@ var TextLanguageDetectionInputSchema = {
|
|
|
5498
6296
|
title: "Max Languages",
|
|
5499
6297
|
description: "The maximum number of languages to return"
|
|
5500
6298
|
},
|
|
5501
|
-
model:
|
|
6299
|
+
model: modelSchema26
|
|
5502
6300
|
},
|
|
5503
6301
|
required: ["text", "model"],
|
|
5504
6302
|
additionalProperties: false
|
|
@@ -5546,12 +6344,12 @@ class TextLanguageDetectionTask extends AiTask {
|
|
|
5546
6344
|
}
|
|
5547
6345
|
}
|
|
5548
6346
|
var textLanguageDetection = (input, config) => {
|
|
5549
|
-
return new TextLanguageDetectionTask(
|
|
6347
|
+
return new TextLanguageDetectionTask(config).run(input);
|
|
5550
6348
|
};
|
|
5551
|
-
|
|
6349
|
+
Workflow38.prototype.textLanguageDetection = CreateWorkflow38(TextLanguageDetectionTask);
|
|
5552
6350
|
|
|
5553
6351
|
// src/task/TextQuestionAnswerTask.ts
|
|
5554
|
-
import { CreateWorkflow as
|
|
6352
|
+
import { CreateWorkflow as CreateWorkflow39, Workflow as Workflow39 } from "@workglow/task-graph";
|
|
5555
6353
|
var contextSchema = {
|
|
5556
6354
|
type: "string",
|
|
5557
6355
|
title: "Context",
|
|
@@ -5568,13 +6366,13 @@ var textSchema = {
|
|
|
5568
6366
|
description: "The generated text",
|
|
5569
6367
|
"x-stream": "append"
|
|
5570
6368
|
};
|
|
5571
|
-
var
|
|
6369
|
+
var modelSchema27 = TypeModel("model:TextQuestionAnswerTask");
|
|
5572
6370
|
var TextQuestionAnswerInputSchema = {
|
|
5573
6371
|
type: "object",
|
|
5574
6372
|
properties: {
|
|
5575
6373
|
context: contextSchema,
|
|
5576
6374
|
question: questionSchema,
|
|
5577
|
-
model:
|
|
6375
|
+
model: modelSchema27
|
|
5578
6376
|
},
|
|
5579
6377
|
required: ["context", "question", "model"],
|
|
5580
6378
|
additionalProperties: false
|
|
@@ -5601,13 +6399,13 @@ class TextQuestionAnswerTask extends StreamingAiTask {
|
|
|
5601
6399
|
}
|
|
5602
6400
|
}
|
|
5603
6401
|
var textQuestionAnswer = (input, config) => {
|
|
5604
|
-
return new TextQuestionAnswerTask(
|
|
6402
|
+
return new TextQuestionAnswerTask(config).run(input);
|
|
5605
6403
|
};
|
|
5606
|
-
|
|
6404
|
+
Workflow39.prototype.textQuestionAnswer = CreateWorkflow39(TextQuestionAnswerTask);
|
|
5607
6405
|
|
|
5608
6406
|
// src/task/TextRewriterTask.ts
|
|
5609
|
-
import { CreateWorkflow as
|
|
5610
|
-
var
|
|
6407
|
+
import { CreateWorkflow as CreateWorkflow40, Workflow as Workflow40 } from "@workglow/task-graph";
|
|
6408
|
+
var modelSchema28 = TypeModel("model:TextRewriterTask");
|
|
5611
6409
|
var TextRewriterInputSchema = {
|
|
5612
6410
|
type: "object",
|
|
5613
6411
|
properties: {
|
|
@@ -5621,7 +6419,7 @@ var TextRewriterInputSchema = {
|
|
|
5621
6419
|
title: "Prompt",
|
|
5622
6420
|
description: "The prompt to direct the rewriting"
|
|
5623
6421
|
},
|
|
5624
|
-
model:
|
|
6422
|
+
model: modelSchema28
|
|
5625
6423
|
},
|
|
5626
6424
|
required: ["text", "prompt", "model"],
|
|
5627
6425
|
additionalProperties: false
|
|
@@ -5653,13 +6451,13 @@ class TextRewriterTask extends StreamingAiTask {
|
|
|
5653
6451
|
}
|
|
5654
6452
|
}
|
|
5655
6453
|
var textRewriter = (input, config) => {
|
|
5656
|
-
return new TextRewriterTask(
|
|
6454
|
+
return new TextRewriterTask(config).run(input);
|
|
5657
6455
|
};
|
|
5658
|
-
|
|
6456
|
+
Workflow40.prototype.textRewriter = CreateWorkflow40(TextRewriterTask);
|
|
5659
6457
|
|
|
5660
6458
|
// src/task/TextTranslationTask.ts
|
|
5661
|
-
import { CreateWorkflow as
|
|
5662
|
-
var
|
|
6459
|
+
import { CreateWorkflow as CreateWorkflow41, Workflow as Workflow41 } from "@workglow/task-graph";
|
|
6460
|
+
var modelSchema29 = TypeModel("model:TextTranslationTask");
|
|
5663
6461
|
var translationTextSchema = {
|
|
5664
6462
|
type: "string",
|
|
5665
6463
|
title: "Text",
|
|
@@ -5686,7 +6484,7 @@ var TextTranslationInputSchema = {
|
|
|
5686
6484
|
minLength: 2,
|
|
5687
6485
|
maxLength: 2
|
|
5688
6486
|
}),
|
|
5689
|
-
model:
|
|
6487
|
+
model: modelSchema29
|
|
5690
6488
|
},
|
|
5691
6489
|
required: ["text", "source_lang", "target_lang", "model"],
|
|
5692
6490
|
additionalProperties: false
|
|
@@ -5719,12 +6517,12 @@ class TextTranslationTask extends StreamingAiTask {
|
|
|
5719
6517
|
}
|
|
5720
6518
|
}
|
|
5721
6519
|
var textTranslation = (input, config) => {
|
|
5722
|
-
return new TextTranslationTask(
|
|
6520
|
+
return new TextTranslationTask(config).run(input);
|
|
5723
6521
|
};
|
|
5724
|
-
|
|
6522
|
+
Workflow41.prototype.textTranslation = CreateWorkflow41(TextTranslationTask);
|
|
5725
6523
|
|
|
5726
6524
|
// src/task/TopicSegmenterTask.ts
|
|
5727
|
-
import { CreateWorkflow as
|
|
6525
|
+
import { CreateWorkflow as CreateWorkflow42, Task as Task17, Workflow as Workflow42 } from "@workglow/task-graph";
|
|
5728
6526
|
var SegmentationMethod = {
|
|
5729
6527
|
HEURISTIC: "heuristic",
|
|
5730
6528
|
EMBEDDING_SIMILARITY: "embedding-similarity",
|
|
@@ -5799,7 +6597,7 @@ var outputSchema14 = {
|
|
|
5799
6597
|
additionalProperties: false
|
|
5800
6598
|
};
|
|
5801
6599
|
|
|
5802
|
-
class TopicSegmenterTask extends
|
|
6600
|
+
class TopicSegmenterTask extends Task17 {
|
|
5803
6601
|
static type = "TopicSegmenterTask";
|
|
5804
6602
|
static category = "Document";
|
|
5805
6603
|
static title = "Topic Segmenter";
|
|
@@ -6002,17 +6800,17 @@ class TopicSegmenterTask extends Task16 {
|
|
|
6002
6800
|
}
|
|
6003
6801
|
}
|
|
6004
6802
|
var topicSegmenter = (input, config) => {
|
|
6005
|
-
return new TopicSegmenterTask(
|
|
6803
|
+
return new TopicSegmenterTask(config).run(input);
|
|
6006
6804
|
};
|
|
6007
|
-
|
|
6805
|
+
Workflow42.prototype.topicSegmenter = CreateWorkflow42(TopicSegmenterTask);
|
|
6008
6806
|
|
|
6009
6807
|
// src/task/UnloadModelTask.ts
|
|
6010
|
-
import { CreateWorkflow as
|
|
6011
|
-
var
|
|
6808
|
+
import { CreateWorkflow as CreateWorkflow43, Workflow as Workflow43 } from "@workglow/task-graph";
|
|
6809
|
+
var modelSchema30 = TypeModel("model");
|
|
6012
6810
|
var UnloadModelInputSchema = {
|
|
6013
6811
|
type: "object",
|
|
6014
6812
|
properties: {
|
|
6015
|
-
model:
|
|
6813
|
+
model: modelSchema30
|
|
6016
6814
|
},
|
|
6017
6815
|
required: ["model"],
|
|
6018
6816
|
additionalProperties: false
|
|
@@ -6020,7 +6818,7 @@ var UnloadModelInputSchema = {
|
|
|
6020
6818
|
var UnloadModelOutputSchema = {
|
|
6021
6819
|
type: "object",
|
|
6022
6820
|
properties: {
|
|
6023
|
-
model:
|
|
6821
|
+
model: modelSchema30
|
|
6024
6822
|
},
|
|
6025
6823
|
required: ["model"],
|
|
6026
6824
|
additionalProperties: false
|
|
@@ -6040,12 +6838,12 @@ class UnloadModelTask extends AiTask {
|
|
|
6040
6838
|
static cacheable = false;
|
|
6041
6839
|
}
|
|
6042
6840
|
var unloadModel = (input, config) => {
|
|
6043
|
-
return new UnloadModelTask(
|
|
6841
|
+
return new UnloadModelTask(config).run(input);
|
|
6044
6842
|
};
|
|
6045
|
-
|
|
6843
|
+
Workflow43.prototype.unloadModel = CreateWorkflow43(UnloadModelTask);
|
|
6046
6844
|
|
|
6047
6845
|
// src/task/VectorQuantizeTask.ts
|
|
6048
|
-
import { CreateWorkflow as
|
|
6846
|
+
import { CreateWorkflow as CreateWorkflow44, Task as Task18, Workflow as Workflow44 } from "@workglow/task-graph";
|
|
6049
6847
|
import {
|
|
6050
6848
|
normalizeNumberArray,
|
|
6051
6849
|
TensorType,
|
|
@@ -6125,7 +6923,7 @@ var outputSchema15 = {
|
|
|
6125
6923
|
additionalProperties: false
|
|
6126
6924
|
};
|
|
6127
6925
|
|
|
6128
|
-
class VectorQuantizeTask extends
|
|
6926
|
+
class VectorQuantizeTask extends Task18 {
|
|
6129
6927
|
static type = "VectorQuantizeTask";
|
|
6130
6928
|
static category = "Vector";
|
|
6131
6929
|
static title = "Quantize";
|
|
@@ -6223,12 +7021,12 @@ class VectorQuantizeTask extends Task17 {
|
|
|
6223
7021
|
}
|
|
6224
7022
|
}
|
|
6225
7023
|
var vectorQuantize = (input, config) => {
|
|
6226
|
-
return new VectorQuantizeTask(
|
|
7024
|
+
return new VectorQuantizeTask(config).run(input);
|
|
6227
7025
|
};
|
|
6228
|
-
|
|
7026
|
+
Workflow44.prototype.vectorQuantize = CreateWorkflow44(VectorQuantizeTask);
|
|
6229
7027
|
|
|
6230
7028
|
// src/task/VectorSimilarityTask.ts
|
|
6231
|
-
import { CreateWorkflow as
|
|
7029
|
+
import { CreateWorkflow as CreateWorkflow45, GraphAsTask, Workflow as Workflow45 } from "@workglow/task-graph";
|
|
6232
7030
|
import {
|
|
6233
7031
|
cosineSimilarity,
|
|
6234
7032
|
hammingSimilarity,
|
|
@@ -6332,13 +7130,210 @@ class VectorSimilarityTask extends GraphAsTask {
|
|
|
6332
7130
|
}
|
|
6333
7131
|
}
|
|
6334
7132
|
var similarity = (input, config) => {
|
|
6335
|
-
return new VectorSimilarityTask(
|
|
6336
|
-
};
|
|
6337
|
-
|
|
7133
|
+
return new VectorSimilarityTask(config).run(input);
|
|
7134
|
+
};
|
|
7135
|
+
Workflow45.prototype.similarity = CreateWorkflow45(VectorSimilarityTask);
|
|
7136
|
+
// src/task/MessageConversion.ts
|
|
7137
|
+
function getInputMessages(input) {
|
|
7138
|
+
const messages = input.messages;
|
|
7139
|
+
if (!messages || messages.length === 0)
|
|
7140
|
+
return;
|
|
7141
|
+
return messages;
|
|
7142
|
+
}
|
|
7143
|
+
function toOpenAIMessages(input) {
|
|
7144
|
+
const messages = [];
|
|
7145
|
+
if (input.systemPrompt) {
|
|
7146
|
+
messages.push({ role: "system", content: input.systemPrompt });
|
|
7147
|
+
}
|
|
7148
|
+
const inputMessages = getInputMessages(input);
|
|
7149
|
+
if (!inputMessages) {
|
|
7150
|
+
if (!Array.isArray(input.prompt)) {
|
|
7151
|
+
messages.push({ role: "user", content: input.prompt });
|
|
7152
|
+
} else if (input.prompt.every((item) => typeof item === "string")) {
|
|
7153
|
+
messages.push({ role: "user", content: input.prompt.join(`
|
|
7154
|
+
`) });
|
|
7155
|
+
} else {
|
|
7156
|
+
const parts = [];
|
|
7157
|
+
for (const item of input.prompt) {
|
|
7158
|
+
if (typeof item === "string") {
|
|
7159
|
+
parts.push({ type: "text", text: item });
|
|
7160
|
+
} else {
|
|
7161
|
+
const b = item;
|
|
7162
|
+
if (b.type === "text") {
|
|
7163
|
+
parts.push({ type: "text", text: b.text });
|
|
7164
|
+
} else if (b.type === "image") {
|
|
7165
|
+
parts.push({
|
|
7166
|
+
type: "image_url",
|
|
7167
|
+
image_url: { url: `data:${b.mimeType};base64,${b.data}` }
|
|
7168
|
+
});
|
|
7169
|
+
} else if (b.type === "audio") {
|
|
7170
|
+
const format = b.mimeType.replace(/^audio\//, "");
|
|
7171
|
+
parts.push({
|
|
7172
|
+
type: "input_audio",
|
|
7173
|
+
input_audio: { data: b.data, format }
|
|
7174
|
+
});
|
|
7175
|
+
}
|
|
7176
|
+
}
|
|
7177
|
+
}
|
|
7178
|
+
messages.push({ role: "user", content: parts });
|
|
7179
|
+
}
|
|
7180
|
+
return messages;
|
|
7181
|
+
}
|
|
7182
|
+
for (const msg of inputMessages) {
|
|
7183
|
+
if (msg.role === "user") {
|
|
7184
|
+
if (typeof msg.content === "string") {
|
|
7185
|
+
messages.push({ role: "user", content: msg.content });
|
|
7186
|
+
} else if (Array.isArray(msg.content) && msg.content.length > 0 && typeof msg.content[0]?.type === "string") {
|
|
7187
|
+
const parts = [];
|
|
7188
|
+
for (const block of msg.content) {
|
|
7189
|
+
const b = block;
|
|
7190
|
+
if (b.type === "text") {
|
|
7191
|
+
parts.push({ type: "text", text: b.text });
|
|
7192
|
+
} else if (b.type === "image") {
|
|
7193
|
+
parts.push({
|
|
7194
|
+
type: "image_url",
|
|
7195
|
+
image_url: { url: `data:${b.mimeType};base64,${b.data}` }
|
|
7196
|
+
});
|
|
7197
|
+
} else if (b.type === "audio") {
|
|
7198
|
+
const format = b.mimeType.replace(/^audio\//, "");
|
|
7199
|
+
parts.push({
|
|
7200
|
+
type: "input_audio",
|
|
7201
|
+
input_audio: { data: b.data, format }
|
|
7202
|
+
});
|
|
7203
|
+
}
|
|
7204
|
+
}
|
|
7205
|
+
messages.push({ role: "user", content: parts });
|
|
7206
|
+
} else {
|
|
7207
|
+
try {
|
|
7208
|
+
messages.push({ role: "user", content: JSON.stringify(msg.content) });
|
|
7209
|
+
} catch {
|
|
7210
|
+
messages.push({ role: "user", content: String(msg.content) });
|
|
7211
|
+
}
|
|
7212
|
+
}
|
|
7213
|
+
} else if (msg.role === "assistant") {
|
|
7214
|
+
if (typeof msg.content === "string") {
|
|
7215
|
+
messages.push({ role: "assistant", content: msg.content.length > 0 ? msg.content : null });
|
|
7216
|
+
} else if (Array.isArray(msg.content)) {
|
|
7217
|
+
const textParts = msg.content.filter((b) => b.type === "text").map((b) => b.text).join("");
|
|
7218
|
+
const toolCalls = msg.content.filter((b) => b.type === "tool_use").map((b) => ({
|
|
7219
|
+
id: b.id,
|
|
7220
|
+
type: "function",
|
|
7221
|
+
function: {
|
|
7222
|
+
name: b.name,
|
|
7223
|
+
arguments: JSON.stringify(b.input)
|
|
7224
|
+
}
|
|
7225
|
+
}));
|
|
7226
|
+
const entry = {
|
|
7227
|
+
role: "assistant",
|
|
7228
|
+
content: textParts.length > 0 ? textParts : null
|
|
7229
|
+
};
|
|
7230
|
+
if (toolCalls.length > 0) {
|
|
7231
|
+
entry.tool_calls = toolCalls;
|
|
7232
|
+
}
|
|
7233
|
+
messages.push(entry);
|
|
7234
|
+
}
|
|
7235
|
+
} else if (msg.role === "tool" && Array.isArray(msg.content)) {
|
|
7236
|
+
for (const block of msg.content) {
|
|
7237
|
+
const b = block;
|
|
7238
|
+
let content;
|
|
7239
|
+
if (typeof b.content === "string") {
|
|
7240
|
+
content = b.content;
|
|
7241
|
+
} else if (Array.isArray(b.content)) {
|
|
7242
|
+
const parts = [];
|
|
7243
|
+
for (const inner of b.content) {
|
|
7244
|
+
if (inner.type === "text") {
|
|
7245
|
+
parts.push({ type: "text", text: inner.text });
|
|
7246
|
+
} else if (inner.type === "image") {
|
|
7247
|
+
parts.push({
|
|
7248
|
+
type: "image_url",
|
|
7249
|
+
image_url: { url: `data:${inner.mimeType};base64,${inner.data}` }
|
|
7250
|
+
});
|
|
7251
|
+
}
|
|
7252
|
+
}
|
|
7253
|
+
content = parts;
|
|
7254
|
+
} else {
|
|
7255
|
+
content = "";
|
|
7256
|
+
}
|
|
7257
|
+
messages.push({
|
|
7258
|
+
role: "tool",
|
|
7259
|
+
content,
|
|
7260
|
+
tool_call_id: b.tool_use_id
|
|
7261
|
+
});
|
|
7262
|
+
}
|
|
7263
|
+
}
|
|
7264
|
+
}
|
|
7265
|
+
return messages;
|
|
7266
|
+
}
|
|
7267
|
+
function toTextFlatMessages(input) {
|
|
7268
|
+
const messages = [];
|
|
7269
|
+
if (input.systemPrompt) {
|
|
7270
|
+
messages.push({ role: "system", content: input.systemPrompt });
|
|
7271
|
+
}
|
|
7272
|
+
const inputMessages = getInputMessages(input);
|
|
7273
|
+
if (!inputMessages) {
|
|
7274
|
+
let promptContent;
|
|
7275
|
+
if (!Array.isArray(input.prompt)) {
|
|
7276
|
+
promptContent = input.prompt;
|
|
7277
|
+
} else {
|
|
7278
|
+
promptContent = input.prompt.map((item) => {
|
|
7279
|
+
if (typeof item === "string")
|
|
7280
|
+
return item;
|
|
7281
|
+
const b = item;
|
|
7282
|
+
return b.type === "text" ? b.text : "";
|
|
7283
|
+
}).filter((s) => s !== "").join(`
|
|
7284
|
+
`);
|
|
7285
|
+
}
|
|
7286
|
+
messages.push({ role: "user", content: promptContent });
|
|
7287
|
+
return messages;
|
|
7288
|
+
}
|
|
7289
|
+
for (const msg of inputMessages) {
|
|
7290
|
+
if (msg.role === "user") {
|
|
7291
|
+
let content = "";
|
|
7292
|
+
if (typeof msg.content === "string") {
|
|
7293
|
+
content = msg.content;
|
|
7294
|
+
} else if (Array.isArray(msg.content) && msg.content.length > 0 && typeof msg.content[0]?.type === "string") {
|
|
7295
|
+
content = msg.content.filter((b) => b.type === "text").map((b) => b.text).join("");
|
|
7296
|
+
} else if (msg.content != null) {
|
|
7297
|
+
try {
|
|
7298
|
+
content = JSON.stringify(msg.content);
|
|
7299
|
+
} catch {
|
|
7300
|
+
content = String(msg.content);
|
|
7301
|
+
}
|
|
7302
|
+
}
|
|
7303
|
+
messages.push({ role: "user", content });
|
|
7304
|
+
} else if (msg.role === "assistant") {
|
|
7305
|
+
if (typeof msg.content === "string") {
|
|
7306
|
+
if (msg.content) {
|
|
7307
|
+
messages.push({ role: "assistant", content: msg.content });
|
|
7308
|
+
}
|
|
7309
|
+
} else if (Array.isArray(msg.content)) {
|
|
7310
|
+
const text = msg.content.filter((b) => b.type === "text").map((b) => b.text).join("");
|
|
7311
|
+
if (text) {
|
|
7312
|
+
messages.push({ role: "assistant", content: text });
|
|
7313
|
+
}
|
|
7314
|
+
}
|
|
7315
|
+
} else if (msg.role === "tool" && Array.isArray(msg.content)) {
|
|
7316
|
+
for (const block of msg.content) {
|
|
7317
|
+
const b = block;
|
|
7318
|
+
let content;
|
|
7319
|
+
if (typeof b.content === "string") {
|
|
7320
|
+
content = b.content;
|
|
7321
|
+
} else if (Array.isArray(b.content)) {
|
|
7322
|
+
content = b.content.filter((inner) => inner.type === "text").map((inner) => inner.text).join("");
|
|
7323
|
+
} else {
|
|
7324
|
+
content = "";
|
|
7325
|
+
}
|
|
7326
|
+
messages.push({ role: "tool", content });
|
|
7327
|
+
}
|
|
7328
|
+
}
|
|
7329
|
+
}
|
|
7330
|
+
return messages;
|
|
7331
|
+
}
|
|
6338
7332
|
|
|
6339
7333
|
// src/task/index.ts
|
|
6340
7334
|
var registerAiTasks = () => {
|
|
6341
7335
|
const tasks = [
|
|
7336
|
+
AgentTask,
|
|
6342
7337
|
BackgroundRemovalTask,
|
|
6343
7338
|
ChunkToVectorTask,
|
|
6344
7339
|
CountTokensTask,
|
|
@@ -6378,6 +7373,7 @@ var registerAiTasks = () => {
|
|
|
6378
7373
|
TextRewriterTask,
|
|
6379
7374
|
TextSummaryTask,
|
|
6380
7375
|
TextTranslationTask,
|
|
7376
|
+
ToolCallingTask,
|
|
6381
7377
|
TopicSegmenterTask,
|
|
6382
7378
|
UnloadModelTask,
|
|
6383
7379
|
VectorQuantizeTask,
|
|
@@ -6389,8 +7385,14 @@ var registerAiTasks = () => {
|
|
|
6389
7385
|
export {
|
|
6390
7386
|
vectorStoreSearch,
|
|
6391
7387
|
vectorQuantize,
|
|
7388
|
+
userMessage,
|
|
6392
7389
|
unloadModel,
|
|
6393
7390
|
topicSegmenter,
|
|
7391
|
+
toolSourceDefinitions,
|
|
7392
|
+
toolMessage,
|
|
7393
|
+
toolCalling,
|
|
7394
|
+
toTextFlatMessages,
|
|
7395
|
+
toOpenAIMessages,
|
|
6394
7396
|
textTranslation,
|
|
6395
7397
|
textSummary,
|
|
6396
7398
|
textRewriter,
|
|
@@ -6402,6 +7404,7 @@ export {
|
|
|
6402
7404
|
textEmbedding,
|
|
6403
7405
|
textClassification,
|
|
6404
7406
|
textChunker,
|
|
7407
|
+
taskTypesToTools,
|
|
6405
7408
|
structuredGeneration,
|
|
6406
7409
|
structuralParser,
|
|
6407
7410
|
similarity,
|
|
@@ -6415,27 +7418,42 @@ export {
|
|
|
6415
7418
|
objectDetection,
|
|
6416
7419
|
modelSearch,
|
|
6417
7420
|
modelInfo,
|
|
7421
|
+
isAllowedToolName,
|
|
6418
7422
|
imageToText,
|
|
6419
7423
|
imageSegmentation,
|
|
6420
7424
|
imageEmbedding,
|
|
6421
7425
|
imageClassification,
|
|
7426
|
+
imageBlockFromDataUri,
|
|
7427
|
+
imageBlock,
|
|
6422
7428
|
hybridSearch,
|
|
6423
7429
|
hierarchyJoin,
|
|
6424
7430
|
hierarchicalChunker,
|
|
7431
|
+
hasToolCalls,
|
|
6425
7432
|
handLandmarker,
|
|
6426
7433
|
getGlobalModelRepository,
|
|
6427
7434
|
getAiProviderRegistry,
|
|
6428
7435
|
gestureRecognizer,
|
|
7436
|
+
findToolSource,
|
|
7437
|
+
filterValidToolCalls,
|
|
6429
7438
|
faceLandmarker,
|
|
6430
7439
|
faceDetector,
|
|
7440
|
+
executeToolCalls,
|
|
7441
|
+
executeToolCall,
|
|
6431
7442
|
downloadModel,
|
|
6432
7443
|
documentEnricher,
|
|
6433
7444
|
countTokens,
|
|
7445
|
+
countAssistantToolUses,
|
|
6434
7446
|
contextBuilder,
|
|
6435
7447
|
chunkVectorUpsert,
|
|
6436
7448
|
chunkToVector,
|
|
6437
7449
|
chunkRetrieval,
|
|
7450
|
+
buildToolSources,
|
|
7451
|
+
buildToolDescription,
|
|
6438
7452
|
backgroundRemoval,
|
|
7453
|
+
audioBlockFromDataUri,
|
|
7454
|
+
audioBlock,
|
|
7455
|
+
assistantMessage,
|
|
7456
|
+
agent,
|
|
6439
7457
|
VectorSimilarityTask,
|
|
6440
7458
|
VectorQuantizeTask,
|
|
6441
7459
|
UnloadModelTask,
|
|
@@ -6449,6 +7467,10 @@ export {
|
|
|
6449
7467
|
TypeBoundingBox,
|
|
6450
7468
|
TypeAudioInput,
|
|
6451
7469
|
TopicSegmenterTask,
|
|
7470
|
+
ToolDefinitionSchema,
|
|
7471
|
+
ToolCallingTask,
|
|
7472
|
+
ToolCallingOutputSchema,
|
|
7473
|
+
ToolCallingInputSchema,
|
|
6452
7474
|
TextTranslationTask,
|
|
6453
7475
|
TextTranslationOutputSchema,
|
|
6454
7476
|
TextTranslationInputSchema,
|
|
@@ -6552,7 +7574,10 @@ export {
|
|
|
6552
7574
|
AiTask,
|
|
6553
7575
|
AiProviderRegistry,
|
|
6554
7576
|
AiProvider,
|
|
6555
|
-
AiJob
|
|
7577
|
+
AiJob,
|
|
7578
|
+
AgentTask,
|
|
7579
|
+
AgentOutputSchema,
|
|
7580
|
+
AgentInputSchema
|
|
6556
7581
|
};
|
|
6557
7582
|
|
|
6558
|
-
//# debugId=
|
|
7583
|
+
//# debugId=64037AF9B0D88FB164756E2164756E21
|