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