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