@workglow/ai 0.2.7 → 0.2.8
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/dist/browser.js +631 -1116
- package/dist/browser.js.map +11 -14
- package/dist/bun.js +631 -1116
- package/dist/bun.js.map +11 -14
- package/dist/job/AiJob.d.ts +2 -0
- package/dist/job/AiJob.d.ts.map +1 -1
- package/dist/node.js +631 -1116
- package/dist/node.js.map +11 -14
- package/dist/provider/AiProvider.d.ts +15 -0
- package/dist/provider/AiProvider.d.ts.map +1 -1
- package/dist/provider/AiProviderRegistry.d.ts +16 -2
- package/dist/provider/AiProviderRegistry.d.ts.map +1 -1
- package/dist/task/ToolCallingTask.d.ts +15 -2
- package/dist/task/ToolCallingTask.d.ts.map +1 -1
- package/dist/task/base/AiTask.d.ts.map +1 -1
- package/dist/task/index.d.ts +1 -5
- package/dist/task/index.d.ts.map +1 -1
- package/dist/worker.js +24 -7
- package/dist/worker.js.map +5 -5
- package/package.json +11 -11
- package/dist/task/AgentTask.d.ts +0 -541
- package/dist/task/AgentTask.d.ts.map +0 -1
- package/dist/task/AgentTypes.d.ts +0 -183
- package/dist/task/AgentTypes.d.ts.map +0 -1
- package/dist/task/AgentUtils.d.ts +0 -55
- package/dist/task/AgentUtils.d.ts.map +0 -1
package/dist/node.js
CHANGED
|
@@ -55,6 +55,19 @@ class AiProviderRegistry {
|
|
|
55
55
|
}
|
|
56
56
|
return this.defaultStrategy;
|
|
57
57
|
}
|
|
58
|
+
createSession(providerName, model) {
|
|
59
|
+
const provider = this.providers.get(providerName);
|
|
60
|
+
if (!provider) {
|
|
61
|
+
throw new Error(`No provider found for "${providerName}". Register the provider before creating sessions.`);
|
|
62
|
+
}
|
|
63
|
+
return provider.createSession(model);
|
|
64
|
+
}
|
|
65
|
+
async disposeSession(providerName, sessionId) {
|
|
66
|
+
const provider = this.providers.get(providerName);
|
|
67
|
+
if (provider) {
|
|
68
|
+
await provider.disposeSession(sessionId);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
58
71
|
getProviderIdsForTask(taskType) {
|
|
59
72
|
const taskMap = this.runFnRegistry.get(taskType);
|
|
60
73
|
if (!taskMap)
|
|
@@ -68,9 +81,9 @@ class AiProviderRegistry {
|
|
|
68
81
|
this.runFnRegistry.get(taskType).set(modelProvider, runFn);
|
|
69
82
|
}
|
|
70
83
|
registerAsWorkerRunFn(modelProvider, taskType) {
|
|
71
|
-
const workerFn = async (input, model, update_progress, signal, outputSchema) => {
|
|
84
|
+
const workerFn = async (input, model, update_progress, signal, outputSchema, sessionId) => {
|
|
72
85
|
const workerManager = globalServiceRegistry.get(WORKER_MANAGER);
|
|
73
|
-
const result = await workerManager.callWorkerFunction(modelProvider, taskType, [input, model, outputSchema], {
|
|
86
|
+
const result = await workerManager.callWorkerFunction(modelProvider, taskType, [input, model, outputSchema, sessionId], {
|
|
74
87
|
signal,
|
|
75
88
|
onProgress: update_progress
|
|
76
89
|
});
|
|
@@ -85,9 +98,9 @@ class AiProviderRegistry {
|
|
|
85
98
|
this.streamFnRegistry.get(taskType).set(modelProvider, streamFn);
|
|
86
99
|
}
|
|
87
100
|
registerAsWorkerStreamFn(modelProvider, taskType) {
|
|
88
|
-
const streamFn = async function* (input, model, signal, outputSchema) {
|
|
101
|
+
const streamFn = async function* (input, model, signal, outputSchema, sessionId) {
|
|
89
102
|
const workerManager = globalServiceRegistry.get(WORKER_MANAGER);
|
|
90
|
-
yield* workerManager.callWorkerStreamFunction(modelProvider, taskType, [input, model, outputSchema], { signal });
|
|
103
|
+
yield* workerManager.callWorkerStreamFunction(modelProvider, taskType, [input, model, outputSchema, sessionId], { signal });
|
|
91
104
|
};
|
|
92
105
|
this.registerStreamFn(modelProvider, taskType, streamFn);
|
|
93
106
|
}
|
|
@@ -215,7 +228,7 @@ class AiJob extends Job {
|
|
|
215
228
|
const timeoutMs = resolveAiJobTimeoutMs(input.aiProvider, input.timeoutMs);
|
|
216
229
|
const timeoutSignal = AbortSignal.timeout(timeoutMs);
|
|
217
230
|
const combinedSignal = AbortSignal.any([context.signal, timeoutSignal]);
|
|
218
|
-
return await fn(input.taskInput, model, context.updateProgress, combinedSignal, input.outputSchema);
|
|
231
|
+
return await fn(input.taskInput, model, context.updateProgress, combinedSignal, input.outputSchema, input.sessionId);
|
|
219
232
|
};
|
|
220
233
|
const runFnPromise = runFn();
|
|
221
234
|
return await Promise.race([runFnPromise, abortPromise]);
|
|
@@ -243,7 +256,7 @@ class AiJob extends Job {
|
|
|
243
256
|
const timeoutSignal = AbortSignal.timeout(timeoutMs);
|
|
244
257
|
const combinedSignal = AbortSignal.any([context.signal, timeoutSignal]);
|
|
245
258
|
try {
|
|
246
|
-
for await (const event of streamFn(input.taskInput, model, combinedSignal, input.outputSchema)) {
|
|
259
|
+
for await (const event of streamFn(input.taskInput, model, combinedSignal, input.outputSchema, input.sessionId)) {
|
|
247
260
|
if (event.type === "finish") {
|
|
248
261
|
lastFinishData = event.data;
|
|
249
262
|
}
|
|
@@ -759,6 +772,10 @@ class AiProvider {
|
|
|
759
772
|
}
|
|
760
773
|
async onInitialize(_options) {}
|
|
761
774
|
async dispose() {}
|
|
775
|
+
createSession(_model) {
|
|
776
|
+
return crypto.randomUUID();
|
|
777
|
+
}
|
|
778
|
+
async disposeSession(_sessionId) {}
|
|
762
779
|
async afterRegister(_options) {}
|
|
763
780
|
}
|
|
764
781
|
|
|
@@ -782,74 +799,8 @@ class QueuedAiProvider extends AiProvider {
|
|
|
782
799
|
// src/task/index.ts
|
|
783
800
|
import { TaskRegistry } from "@workglow/task-graph";
|
|
784
801
|
|
|
785
|
-
// src/task/
|
|
786
|
-
import { CreateWorkflow
|
|
787
|
-
import { getLogger as getLogger4 } from "@workglow/util";
|
|
788
|
-
|
|
789
|
-
// src/task/AgentTypes.ts
|
|
790
|
-
import { parseDataUri } from "@workglow/util/media";
|
|
791
|
-
function imageBlock(mimeType, data) {
|
|
792
|
-
return { type: "image", mimeType, data };
|
|
793
|
-
}
|
|
794
|
-
function audioBlock(mimeType, data) {
|
|
795
|
-
return { type: "audio", mimeType, data };
|
|
796
|
-
}
|
|
797
|
-
function imageBlockFromDataUri(dataUri) {
|
|
798
|
-
const { mimeType, base64 } = parseDataUri(dataUri);
|
|
799
|
-
return { type: "image", mimeType, data: base64 };
|
|
800
|
-
}
|
|
801
|
-
function audioBlockFromDataUri(dataUri) {
|
|
802
|
-
const { mimeType, base64 } = parseDataUri(dataUri);
|
|
803
|
-
return { type: "audio", mimeType, data: base64 };
|
|
804
|
-
}
|
|
805
|
-
function userMessage(prompt) {
|
|
806
|
-
return { role: "user", content: prompt };
|
|
807
|
-
}
|
|
808
|
-
function assistantMessage(text, toolCalls) {
|
|
809
|
-
const content = [];
|
|
810
|
-
if (text) {
|
|
811
|
-
content.push({ type: "text", text });
|
|
812
|
-
}
|
|
813
|
-
if (toolCalls) {
|
|
814
|
-
for (const tc of toolCalls) {
|
|
815
|
-
content.push({
|
|
816
|
-
type: "tool_use",
|
|
817
|
-
id: tc.id,
|
|
818
|
-
name: tc.name,
|
|
819
|
-
input: tc.input
|
|
820
|
-
});
|
|
821
|
-
}
|
|
822
|
-
}
|
|
823
|
-
return { role: "assistant", content };
|
|
824
|
-
}
|
|
825
|
-
function toolMessage(results) {
|
|
826
|
-
return {
|
|
827
|
-
role: "tool",
|
|
828
|
-
content: results.map((r) => {
|
|
829
|
-
const jsonText = JSON.stringify(r.output);
|
|
830
|
-
const content = r.mediaContent && r.mediaContent.length > 0 ? [{ type: "text", text: jsonText }, ...r.mediaContent] : jsonText;
|
|
831
|
-
return {
|
|
832
|
-
type: "tool_result",
|
|
833
|
-
tool_use_id: r.toolCallId,
|
|
834
|
-
content,
|
|
835
|
-
is_error: r.isError || undefined
|
|
836
|
-
};
|
|
837
|
-
})
|
|
838
|
-
};
|
|
839
|
-
}
|
|
840
|
-
function toolSourceDefinitions(sources) {
|
|
841
|
-
return sources.map((s) => s.definition);
|
|
842
|
-
}
|
|
843
|
-
function findToolSource(sources, name) {
|
|
844
|
-
return sources.find((s) => s.definition.name === name);
|
|
845
|
-
}
|
|
846
|
-
|
|
847
|
-
// src/task/AgentUtils.ts
|
|
848
|
-
import { getTaskConstructors as getTaskConstructors2, TaskAbortedError } from "@workglow/task-graph";
|
|
849
|
-
import { getLogger as getLogger3 } from "@workglow/util";
|
|
850
|
-
|
|
851
|
-
// src/task/ToolCallingTask.ts
|
|
852
|
-
import { CreateWorkflow, getTaskConstructors, Workflow } from "@workglow/task-graph";
|
|
802
|
+
// src/task/BackgroundRemovalTask.ts
|
|
803
|
+
import { CreateWorkflow, Workflow } from "@workglow/task-graph";
|
|
853
804
|
|
|
854
805
|
// src/task/base/AiTaskSchemas.ts
|
|
855
806
|
var TypeLanguage = (annotations = {}) => ({
|
|
@@ -1008,8 +959,8 @@ var TypeCategory = {
|
|
|
1008
959
|
description: "Classification category with label and score"
|
|
1009
960
|
};
|
|
1010
961
|
|
|
1011
|
-
// src/task/base/
|
|
1012
|
-
import {
|
|
962
|
+
// src/task/base/AiVisionTask.ts
|
|
963
|
+
import { convertImageDataToUseableForm } from "@workglow/util/media";
|
|
1013
964
|
|
|
1014
965
|
// src/task/base/AiTask.ts
|
|
1015
966
|
import {
|
|
@@ -1018,882 +969,184 @@ import {
|
|
|
1018
969
|
TaskConfigSchema,
|
|
1019
970
|
TaskConfigurationError as TaskConfigurationError2,
|
|
1020
971
|
hasStructuredOutput
|
|
1021
|
-
} from "@workglow/task-graph";
|
|
1022
|
-
function schemaFormat(schema) {
|
|
1023
|
-
return typeof schema === "object" && schema !== null && "format" in schema ? schema.format : undefined;
|
|
1024
|
-
}
|
|
1025
|
-
var aiTaskConfigSchema = {
|
|
1026
|
-
type: "object",
|
|
1027
|
-
properties: {
|
|
1028
|
-
...TaskConfigSchema["properties"]
|
|
1029
|
-
},
|
|
1030
|
-
additionalProperties: false
|
|
1031
|
-
};
|
|
1032
|
-
|
|
1033
|
-
class AiTask extends Task {
|
|
1034
|
-
static type = "AiTask";
|
|
1035
|
-
static hasDynamicEntitlements = true;
|
|
1036
|
-
static entitlements() {
|
|
1037
|
-
return {
|
|
1038
|
-
entitlements: [{ id: Entitlements.AI_INFERENCE, reason: "Runs AI model inference" }]
|
|
1039
|
-
};
|
|
1040
|
-
}
|
|
1041
|
-
entitlements() {
|
|
1042
|
-
const base = [
|
|
1043
|
-
{ id: Entitlements.AI_INFERENCE, reason: "Runs AI model inference" }
|
|
1044
|
-
];
|
|
1045
|
-
const runModel = this.runInputData?.model;
|
|
1046
|
-
const modelId = typeof runModel === "string" ? runModel : typeof this.defaults.model === "string" ? this.defaults.model : undefined;
|
|
1047
|
-
if (modelId) {
|
|
1048
|
-
base.push({
|
|
1049
|
-
id: Entitlements.AI_MODEL,
|
|
1050
|
-
reason: `Uses model ${modelId}`,
|
|
1051
|
-
resources: [modelId]
|
|
1052
|
-
});
|
|
1053
|
-
}
|
|
1054
|
-
return { entitlements: base };
|
|
1055
|
-
}
|
|
1056
|
-
static configSchema() {
|
|
1057
|
-
return aiTaskConfigSchema;
|
|
1058
|
-
}
|
|
1059
|
-
async execute(input, executeContext) {
|
|
1060
|
-
const model = input.model;
|
|
1061
|
-
if (!model || typeof model !== "object") {
|
|
1062
|
-
throw new TaskConfigurationError2("AiTask: Model was not resolved to ModelConfig - this indicates a bug in the resolution system");
|
|
1063
|
-
}
|
|
1064
|
-
const jobInput = await this.getJobInput(input);
|
|
1065
|
-
const strategy = getAiProviderRegistry().getStrategy(model);
|
|
1066
|
-
const output = await strategy.execute(jobInput, executeContext, this.runConfig.runnerId);
|
|
1067
|
-
if (executeContext.resourceScope) {
|
|
1068
|
-
const registry = getAiProviderRegistry();
|
|
1069
|
-
const provider = registry.getProvider(model.provider);
|
|
1070
|
-
const unloadFn = provider?.getRunFn("UnloadModelTask");
|
|
1071
|
-
if (unloadFn) {
|
|
1072
|
-
const modelPath = model.provider_config?.model_path ?? model.model;
|
|
1073
|
-
const resourceKey = `ai:${model.provider}:${modelPath}`;
|
|
1074
|
-
executeContext.resourceScope.register(resourceKey, async () => {
|
|
1075
|
-
await unloadFn({ model }, model, () => {}, AbortSignal.timeout(30000));
|
|
1076
|
-
});
|
|
1077
|
-
}
|
|
1078
|
-
}
|
|
1079
|
-
return output;
|
|
1080
|
-
}
|
|
1081
|
-
async getJobInput(input) {
|
|
1082
|
-
const model = input.model;
|
|
1083
|
-
const runtype = this.constructor.runtype ?? this.constructor.type;
|
|
1084
|
-
const jobInput = {
|
|
1085
|
-
taskType: runtype,
|
|
1086
|
-
aiProvider: model.provider,
|
|
1087
|
-
taskInput: input
|
|
1088
|
-
};
|
|
1089
|
-
const taskTimeoutMs = this.config.timeout;
|
|
1090
|
-
if (typeof taskTimeoutMs === "number" && taskTimeoutMs > 0) {
|
|
1091
|
-
jobInput.timeoutMs = taskTimeoutMs;
|
|
1092
|
-
}
|
|
1093
|
-
const inputOutputSchema = input.outputSchema;
|
|
1094
|
-
if (inputOutputSchema && typeof inputOutputSchema === "object" && !Array.isArray(inputOutputSchema) && typeof inputOutputSchema.type === "string") {
|
|
1095
|
-
jobInput.outputSchema = inputOutputSchema;
|
|
1096
|
-
} else {
|
|
1097
|
-
const taskOutputSchema = this.outputSchema();
|
|
1098
|
-
if (hasStructuredOutput(taskOutputSchema)) {
|
|
1099
|
-
jobInput.outputSchema = taskOutputSchema;
|
|
1100
|
-
}
|
|
1101
|
-
}
|
|
1102
|
-
return jobInput;
|
|
1103
|
-
}
|
|
1104
|
-
async createJob(input, queueName) {
|
|
1105
|
-
const jobInput = await this.getJobInput(input);
|
|
1106
|
-
const resolvedQueueName = queueName ?? await this.getDefaultQueueName(input);
|
|
1107
|
-
if (!resolvedQueueName) {
|
|
1108
|
-
throw new TaskConfigurationError2("AiTask: Unable to determine queue for AI provider");
|
|
1109
|
-
}
|
|
1110
|
-
const job = new AiJob({
|
|
1111
|
-
queueName: resolvedQueueName,
|
|
1112
|
-
jobRunId: this.runConfig.runnerId,
|
|
1113
|
-
input: jobInput
|
|
1114
|
-
});
|
|
1115
|
-
return job;
|
|
1116
|
-
}
|
|
1117
|
-
async getDefaultQueueName(input) {
|
|
1118
|
-
const model = input.model;
|
|
1119
|
-
return model?.provider;
|
|
1120
|
-
}
|
|
1121
|
-
async executeReactive(input, output, context) {
|
|
1122
|
-
const model = input.model;
|
|
1123
|
-
if (model && typeof model === "object" && model.provider) {
|
|
1124
|
-
const taskType = this.constructor.runtype ?? this.constructor.type;
|
|
1125
|
-
const reactiveFn = getAiProviderRegistry().getReactiveRunFn(model.provider, taskType);
|
|
1126
|
-
if (reactiveFn) {
|
|
1127
|
-
return reactiveFn(input, output, model);
|
|
1128
|
-
}
|
|
1129
|
-
}
|
|
1130
|
-
return super.executeReactive(input, output, context);
|
|
1131
|
-
}
|
|
1132
|
-
async validateInput(input) {
|
|
1133
|
-
const inputSchema = this.inputSchema();
|
|
1134
|
-
if (typeof inputSchema === "boolean") {
|
|
1135
|
-
if (inputSchema === false) {
|
|
1136
|
-
throw new TaskConfigurationError2(`AiTask: Input schema is 'false' and accepts no inputs`);
|
|
1137
|
-
}
|
|
1138
|
-
return true;
|
|
1139
|
-
}
|
|
1140
|
-
const modelTaskProperties = Object.entries(inputSchema.properties || {}).filter(([key, schema]) => schemaFormat(schema)?.startsWith("model:"));
|
|
1141
|
-
for (const [key] of modelTaskProperties) {
|
|
1142
|
-
const model = input[key];
|
|
1143
|
-
if (typeof model === "object" && model !== null) {
|
|
1144
|
-
const tasks = model.tasks;
|
|
1145
|
-
if (Array.isArray(tasks) && tasks.length > 0 && !tasks.includes(this.type)) {
|
|
1146
|
-
const modelId = model.model_id ?? "(inline config)";
|
|
1147
|
-
throw new TaskConfigurationError2(`AiTask: Model "${modelId}" for '${key}' is not compatible with task '${this.type}'. ` + `Model supports: [${tasks.join(", ")}]`);
|
|
1148
|
-
}
|
|
1149
|
-
} else if (model !== undefined && model !== null) {
|
|
1150
|
-
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.`);
|
|
1151
|
-
}
|
|
1152
|
-
}
|
|
1153
|
-
const modelPlainProperties = Object.entries(inputSchema.properties || {}).filter(([key, schema]) => schemaFormat(schema) === "model");
|
|
1154
|
-
for (const [key] of modelPlainProperties) {
|
|
1155
|
-
const model = input[key];
|
|
1156
|
-
if (model !== undefined && model !== null && typeof model !== "object") {
|
|
1157
|
-
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.`);
|
|
1158
|
-
}
|
|
1159
|
-
}
|
|
1160
|
-
return super.validateInput(input);
|
|
1161
|
-
}
|
|
1162
|
-
async narrowInput(input, registry) {
|
|
1163
|
-
const inputSchema = this.inputSchema();
|
|
1164
|
-
if (typeof inputSchema === "boolean") {
|
|
1165
|
-
if (inputSchema === false) {
|
|
1166
|
-
throw new TaskConfigurationError2(`AiTask: Input schema is 'false' and accepts no inputs`);
|
|
1167
|
-
}
|
|
1168
|
-
return input;
|
|
1169
|
-
}
|
|
1170
|
-
const modelTaskProperties = Object.entries(inputSchema.properties || {}).filter(([key, schema]) => schemaFormat(schema)?.startsWith("model:"));
|
|
1171
|
-
if (modelTaskProperties.length > 0) {
|
|
1172
|
-
const modelRepo = registry.get(MODEL_REPOSITORY);
|
|
1173
|
-
const taskModels = await modelRepo.findModelsByTask(this.type) ?? [];
|
|
1174
|
-
for (const [key] of modelTaskProperties) {
|
|
1175
|
-
const requestedModel = input[key];
|
|
1176
|
-
if (typeof requestedModel === "string") {
|
|
1177
|
-
const found = taskModels?.find((m) => m.model_id === requestedModel);
|
|
1178
|
-
if (!found) {
|
|
1179
|
-
input[key] = undefined;
|
|
1180
|
-
}
|
|
1181
|
-
} else if (typeof requestedModel === "object" && requestedModel !== null) {
|
|
1182
|
-
const model = requestedModel;
|
|
1183
|
-
const tasks = model.tasks;
|
|
1184
|
-
if (Array.isArray(tasks) && tasks.length > 0 && !tasks.includes(this.type)) {
|
|
1185
|
-
input[key] = undefined;
|
|
1186
|
-
}
|
|
1187
|
-
}
|
|
1188
|
-
}
|
|
1189
|
-
}
|
|
1190
|
-
return input;
|
|
1191
|
-
}
|
|
1192
|
-
}
|
|
1193
|
-
|
|
1194
|
-
// src/task/base/StreamingAiTask.ts
|
|
1195
|
-
class StreamingAiTask extends AiTask {
|
|
1196
|
-
static type = "StreamingAiTask";
|
|
1197
|
-
async* executeStream(input, context) {
|
|
1198
|
-
const model = input.model;
|
|
1199
|
-
if (!model || typeof model !== "object") {
|
|
1200
|
-
throw new TaskConfigurationError3("StreamingAiTask: Model was not resolved to ModelConfig - this indicates a bug in the resolution system");
|
|
1201
|
-
}
|
|
1202
|
-
const jobInput = await this.getJobInput(input);
|
|
1203
|
-
const strategy = getAiProviderRegistry().getStrategy(model);
|
|
1204
|
-
const outSchema = this.outputSchema();
|
|
1205
|
-
const ports = getStreamingPorts(outSchema);
|
|
1206
|
-
let defaultPort = "text";
|
|
1207
|
-
if (ports.length > 0) {
|
|
1208
|
-
defaultPort = ports[0].port;
|
|
1209
|
-
} else {
|
|
1210
|
-
if (typeof outSchema === "object" && outSchema.properties) {
|
|
1211
|
-
const firstProp = Object.keys(outSchema.properties)[0];
|
|
1212
|
-
if (firstProp)
|
|
1213
|
-
defaultPort = firstProp;
|
|
1214
|
-
}
|
|
1215
|
-
}
|
|
1216
|
-
for await (const event of strategy.executeStream(jobInput, context, this.runConfig.runnerId)) {
|
|
1217
|
-
if (event.type === "text-delta") {
|
|
1218
|
-
yield { ...event, port: event.port ?? defaultPort };
|
|
1219
|
-
} else if (event.type === "object-delta") {
|
|
1220
|
-
yield { ...event, port: event.port ?? defaultPort };
|
|
1221
|
-
} else {
|
|
1222
|
-
yield event;
|
|
1223
|
-
}
|
|
1224
|
-
}
|
|
1225
|
-
}
|
|
1226
|
-
}
|
|
1227
|
-
|
|
1228
|
-
// src/task/ToolCallingTask.ts
|
|
1229
|
-
function taskTypesToTools(taskNames, registry) {
|
|
1230
|
-
const constructors = getTaskConstructors(registry);
|
|
1231
|
-
return taskNames.map((name) => {
|
|
1232
|
-
const ctor = constructors.get(name);
|
|
1233
|
-
if (!ctor) {
|
|
1234
|
-
throw new Error(`taskTypesToTools: Unknown task type "${name}" — not found in task constructors registry (ServiceRegistry: ${registry ? "custom" : "default"})`);
|
|
1235
|
-
}
|
|
1236
|
-
const configSchema = "configSchema" in ctor && typeof ctor.configSchema === "function" ? ctor.configSchema() : undefined;
|
|
1237
|
-
return {
|
|
1238
|
-
name: ctor.type,
|
|
1239
|
-
description: ctor.description ?? "",
|
|
1240
|
-
inputSchema: ctor.inputSchema(),
|
|
1241
|
-
outputSchema: ctor.outputSchema(),
|
|
1242
|
-
...configSchema ? { configSchema } : {},
|
|
1243
|
-
taskType: name
|
|
1244
|
-
};
|
|
1245
|
-
});
|
|
1246
|
-
}
|
|
1247
|
-
var ToolDefinitionSchema = {
|
|
1248
|
-
type: "object",
|
|
1249
|
-
properties: {
|
|
1250
|
-
name: {
|
|
1251
|
-
type: "string",
|
|
1252
|
-
title: "Name",
|
|
1253
|
-
description: "The tool name"
|
|
1254
|
-
},
|
|
1255
|
-
description: {
|
|
1256
|
-
type: "string",
|
|
1257
|
-
title: "Description",
|
|
1258
|
-
description: "A description of what the tool does"
|
|
1259
|
-
},
|
|
1260
|
-
inputSchema: {
|
|
1261
|
-
type: "object",
|
|
1262
|
-
title: "Input Schema",
|
|
1263
|
-
description: "JSON Schema describing the tool's input parameters",
|
|
1264
|
-
additionalProperties: true
|
|
1265
|
-
},
|
|
1266
|
-
outputSchema: {
|
|
1267
|
-
type: "object",
|
|
1268
|
-
title: "Output Schema",
|
|
1269
|
-
description: "JSON Schema describing what the tool returns",
|
|
1270
|
-
additionalProperties: true
|
|
1271
|
-
},
|
|
1272
|
-
configSchema: {
|
|
1273
|
-
type: "object",
|
|
1274
|
-
title: "Config Schema",
|
|
1275
|
-
description: "JSON Schema describing the task's configuration options (not sent to the LLM)",
|
|
1276
|
-
additionalProperties: true
|
|
1277
|
-
},
|
|
1278
|
-
config: {
|
|
1279
|
-
type: "object",
|
|
1280
|
-
title: "Config",
|
|
1281
|
-
description: "Concrete configuration values for the backing task (not sent to the LLM)",
|
|
1282
|
-
additionalProperties: true
|
|
1283
|
-
}
|
|
1284
|
-
},
|
|
1285
|
-
required: ["name", "description", "inputSchema"],
|
|
1286
|
-
additionalProperties: true
|
|
1287
|
-
};
|
|
1288
|
-
var ToolCallSchema = {
|
|
1289
|
-
type: "object",
|
|
1290
|
-
properties: {
|
|
1291
|
-
id: {
|
|
1292
|
-
type: "string",
|
|
1293
|
-
title: "ID",
|
|
1294
|
-
description: "Unique identifier for this tool call"
|
|
1295
|
-
},
|
|
1296
|
-
name: {
|
|
1297
|
-
type: "string",
|
|
1298
|
-
title: "Name",
|
|
1299
|
-
description: "The name of the tool to invoke"
|
|
1300
|
-
},
|
|
1301
|
-
input: {
|
|
1302
|
-
type: "object",
|
|
1303
|
-
title: "Input",
|
|
1304
|
-
description: "The input arguments for the tool call",
|
|
1305
|
-
additionalProperties: true
|
|
1306
|
-
}
|
|
1307
|
-
},
|
|
1308
|
-
required: ["id", "name", "input"],
|
|
1309
|
-
additionalProperties: false
|
|
1310
|
-
};
|
|
1311
|
-
var modelSchema = TypeModel("model:ToolCallingTask");
|
|
1312
|
-
var ToolCallingInputSchema = {
|
|
1313
|
-
type: "object",
|
|
1314
|
-
properties: {
|
|
1315
|
-
model: modelSchema,
|
|
1316
|
-
prompt: {
|
|
1317
|
-
oneOf: [
|
|
1318
|
-
{ type: "string", title: "Prompt", description: "The prompt to send to the model" },
|
|
1319
|
-
{
|
|
1320
|
-
type: "array",
|
|
1321
|
-
title: "Prompt",
|
|
1322
|
-
description: "The prompt as an array of strings or content blocks",
|
|
1323
|
-
items: {
|
|
1324
|
-
oneOf: [
|
|
1325
|
-
{ type: "string" },
|
|
1326
|
-
{
|
|
1327
|
-
type: "object",
|
|
1328
|
-
properties: {
|
|
1329
|
-
type: { type: "string", enum: ["text", "image", "audio"] }
|
|
1330
|
-
},
|
|
1331
|
-
required: ["type"],
|
|
1332
|
-
additionalProperties: true
|
|
1333
|
-
}
|
|
1334
|
-
]
|
|
1335
|
-
}
|
|
1336
|
-
}
|
|
1337
|
-
],
|
|
1338
|
-
title: "Prompt",
|
|
1339
|
-
description: "The prompt to send to the model"
|
|
1340
|
-
},
|
|
1341
|
-
systemPrompt: {
|
|
1342
|
-
type: "string",
|
|
1343
|
-
title: "System Prompt",
|
|
1344
|
-
description: "Optional system instructions for the model"
|
|
1345
|
-
},
|
|
1346
|
-
messages: {
|
|
1347
|
-
type: "array",
|
|
1348
|
-
title: "Messages",
|
|
1349
|
-
description: "Full conversation history for multi-turn interactions. When provided, used instead of prompt to construct the messages array sent to the provider.",
|
|
1350
|
-
items: {
|
|
1351
|
-
type: "object",
|
|
1352
|
-
properties: {
|
|
1353
|
-
role: { type: "string", enum: ["user", "assistant", "tool"] },
|
|
1354
|
-
content: {}
|
|
1355
|
-
},
|
|
1356
|
-
required: ["role", "content"],
|
|
1357
|
-
additionalProperties: true
|
|
1358
|
-
}
|
|
1359
|
-
},
|
|
1360
|
-
tools: {
|
|
1361
|
-
type: "array",
|
|
1362
|
-
format: "tasks",
|
|
1363
|
-
title: "Tools",
|
|
1364
|
-
description: "Tool definitions available for the model to call",
|
|
1365
|
-
items: {
|
|
1366
|
-
oneOf: [
|
|
1367
|
-
{ type: "string", format: "tasks", description: "Task type name" },
|
|
1368
|
-
ToolDefinitionSchema
|
|
1369
|
-
]
|
|
1370
|
-
}
|
|
1371
|
-
},
|
|
1372
|
-
toolChoice: {
|
|
1373
|
-
type: "string",
|
|
1374
|
-
title: "Tool Choice",
|
|
1375
|
-
description: 'Controls tool selection: "auto" (model decides), "none" (no tools), "required" (must call a tool), or a specific tool name',
|
|
1376
|
-
"x-ui-group": "Configuration"
|
|
1377
|
-
},
|
|
1378
|
-
maxTokens: {
|
|
1379
|
-
type: "number",
|
|
1380
|
-
title: "Max Tokens",
|
|
1381
|
-
description: "The maximum number of tokens to generate",
|
|
1382
|
-
minimum: 1,
|
|
1383
|
-
"x-ui-group": "Configuration"
|
|
1384
|
-
},
|
|
1385
|
-
temperature: {
|
|
1386
|
-
type: "number",
|
|
1387
|
-
title: "Temperature",
|
|
1388
|
-
description: "The temperature to use for sampling",
|
|
1389
|
-
minimum: 0,
|
|
1390
|
-
maximum: 2,
|
|
1391
|
-
"x-ui-group": "Configuration"
|
|
1392
|
-
}
|
|
1393
|
-
},
|
|
1394
|
-
required: ["model", "prompt", "tools"],
|
|
1395
|
-
additionalProperties: false
|
|
1396
|
-
};
|
|
1397
|
-
var ToolCallingOutputSchema = {
|
|
1398
|
-
type: "object",
|
|
1399
|
-
properties: {
|
|
1400
|
-
text: {
|
|
1401
|
-
type: "string",
|
|
1402
|
-
title: "Text",
|
|
1403
|
-
description: "Any text content generated by the model",
|
|
1404
|
-
"x-stream": "append"
|
|
1405
|
-
},
|
|
1406
|
-
toolCalls: {
|
|
1407
|
-
type: "array",
|
|
1408
|
-
items: ToolCallSchema,
|
|
1409
|
-
title: "Tool Calls",
|
|
1410
|
-
description: "Tool calls requested by the model",
|
|
1411
|
-
"x-stream": "object"
|
|
1412
|
-
}
|
|
1413
|
-
},
|
|
1414
|
-
required: ["text", "toolCalls"],
|
|
1415
|
-
additionalProperties: false
|
|
1416
|
-
};
|
|
1417
|
-
|
|
1418
|
-
class ToolCallingTask extends StreamingAiTask {
|
|
1419
|
-
static type = "ToolCallingTask";
|
|
1420
|
-
static category = "AI Text Model";
|
|
1421
|
-
static title = "Tool Calling";
|
|
1422
|
-
static description = "Sends a prompt with tool definitions to a language model and returns text along with any tool calls the model requests";
|
|
1423
|
-
static inputSchema() {
|
|
1424
|
-
return ToolCallingInputSchema;
|
|
1425
|
-
}
|
|
1426
|
-
static outputSchema() {
|
|
1427
|
-
return ToolCallingOutputSchema;
|
|
1428
|
-
}
|
|
1429
|
-
}
|
|
1430
|
-
var toolCalling = (input, config) => {
|
|
1431
|
-
return new ToolCallingTask(config).run(input);
|
|
1432
|
-
};
|
|
1433
|
-
Workflow.prototype.toolCalling = CreateWorkflow(ToolCallingTask);
|
|
1434
|
-
|
|
1435
|
-
// src/task/AgentUtils.ts
|
|
1436
|
-
function resolveToolConfig(toolName, config, taskConfigSchema) {
|
|
1437
|
-
if (config && !taskConfigSchema) {
|
|
1438
|
-
getLogger3().warn(`AgentTask: Tool "${toolName}" provided config but task has no configSchema — config ignored`);
|
|
1439
|
-
return {};
|
|
1440
|
-
}
|
|
1441
|
-
return config;
|
|
1442
|
-
}
|
|
1443
|
-
function buildToolSources(tools, registry) {
|
|
1444
|
-
if (!tools || tools.length === 0)
|
|
1445
|
-
return [];
|
|
1446
|
-
const stringNames = tools.filter((t) => typeof t === "string");
|
|
1447
|
-
const resolvedDefs = new Map(taskTypesToTools(stringNames, registry).map((d) => [d.taskType, d]));
|
|
1448
|
-
const constructors = getTaskConstructors2(registry);
|
|
1449
|
-
const sources = [];
|
|
1450
|
-
for (const tool of tools) {
|
|
1451
|
-
if (typeof tool === "string") {
|
|
1452
|
-
const def = resolvedDefs.get(tool);
|
|
1453
|
-
if (def) {
|
|
1454
|
-
const { taskType, ...definition } = def;
|
|
1455
|
-
sources.push({
|
|
1456
|
-
type: "registry",
|
|
1457
|
-
definition,
|
|
1458
|
-
taskType
|
|
1459
|
-
});
|
|
1460
|
-
}
|
|
1461
|
-
} else if (tool.type === "function" || !tool.type && tool.execute) {
|
|
1462
|
-
if (!tool.execute) {
|
|
1463
|
-
getLogger3().warn(`AgentTask: Tool "${tool.name}" has type "function" but no execute function — will throw on invocation`);
|
|
1464
|
-
}
|
|
1465
|
-
const { execute, configSchema: _cs, config: _c, type: _t, ...definition } = tool;
|
|
1466
|
-
sources.push({
|
|
1467
|
-
type: "function",
|
|
1468
|
-
definition,
|
|
1469
|
-
run: execute ?? (async () => {
|
|
1470
|
-
throw new Error(`No execute function for tool "${tool.name}"`);
|
|
1471
|
-
})
|
|
1472
|
-
});
|
|
1473
|
-
} else if (tool.type === "task") {
|
|
1474
|
-
const ctor = constructors.get(tool.name);
|
|
1475
|
-
if (!ctor) {
|
|
1476
|
-
getLogger3().warn(`AgentTask: Tool "${tool.name}" has type "task" but is not in TaskRegistry — will throw on invocation`);
|
|
1477
|
-
const { execute: _e, configSchema: _cs, config: _c, type: _t, ...definition } = tool;
|
|
1478
|
-
sources.push({
|
|
1479
|
-
type: "function",
|
|
1480
|
-
definition,
|
|
1481
|
-
run: async () => {
|
|
1482
|
-
throw new Error(`Task "${tool.name}" not found in TaskRegistry`);
|
|
1483
|
-
}
|
|
1484
|
-
});
|
|
1485
|
-
} else {
|
|
1486
|
-
const safeConfig = resolveToolConfig(tool.name, tool.config, ctor.configSchema?.());
|
|
1487
|
-
const { execute: _e, configSchema: _cs, config: _c, type: _t, ...definition } = tool;
|
|
1488
|
-
sources.push({
|
|
1489
|
-
type: "registry",
|
|
1490
|
-
definition,
|
|
1491
|
-
taskType: tool.name,
|
|
1492
|
-
config: safeConfig
|
|
1493
|
-
});
|
|
1494
|
-
}
|
|
1495
|
-
} else {
|
|
1496
|
-
const ctor = constructors.get(tool.name);
|
|
1497
|
-
if (ctor) {
|
|
1498
|
-
const safeConfig = resolveToolConfig(tool.name, tool.config, ctor.configSchema?.());
|
|
1499
|
-
const { execute: _e, configSchema: _cs, config: _c, type: _t, ...definition } = tool;
|
|
1500
|
-
sources.push({
|
|
1501
|
-
type: "registry",
|
|
1502
|
-
definition,
|
|
1503
|
-
taskType: tool.name,
|
|
1504
|
-
config: safeConfig
|
|
1505
|
-
});
|
|
1506
|
-
} else {
|
|
1507
|
-
const { execute: _e, configSchema: _cs, config: _c, type: _t, ...definition } = tool;
|
|
1508
|
-
sources.push({
|
|
1509
|
-
type: "function",
|
|
1510
|
-
definition,
|
|
1511
|
-
run: async () => {
|
|
1512
|
-
throw new Error(`No executor registered for tool "${tool.name}"`);
|
|
1513
|
-
}
|
|
1514
|
-
});
|
|
1515
|
-
}
|
|
1516
|
-
}
|
|
1517
|
-
}
|
|
1518
|
-
return sources;
|
|
1519
|
-
}
|
|
1520
|
-
async function executeToolCall(toolCall, sources, context, hooks) {
|
|
1521
|
-
const source = findToolSource(sources, toolCall.name);
|
|
1522
|
-
if (!source) {
|
|
1523
|
-
getLogger3().warn(`AgentTask: Unknown tool "${toolCall.name}" — not found in tool sources`);
|
|
1524
|
-
return {
|
|
1525
|
-
toolCallId: toolCall.id,
|
|
1526
|
-
toolName: toolCall.name,
|
|
1527
|
-
output: { error: `Unknown tool: ${toolCall.name}` },
|
|
1528
|
-
isError: true
|
|
1529
|
-
};
|
|
1530
|
-
}
|
|
1531
|
-
let effectiveCall = toolCall;
|
|
1532
|
-
if (hooks?.beforeToolCall) {
|
|
1533
|
-
const decision = await hooks.beforeToolCall(toolCall, source);
|
|
1534
|
-
if (decision.action === "deny") {
|
|
1535
|
-
return {
|
|
1536
|
-
toolCallId: toolCall.id,
|
|
1537
|
-
toolName: toolCall.name,
|
|
1538
|
-
output: { error: decision.reason ?? "Tool call denied by hook" },
|
|
1539
|
-
isError: true
|
|
1540
|
-
};
|
|
1541
|
-
}
|
|
1542
|
-
if (decision.action === "modify") {
|
|
1543
|
-
effectiveCall = { ...toolCall, input: decision.input };
|
|
1544
|
-
}
|
|
1545
|
-
}
|
|
1546
|
-
try {
|
|
1547
|
-
let output;
|
|
1548
|
-
switch (source.type) {
|
|
1549
|
-
case "registry": {
|
|
1550
|
-
const ctor = getTaskConstructors2(context.registry).get(source.taskType);
|
|
1551
|
-
if (!ctor) {
|
|
1552
|
-
throw new Error(`Task type "${source.taskType}" not found in TaskRegistry`);
|
|
1553
|
-
}
|
|
1554
|
-
const taskConfig = source.config ?? {};
|
|
1555
|
-
const task = context.own(new ctor({}, taskConfig));
|
|
1556
|
-
output = await task.run(effectiveCall.input) ?? {};
|
|
1557
|
-
break;
|
|
1558
|
-
}
|
|
1559
|
-
case "function": {
|
|
1560
|
-
output = await source.run(effectiveCall.input);
|
|
1561
|
-
break;
|
|
1562
|
-
}
|
|
1563
|
-
}
|
|
1564
|
-
let result = {
|
|
1565
|
-
toolCallId: toolCall.id,
|
|
1566
|
-
toolName: toolCall.name,
|
|
1567
|
-
output,
|
|
1568
|
-
isError: false
|
|
1569
|
-
};
|
|
1570
|
-
if (hooks?.afterToolCall) {
|
|
1571
|
-
result = await hooks.afterToolCall(toolCall, result);
|
|
1572
|
-
}
|
|
1573
|
-
return result;
|
|
1574
|
-
} catch (err) {
|
|
1575
|
-
const error = err instanceof Error ? err : new Error(String(err));
|
|
1576
|
-
if (hooks?.onToolError) {
|
|
1577
|
-
const action = await hooks.onToolError(toolCall, error);
|
|
1578
|
-
if (action.action === "result") {
|
|
1579
|
-
return {
|
|
1580
|
-
toolCallId: toolCall.id,
|
|
1581
|
-
toolName: toolCall.name,
|
|
1582
|
-
output: action.output,
|
|
1583
|
-
isError: false
|
|
1584
|
-
};
|
|
1585
|
-
}
|
|
1586
|
-
}
|
|
1587
|
-
getLogger3().warn(`AgentTask: Tool "${toolCall.name}" failed: ${error.message}`);
|
|
1588
|
-
return {
|
|
1589
|
-
toolCallId: toolCall.id,
|
|
1590
|
-
toolName: toolCall.name,
|
|
1591
|
-
output: { error: error.message },
|
|
1592
|
-
isError: true
|
|
1593
|
-
};
|
|
1594
|
-
}
|
|
1595
|
-
}
|
|
1596
|
-
async function executeToolCalls(toolCalls, sources, context, hooks, maxConcurrency = 5) {
|
|
1597
|
-
const calls = toolCalls;
|
|
1598
|
-
if (calls.length === 0)
|
|
1599
|
-
return [];
|
|
1600
|
-
const concurrency = Math.max(1, Math.min(maxConcurrency, calls.length));
|
|
1601
|
-
const results = new Array(calls.length);
|
|
1602
|
-
let cursor = 0;
|
|
1603
|
-
const workers = Array.from({ length: concurrency }, async () => {
|
|
1604
|
-
while (true) {
|
|
1605
|
-
if (context.signal.aborted) {
|
|
1606
|
-
throw context.signal.reason ?? new TaskAbortedError("The operation was aborted");
|
|
1607
|
-
}
|
|
1608
|
-
const position = cursor;
|
|
1609
|
-
cursor += 1;
|
|
1610
|
-
if (position >= calls.length)
|
|
1611
|
-
return;
|
|
1612
|
-
results[position] = await executeToolCall(calls[position], sources, context, hooks);
|
|
1613
|
-
}
|
|
1614
|
-
});
|
|
1615
|
-
await Promise.all(workers);
|
|
1616
|
-
return results;
|
|
1617
|
-
}
|
|
1618
|
-
function hasToolCalls(toolCalls) {
|
|
1619
|
-
return toolCalls !== undefined && toolCalls.length > 0;
|
|
1620
|
-
}
|
|
1621
|
-
function countAssistantToolUses(messages) {
|
|
1622
|
-
let n = 0;
|
|
1623
|
-
for (const m of messages) {
|
|
1624
|
-
if (m.role !== "assistant")
|
|
1625
|
-
continue;
|
|
1626
|
-
for (const block of m.content) {
|
|
1627
|
-
if (block.type === "tool_use")
|
|
1628
|
-
n += 1;
|
|
1629
|
-
}
|
|
1630
|
-
}
|
|
1631
|
-
return n;
|
|
1632
|
-
}
|
|
1633
|
-
|
|
1634
|
-
// src/task/AgentTask.ts
|
|
1635
|
-
var MAX_CONTEXT_MESSAGES = 1000;
|
|
1636
|
-
var modelSchema2 = TypeModel("model:ToolCallingTask");
|
|
1637
|
-
var AgentInputSchema = {
|
|
1638
|
-
type: "object",
|
|
1639
|
-
properties: {
|
|
1640
|
-
model: modelSchema2,
|
|
1641
|
-
prompt: {
|
|
1642
|
-
oneOf: [
|
|
1643
|
-
{ type: "string" },
|
|
1644
|
-
{
|
|
1645
|
-
type: "array",
|
|
1646
|
-
items: {
|
|
1647
|
-
type: "object",
|
|
1648
|
-
properties: {
|
|
1649
|
-
type: { type: "string", enum: ["text", "image", "audio"] }
|
|
1650
|
-
},
|
|
1651
|
-
required: ["type"],
|
|
1652
|
-
additionalProperties: true
|
|
1653
|
-
}
|
|
1654
|
-
}
|
|
1655
|
-
],
|
|
1656
|
-
title: "Prompt",
|
|
1657
|
-
description: "The user prompt to start the agent loop. Can be a string or an array of content blocks (text, image, audio)."
|
|
1658
|
-
},
|
|
1659
|
-
systemPrompt: {
|
|
1660
|
-
type: "string",
|
|
1661
|
-
title: "System Prompt",
|
|
1662
|
-
description: "Optional system instructions for the agent"
|
|
1663
|
-
},
|
|
1664
|
-
tools: {
|
|
1665
|
-
type: "array",
|
|
1666
|
-
format: "tasks",
|
|
1667
|
-
title: "Tools",
|
|
1668
|
-
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.",
|
|
1669
|
-
items: {
|
|
1670
|
-
oneOf: [
|
|
1671
|
-
{ type: "string", format: "tasks", description: "Task type name" },
|
|
1672
|
-
ToolDefinitionSchema
|
|
1673
|
-
]
|
|
1674
|
-
}
|
|
1675
|
-
},
|
|
1676
|
-
stopTool: {
|
|
1677
|
-
type: "string",
|
|
1678
|
-
title: "Stop Tool",
|
|
1679
|
-
description: "Name of a tool that signals agent completion. When called, the loop ends and the tool input becomes structuredOutput.",
|
|
1680
|
-
"x-ui-group": "Configuration"
|
|
1681
|
-
},
|
|
1682
|
-
maxIterations: {
|
|
1683
|
-
type: "number",
|
|
1684
|
-
title: "Max Iterations",
|
|
1685
|
-
description: "Maximum number of agent loop iterations (default: 10)",
|
|
1686
|
-
minimum: 1,
|
|
1687
|
-
"x-ui-group": "Configuration"
|
|
1688
|
-
},
|
|
1689
|
-
maxContextMessages: {
|
|
1690
|
-
type: "number",
|
|
1691
|
-
title: "Max Context Messages",
|
|
1692
|
-
description: "Maximum messages in conversation history. Older messages are trimmed to prevent context overflow.",
|
|
1693
|
-
minimum: 3,
|
|
1694
|
-
"x-ui-group": "Configuration"
|
|
1695
|
-
},
|
|
1696
|
-
maxTokens: {
|
|
1697
|
-
type: "number",
|
|
1698
|
-
title: "Max Tokens",
|
|
1699
|
-
description: "Maximum tokens per LLM call",
|
|
1700
|
-
minimum: 1,
|
|
1701
|
-
"x-ui-group": "Configuration"
|
|
1702
|
-
},
|
|
1703
|
-
temperature: {
|
|
1704
|
-
type: "number",
|
|
1705
|
-
title: "Temperature",
|
|
1706
|
-
description: "Sampling temperature for LLM calls",
|
|
1707
|
-
minimum: 0,
|
|
1708
|
-
maximum: 2,
|
|
1709
|
-
"x-ui-group": "Configuration"
|
|
1710
|
-
}
|
|
1711
|
-
},
|
|
1712
|
-
required: ["model", "prompt"],
|
|
1713
|
-
additionalProperties: false
|
|
1714
|
-
};
|
|
1715
|
-
var AgentOutputSchema = {
|
|
1716
|
-
type: "object",
|
|
1717
|
-
properties: {
|
|
1718
|
-
text: {
|
|
1719
|
-
type: "string",
|
|
1720
|
-
title: "Text",
|
|
1721
|
-
description: "The final text response from the agent",
|
|
1722
|
-
"x-stream": "append"
|
|
1723
|
-
},
|
|
1724
|
-
messages: {
|
|
1725
|
-
type: "array",
|
|
1726
|
-
title: "Messages",
|
|
1727
|
-
description: "Full conversation history including all tool calls and results",
|
|
1728
|
-
items: {
|
|
1729
|
-
type: "object",
|
|
1730
|
-
additionalProperties: true
|
|
1731
|
-
}
|
|
1732
|
-
},
|
|
1733
|
-
iterations: {
|
|
1734
|
-
type: "number",
|
|
1735
|
-
title: "Iterations",
|
|
1736
|
-
description: "Number of LLM calls made during the agent loop"
|
|
1737
|
-
},
|
|
1738
|
-
toolCallCount: {
|
|
1739
|
-
type: "number",
|
|
1740
|
-
title: "Tool Call Count",
|
|
1741
|
-
description: "Total number of tool calls the assistant requested (tool_use blocks in assistant messages)"
|
|
1742
|
-
},
|
|
1743
|
-
structuredOutput: {
|
|
1744
|
-
type: "object",
|
|
1745
|
-
title: "Structured Output",
|
|
1746
|
-
description: "Present when the agent terminated via a stop tool",
|
|
1747
|
-
additionalProperties: true
|
|
1748
|
-
}
|
|
972
|
+
} from "@workglow/task-graph";
|
|
973
|
+
function schemaFormat(schema) {
|
|
974
|
+
return typeof schema === "object" && schema !== null && "format" in schema ? schema.format : undefined;
|
|
975
|
+
}
|
|
976
|
+
var aiTaskConfigSchema = {
|
|
977
|
+
type: "object",
|
|
978
|
+
properties: {
|
|
979
|
+
...TaskConfigSchema["properties"]
|
|
1749
980
|
},
|
|
1750
|
-
required: ["text", "messages", "iterations", "toolCallCount"],
|
|
1751
981
|
additionalProperties: false
|
|
1752
982
|
};
|
|
1753
983
|
|
|
1754
|
-
class
|
|
1755
|
-
static type = "
|
|
1756
|
-
static
|
|
1757
|
-
static
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
return AgentInputSchema;
|
|
984
|
+
class AiTask extends Task {
|
|
985
|
+
static type = "AiTask";
|
|
986
|
+
static hasDynamicEntitlements = true;
|
|
987
|
+
static entitlements() {
|
|
988
|
+
return {
|
|
989
|
+
entitlements: [{ id: Entitlements.AI_INFERENCE, reason: "Runs AI model inference" }]
|
|
990
|
+
};
|
|
1762
991
|
}
|
|
1763
|
-
|
|
1764
|
-
|
|
992
|
+
entitlements() {
|
|
993
|
+
const base = [
|
|
994
|
+
{ id: Entitlements.AI_INFERENCE, reason: "Runs AI model inference" }
|
|
995
|
+
];
|
|
996
|
+
const runModel = this.runInputData?.model;
|
|
997
|
+
const modelId = typeof runModel === "string" ? runModel : typeof this.defaults.model === "string" ? this.defaults.model : undefined;
|
|
998
|
+
if (modelId) {
|
|
999
|
+
base.push({
|
|
1000
|
+
id: Entitlements.AI_MODEL,
|
|
1001
|
+
reason: `Uses model ${modelId}`,
|
|
1002
|
+
resources: [modelId]
|
|
1003
|
+
});
|
|
1004
|
+
}
|
|
1005
|
+
return { entitlements: base };
|
|
1765
1006
|
}
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1007
|
+
static configSchema() {
|
|
1008
|
+
return aiTaskConfigSchema;
|
|
1009
|
+
}
|
|
1010
|
+
async execute(input, executeContext) {
|
|
1011
|
+
const model = input.model;
|
|
1012
|
+
if (!model || typeof model !== "object") {
|
|
1013
|
+
throw new TaskConfigurationError2("AiTask: Model was not resolved to ModelConfig - this indicates a bug in the resolution system");
|
|
1014
|
+
}
|
|
1015
|
+
const jobInput = await this.getJobInput(input);
|
|
1016
|
+
const strategy = getAiProviderRegistry().getStrategy(model);
|
|
1017
|
+
const output = await strategy.execute(jobInput, executeContext, this.runConfig.runnerId);
|
|
1018
|
+
if (executeContext.resourceScope) {
|
|
1019
|
+
const registry = getAiProviderRegistry();
|
|
1020
|
+
const provider = registry.getProvider(model.provider);
|
|
1021
|
+
const unloadFn = provider?.getRunFn("UnloadModelTask");
|
|
1022
|
+
if (unloadFn) {
|
|
1023
|
+
const modelPath = model.provider_config?.model_path ?? model.model;
|
|
1024
|
+
const resourceKey = `ai:${model.provider}:${modelPath}`;
|
|
1025
|
+
executeContext.resourceScope.register(resourceKey, async () => {
|
|
1026
|
+
await unloadFn({ model }, model, () => {}, AbortSignal.timeout(30000));
|
|
1027
|
+
});
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
return output;
|
|
1031
|
+
}
|
|
1032
|
+
async getJobInput(input) {
|
|
1033
|
+
const model = input.model;
|
|
1034
|
+
const runtype = this.constructor.runtype ?? this.constructor.type;
|
|
1035
|
+
const jobInput = {
|
|
1036
|
+
taskType: runtype,
|
|
1037
|
+
aiProvider: model.provider,
|
|
1038
|
+
taskInput: input
|
|
1039
|
+
};
|
|
1040
|
+
const taskTimeoutMs = this.config.timeout;
|
|
1041
|
+
if (typeof taskTimeoutMs === "number" && taskTimeoutMs > 0) {
|
|
1042
|
+
jobInput.timeoutMs = taskTimeoutMs;
|
|
1043
|
+
}
|
|
1044
|
+
const inputOutputSchema = input.outputSchema;
|
|
1045
|
+
if (inputOutputSchema && typeof inputOutputSchema === "object" && !Array.isArray(inputOutputSchema) && typeof inputOutputSchema.type === "string") {
|
|
1046
|
+
jobInput.outputSchema = inputOutputSchema;
|
|
1047
|
+
} else {
|
|
1048
|
+
const taskOutputSchema = this.outputSchema();
|
|
1049
|
+
if (hasStructuredOutput(taskOutputSchema)) {
|
|
1050
|
+
jobInput.outputSchema = taskOutputSchema;
|
|
1771
1051
|
}
|
|
1772
1052
|
}
|
|
1773
|
-
|
|
1774
|
-
|
|
1053
|
+
const sessionId = input.sessionId;
|
|
1054
|
+
if (sessionId) {
|
|
1055
|
+
jobInput.sessionId = sessionId;
|
|
1775
1056
|
}
|
|
1776
|
-
return
|
|
1057
|
+
return jobInput;
|
|
1777
1058
|
}
|
|
1778
|
-
async
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
const
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1059
|
+
async createJob(input, queueName) {
|
|
1060
|
+
const jobInput = await this.getJobInput(input);
|
|
1061
|
+
const resolvedQueueName = queueName ?? await this.getDefaultQueueName(input);
|
|
1062
|
+
if (!resolvedQueueName) {
|
|
1063
|
+
throw new TaskConfigurationError2("AiTask: Unable to determine queue for AI provider");
|
|
1064
|
+
}
|
|
1065
|
+
const job = new AiJob({
|
|
1066
|
+
queueName: resolvedQueueName,
|
|
1067
|
+
jobRunId: this.runConfig.runnerId,
|
|
1068
|
+
input: jobInput
|
|
1069
|
+
});
|
|
1070
|
+
return job;
|
|
1071
|
+
}
|
|
1072
|
+
async getDefaultQueueName(input) {
|
|
1073
|
+
const model = input.model;
|
|
1074
|
+
return model?.provider;
|
|
1075
|
+
}
|
|
1076
|
+
async executeReactive(input, output, context) {
|
|
1077
|
+
const model = input.model;
|
|
1078
|
+
if (model && typeof model === "object" && model.provider) {
|
|
1079
|
+
const taskType = this.constructor.runtype ?? this.constructor.type;
|
|
1080
|
+
const reactiveFn = getAiProviderRegistry().getReactiveRunFn(model.provider, taskType);
|
|
1081
|
+
if (reactiveFn) {
|
|
1082
|
+
return reactiveFn(input, output, model);
|
|
1799
1083
|
}
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
systemPrompt: input.systemPrompt,
|
|
1809
|
-
tools: toolDefs,
|
|
1810
|
-
messages: contextMessages,
|
|
1811
|
-
maxTokens: input.maxTokens,
|
|
1812
|
-
temperature: input.temperature
|
|
1813
|
-
}, context)) {
|
|
1814
|
-
if (event.type === "text-delta") {
|
|
1815
|
-
yield { type: "text-delta", port: "text", textDelta: event.textDelta };
|
|
1816
|
-
iterationText += event.textDelta;
|
|
1817
|
-
} else if (event.type === "object-delta" && event.port === "toolCalls") {
|
|
1818
|
-
const items = event.objectDelta;
|
|
1819
|
-
for (const item of items) {
|
|
1820
|
-
const idx = toolCalls.findIndex((tc) => tc.id === item.id);
|
|
1821
|
-
if (idx >= 0)
|
|
1822
|
-
toolCalls[idx] = item;
|
|
1823
|
-
else
|
|
1824
|
-
toolCalls.push(item);
|
|
1825
|
-
}
|
|
1826
|
-
} else if (event.type === "finish") {
|
|
1827
|
-
const data = event.data;
|
|
1828
|
-
iterationText = data?.text ?? iterationText;
|
|
1829
|
-
if (data?.toolCalls && data.toolCalls.length > 0) {
|
|
1830
|
-
toolCalls = data.toolCalls;
|
|
1831
|
-
}
|
|
1832
|
-
}
|
|
1084
|
+
}
|
|
1085
|
+
return super.executeReactive(input, output, context);
|
|
1086
|
+
}
|
|
1087
|
+
async validateInput(input) {
|
|
1088
|
+
const inputSchema = this.inputSchema();
|
|
1089
|
+
if (typeof inputSchema === "boolean") {
|
|
1090
|
+
if (inputSchema === false) {
|
|
1091
|
+
throw new TaskConfigurationError2(`AiTask: Input schema is 'false' and accepts no inputs`);
|
|
1833
1092
|
}
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1093
|
+
return true;
|
|
1094
|
+
}
|
|
1095
|
+
const modelTaskProperties = Object.entries(inputSchema.properties || {}).filter(([key, schema]) => schemaFormat(schema)?.startsWith("model:"));
|
|
1096
|
+
for (const [key] of modelTaskProperties) {
|
|
1097
|
+
const model = input[key];
|
|
1098
|
+
if (typeof model === "object" && model !== null) {
|
|
1099
|
+
const tasks = model.tasks;
|
|
1100
|
+
if (Array.isArray(tasks) && tasks.length > 0 && !tasks.includes(this.type)) {
|
|
1101
|
+
const modelId = model.model_id ?? "(inline config)";
|
|
1102
|
+
throw new TaskConfigurationError2(`AiTask: Model "${modelId}" for '${key}' is not compatible with task '${this.type}'. ` + `Model supports: [${tasks.join(", ")}]`);
|
|
1841
1103
|
}
|
|
1104
|
+
} else if (model !== undefined && model !== null) {
|
|
1105
|
+
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.`);
|
|
1842
1106
|
}
|
|
1843
|
-
if (!hasToolCalls(toolCalls)) {
|
|
1844
|
-
break;
|
|
1845
|
-
}
|
|
1846
|
-
const results = await executeToolCalls(toolCalls, toolSources, context, hooks, maxConcurrency);
|
|
1847
|
-
messages.push(toolMessage(results));
|
|
1848
1107
|
}
|
|
1849
|
-
const
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
};
|
|
1856
|
-
yield { type: "finish", data: output };
|
|
1857
|
-
}
|
|
1858
|
-
resolveToolSources(input, context) {
|
|
1859
|
-
return buildToolSources(input.tools, context.registry);
|
|
1860
|
-
}
|
|
1861
|
-
resolveToolDefs(toolSources, stopTool) {
|
|
1862
|
-
const defs = toolSourceDefinitions(toolSources);
|
|
1863
|
-
if (stopTool && !defs.some((d) => d.name === stopTool)) {
|
|
1864
|
-
defs.push({
|
|
1865
|
-
name: stopTool,
|
|
1866
|
-
description: "Call this tool when you have completed the task. Pass your final structured result as the input.",
|
|
1867
|
-
inputSchema: { type: "object", additionalProperties: true }
|
|
1868
|
-
});
|
|
1108
|
+
const modelPlainProperties = Object.entries(inputSchema.properties || {}).filter(([key, schema]) => schemaFormat(schema) === "model");
|
|
1109
|
+
for (const [key] of modelPlainProperties) {
|
|
1110
|
+
const model = input[key];
|
|
1111
|
+
if (model !== undefined && model !== null && typeof model !== "object") {
|
|
1112
|
+
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.`);
|
|
1113
|
+
}
|
|
1869
1114
|
}
|
|
1870
|
-
return
|
|
1115
|
+
return super.validateInput(input);
|
|
1871
1116
|
}
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1117
|
+
async narrowInput(input, registry) {
|
|
1118
|
+
const inputSchema = this.inputSchema();
|
|
1119
|
+
if (typeof inputSchema === "boolean") {
|
|
1120
|
+
if (inputSchema === false) {
|
|
1121
|
+
throw new TaskConfigurationError2(`AiTask: Input schema is 'false' and accepts no inputs`);
|
|
1122
|
+
}
|
|
1123
|
+
return input;
|
|
1875
1124
|
}
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1125
|
+
const modelTaskProperties = Object.entries(inputSchema.properties || {}).filter(([key, schema]) => schemaFormat(schema)?.startsWith("model:"));
|
|
1126
|
+
if (modelTaskProperties.length > 0) {
|
|
1127
|
+
const modelRepo = registry.get(MODEL_REPOSITORY);
|
|
1128
|
+
const taskModels = await modelRepo.findModelsByTask(this.type) ?? [];
|
|
1129
|
+
for (const [key] of modelTaskProperties) {
|
|
1130
|
+
const requestedModel = input[key];
|
|
1131
|
+
if (typeof requestedModel === "string") {
|
|
1132
|
+
const found = taskModels?.find((m) => m.model_id === requestedModel);
|
|
1133
|
+
if (!found) {
|
|
1134
|
+
input[key] = undefined;
|
|
1135
|
+
}
|
|
1136
|
+
} else if (typeof requestedModel === "object" && requestedModel !== null) {
|
|
1137
|
+
const model = requestedModel;
|
|
1138
|
+
const tasks = model.tasks;
|
|
1139
|
+
if (Array.isArray(tasks) && tasks.length > 0 && !tasks.includes(this.type)) {
|
|
1140
|
+
input[key] = undefined;
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1883
1144
|
}
|
|
1884
|
-
return
|
|
1145
|
+
return input;
|
|
1885
1146
|
}
|
|
1886
1147
|
}
|
|
1887
|
-
var agent = (input, config) => {
|
|
1888
|
-
return new AgentTask(config).run(input);
|
|
1889
|
-
};
|
|
1890
|
-
Workflow2.prototype.agent = CreateWorkflow2(AgentTask);
|
|
1891
|
-
|
|
1892
|
-
// src/task/BackgroundRemovalTask.ts
|
|
1893
|
-
import { CreateWorkflow as CreateWorkflow3, Workflow as Workflow3 } from "@workglow/task-graph";
|
|
1894
1148
|
|
|
1895
1149
|
// src/task/base/AiVisionTask.ts
|
|
1896
|
-
import { convertImageDataToUseableForm } from "@workglow/util/media";
|
|
1897
1150
|
class AiVisionTask extends AiTask {
|
|
1898
1151
|
static type = "AiVisionTask";
|
|
1899
1152
|
async getJobInput(input) {
|
|
@@ -1914,7 +1167,7 @@ class AiVisionTask extends AiTask {
|
|
|
1914
1167
|
}
|
|
1915
1168
|
|
|
1916
1169
|
// src/task/BackgroundRemovalTask.ts
|
|
1917
|
-
var
|
|
1170
|
+
var modelSchema = TypeModel("model:BackgroundRemovalTask");
|
|
1918
1171
|
var processedImageSchema = {
|
|
1919
1172
|
type: "string",
|
|
1920
1173
|
contentEncoding: "base64",
|
|
@@ -1926,7 +1179,7 @@ var BackgroundRemovalInputSchema = {
|
|
|
1926
1179
|
type: "object",
|
|
1927
1180
|
properties: {
|
|
1928
1181
|
image: TypeImageInput,
|
|
1929
|
-
model:
|
|
1182
|
+
model: modelSchema
|
|
1930
1183
|
},
|
|
1931
1184
|
required: ["image", "model"],
|
|
1932
1185
|
additionalProperties: false
|
|
@@ -1955,22 +1208,22 @@ class BackgroundRemovalTask extends AiVisionTask {
|
|
|
1955
1208
|
var backgroundRemoval = (input, config) => {
|
|
1956
1209
|
return new BackgroundRemovalTask(config).run(input);
|
|
1957
1210
|
};
|
|
1958
|
-
|
|
1211
|
+
Workflow.prototype.backgroundRemoval = CreateWorkflow(BackgroundRemovalTask);
|
|
1959
1212
|
|
|
1960
1213
|
// src/task/ChunkRetrievalTask.ts
|
|
1961
1214
|
import { TypeKnowledgeBase } from "@workglow/knowledge-base";
|
|
1962
|
-
import { CreateWorkflow as
|
|
1215
|
+
import { CreateWorkflow as CreateWorkflow3, Task as Task2, Workflow as Workflow3 } from "@workglow/task-graph";
|
|
1963
1216
|
import {
|
|
1964
1217
|
isTypedArray,
|
|
1965
1218
|
TypedArraySchema as TypedArraySchema2
|
|
1966
1219
|
} from "@workglow/util/schema";
|
|
1967
1220
|
|
|
1968
1221
|
// src/task/TextEmbeddingTask.ts
|
|
1969
|
-
import { CreateWorkflow as
|
|
1222
|
+
import { CreateWorkflow as CreateWorkflow2, Workflow as Workflow2 } from "@workglow/task-graph";
|
|
1970
1223
|
import {
|
|
1971
1224
|
TypedArraySchema
|
|
1972
1225
|
} from "@workglow/util/schema";
|
|
1973
|
-
var
|
|
1226
|
+
var modelSchema2 = TypeModel("model:TextEmbeddingTask");
|
|
1974
1227
|
var TextEmbeddingInputSchema = {
|
|
1975
1228
|
type: "object",
|
|
1976
1229
|
properties: {
|
|
@@ -1979,7 +1232,7 @@ var TextEmbeddingInputSchema = {
|
|
|
1979
1232
|
title: "Text",
|
|
1980
1233
|
description: "The text to embed"
|
|
1981
1234
|
}),
|
|
1982
|
-
model:
|
|
1235
|
+
model: modelSchema2
|
|
1983
1236
|
},
|
|
1984
1237
|
required: ["text", "model"],
|
|
1985
1238
|
additionalProperties: false
|
|
@@ -2011,7 +1264,7 @@ class TextEmbeddingTask extends AiTask {
|
|
|
2011
1264
|
var textEmbedding = async (input, config) => {
|
|
2012
1265
|
return new TextEmbeddingTask(config).run(input);
|
|
2013
1266
|
};
|
|
2014
|
-
|
|
1267
|
+
Workflow2.prototype.textEmbedding = CreateWorkflow2(TextEmbeddingTask);
|
|
2015
1268
|
|
|
2016
1269
|
// src/task/ChunkRetrievalTask.ts
|
|
2017
1270
|
var inputSchema = {
|
|
@@ -2136,7 +1389,7 @@ var outputSchema = {
|
|
|
2136
1389
|
additionalProperties: false
|
|
2137
1390
|
};
|
|
2138
1391
|
|
|
2139
|
-
class ChunkRetrievalTask extends
|
|
1392
|
+
class ChunkRetrievalTask extends Task2 {
|
|
2140
1393
|
static type = "ChunkRetrievalTask";
|
|
2141
1394
|
static category = "RAG";
|
|
2142
1395
|
static title = "Chunk Retrieval";
|
|
@@ -2203,11 +1456,11 @@ class ChunkRetrievalTask extends Task3 {
|
|
|
2203
1456
|
var chunkRetrieval = (input, config) => {
|
|
2204
1457
|
return new ChunkRetrievalTask(config).run(input);
|
|
2205
1458
|
};
|
|
2206
|
-
|
|
1459
|
+
Workflow3.prototype.chunkRetrieval = CreateWorkflow3(ChunkRetrievalTask);
|
|
2207
1460
|
|
|
2208
1461
|
// src/task/ChunkToVectorTask.ts
|
|
2209
1462
|
import { ChunkRecordSchema } from "@workglow/knowledge-base";
|
|
2210
|
-
import { CreateWorkflow as
|
|
1463
|
+
import { CreateWorkflow as CreateWorkflow4, Task as Task3, Workflow as Workflow4 } from "@workglow/task-graph";
|
|
2211
1464
|
import {
|
|
2212
1465
|
TypedArraySchema as TypedArraySchema3
|
|
2213
1466
|
} from "@workglow/util/schema";
|
|
@@ -2282,7 +1535,7 @@ var outputSchema2 = {
|
|
|
2282
1535
|
additionalProperties: false
|
|
2283
1536
|
};
|
|
2284
1537
|
|
|
2285
|
-
class ChunkToVectorTask extends
|
|
1538
|
+
class ChunkToVectorTask extends Task3 {
|
|
2286
1539
|
static type = "ChunkToVectorTask";
|
|
2287
1540
|
static category = "Document";
|
|
2288
1541
|
static title = "Chunk to Vector";
|
|
@@ -2333,11 +1586,11 @@ class ChunkToVectorTask extends Task4 {
|
|
|
2333
1586
|
var chunkToVector = (input, config) => {
|
|
2334
1587
|
return new ChunkToVectorTask(config).run(input);
|
|
2335
1588
|
};
|
|
2336
|
-
|
|
1589
|
+
Workflow4.prototype.chunkToVector = CreateWorkflow4(ChunkToVectorTask);
|
|
2337
1590
|
|
|
2338
1591
|
// src/task/ChunkVectorHybridSearchTask.ts
|
|
2339
1592
|
import { TypeKnowledgeBase as TypeKnowledgeBase2 } from "@workglow/knowledge-base";
|
|
2340
|
-
import { CreateWorkflow as
|
|
1593
|
+
import { CreateWorkflow as CreateWorkflow5, Task as Task4, Workflow as Workflow5 } from "@workglow/task-graph";
|
|
2341
1594
|
import {
|
|
2342
1595
|
TypedArraySchema as TypedArraySchema4
|
|
2343
1596
|
} from "@workglow/util/schema";
|
|
@@ -2450,7 +1703,7 @@ var outputSchema3 = {
|
|
|
2450
1703
|
additionalProperties: false
|
|
2451
1704
|
};
|
|
2452
1705
|
|
|
2453
|
-
class ChunkVectorHybridSearchTask extends
|
|
1706
|
+
class ChunkVectorHybridSearchTask extends Task4 {
|
|
2454
1707
|
static type = "ChunkVectorHybridSearchTask";
|
|
2455
1708
|
static category = "RAG";
|
|
2456
1709
|
static title = "Hybrid Search";
|
|
@@ -2503,11 +1756,11 @@ class ChunkVectorHybridSearchTask extends Task5 {
|
|
|
2503
1756
|
var hybridSearch = async (input, config) => {
|
|
2504
1757
|
return new ChunkVectorHybridSearchTask(config).run(input);
|
|
2505
1758
|
};
|
|
2506
|
-
|
|
1759
|
+
Workflow5.prototype.hybridSearch = CreateWorkflow5(ChunkVectorHybridSearchTask);
|
|
2507
1760
|
|
|
2508
1761
|
// src/task/ChunkVectorSearchTask.ts
|
|
2509
1762
|
import { TypeKnowledgeBase as TypeKnowledgeBase3 } from "@workglow/knowledge-base";
|
|
2510
|
-
import { CreateWorkflow as
|
|
1763
|
+
import { CreateWorkflow as CreateWorkflow6, Task as Task5, Workflow as Workflow6 } from "@workglow/task-graph";
|
|
2511
1764
|
import {
|
|
2512
1765
|
TypedArraySchema as TypedArraySchema5
|
|
2513
1766
|
} from "@workglow/util/schema";
|
|
@@ -2590,7 +1843,7 @@ var outputSchema4 = {
|
|
|
2590
1843
|
additionalProperties: false
|
|
2591
1844
|
};
|
|
2592
1845
|
|
|
2593
|
-
class ChunkVectorSearchTask extends
|
|
1846
|
+
class ChunkVectorSearchTask extends Task5 {
|
|
2594
1847
|
static type = "ChunkVectorSearchTask";
|
|
2595
1848
|
static category = "Vector Store";
|
|
2596
1849
|
static title = "Vector Store Search";
|
|
@@ -2622,11 +1875,11 @@ class ChunkVectorSearchTask extends Task6 {
|
|
|
2622
1875
|
var vectorStoreSearch = (input, config) => {
|
|
2623
1876
|
return new ChunkVectorSearchTask(config).run(input);
|
|
2624
1877
|
};
|
|
2625
|
-
|
|
1878
|
+
Workflow6.prototype.vectorStoreSearch = CreateWorkflow6(ChunkVectorSearchTask);
|
|
2626
1879
|
|
|
2627
1880
|
// src/task/ChunkVectorUpsertTask.ts
|
|
2628
1881
|
import { TypeKnowledgeBase as TypeKnowledgeBase4 } from "@workglow/knowledge-base";
|
|
2629
|
-
import { CreateWorkflow as
|
|
1882
|
+
import { CreateWorkflow as CreateWorkflow7, Task as Task6, Workflow as Workflow7 } from "@workglow/task-graph";
|
|
2630
1883
|
import {
|
|
2631
1884
|
TypedArraySchema as TypedArraySchema6
|
|
2632
1885
|
} from "@workglow/util/schema";
|
|
@@ -2680,7 +1933,7 @@ var outputSchema5 = {
|
|
|
2680
1933
|
additionalProperties: false
|
|
2681
1934
|
};
|
|
2682
1935
|
|
|
2683
|
-
class ChunkVectorUpsertTask extends
|
|
1936
|
+
class ChunkVectorUpsertTask extends Task6 {
|
|
2684
1937
|
static type = "ChunkVectorUpsertTask";
|
|
2685
1938
|
static category = "Vector Store";
|
|
2686
1939
|
static title = "Add to Vector Store";
|
|
@@ -2740,15 +1993,15 @@ class ChunkVectorUpsertTask extends Task7 {
|
|
|
2740
1993
|
var chunkVectorUpsert = (input, config) => {
|
|
2741
1994
|
return new ChunkVectorUpsertTask(config).run(input);
|
|
2742
1995
|
};
|
|
2743
|
-
|
|
1996
|
+
Workflow7.prototype.chunkVectorUpsert = CreateWorkflow7(ChunkVectorUpsertTask);
|
|
2744
1997
|
|
|
2745
1998
|
// src/task/ContextBuilderTask.ts
|
|
2746
1999
|
import { estimateTokens } from "@workglow/knowledge-base";
|
|
2747
|
-
import { CreateWorkflow as
|
|
2000
|
+
import { CreateWorkflow as CreateWorkflow9, Task as Task7, Workflow as Workflow9 } from "@workglow/task-graph";
|
|
2748
2001
|
|
|
2749
2002
|
// src/task/CountTokensTask.ts
|
|
2750
|
-
import { CreateWorkflow as
|
|
2751
|
-
var
|
|
2003
|
+
import { CreateWorkflow as CreateWorkflow8, Workflow as Workflow8 } from "@workglow/task-graph";
|
|
2004
|
+
var modelSchema3 = TypeModel("model");
|
|
2752
2005
|
var CountTokensInputSchema = {
|
|
2753
2006
|
type: "object",
|
|
2754
2007
|
properties: {
|
|
@@ -2757,7 +2010,7 @@ var CountTokensInputSchema = {
|
|
|
2757
2010
|
title: "Text",
|
|
2758
2011
|
description: "The text to count tokens for"
|
|
2759
2012
|
},
|
|
2760
|
-
model:
|
|
2013
|
+
model: modelSchema3
|
|
2761
2014
|
},
|
|
2762
2015
|
required: ["text", "model"],
|
|
2763
2016
|
additionalProperties: false
|
|
@@ -2791,7 +2044,7 @@ class CountTokensTask extends AiTask {
|
|
|
2791
2044
|
var countTokens = async (input, config) => {
|
|
2792
2045
|
return new CountTokensTask(config).run(input);
|
|
2793
2046
|
};
|
|
2794
|
-
|
|
2047
|
+
Workflow8.prototype.countTokens = CreateWorkflow8(CountTokensTask);
|
|
2795
2048
|
|
|
2796
2049
|
// src/task/ContextBuilderTask.ts
|
|
2797
2050
|
var ContextFormat = {
|
|
@@ -2801,7 +2054,7 @@ var ContextFormat = {
|
|
|
2801
2054
|
MARKDOWN: "markdown",
|
|
2802
2055
|
JSON: "json"
|
|
2803
2056
|
};
|
|
2804
|
-
var
|
|
2057
|
+
var modelSchema4 = TypeModel("model", {
|
|
2805
2058
|
title: "Model",
|
|
2806
2059
|
description: "Model to use for token counting (optional, falls back to estimation)"
|
|
2807
2060
|
});
|
|
@@ -2865,7 +2118,7 @@ var inputSchema6 = {
|
|
|
2865
2118
|
|
|
2866
2119
|
`
|
|
2867
2120
|
},
|
|
2868
|
-
model:
|
|
2121
|
+
model: modelSchema4
|
|
2869
2122
|
},
|
|
2870
2123
|
required: ["chunks"],
|
|
2871
2124
|
additionalProperties: false
|
|
@@ -2898,7 +2151,7 @@ var outputSchema6 = {
|
|
|
2898
2151
|
additionalProperties: false
|
|
2899
2152
|
};
|
|
2900
2153
|
|
|
2901
|
-
class ContextBuilderTask extends
|
|
2154
|
+
class ContextBuilderTask extends Task7 {
|
|
2902
2155
|
static type = "ContextBuilderTask";
|
|
2903
2156
|
static category = "RAG";
|
|
2904
2157
|
static title = "Context Builder";
|
|
@@ -3091,15 +2344,15 @@ class ContextBuilderTask extends Task8 {
|
|
|
3091
2344
|
var contextBuilder = (input, config) => {
|
|
3092
2345
|
return new ContextBuilderTask(config).run(input);
|
|
3093
2346
|
};
|
|
3094
|
-
|
|
2347
|
+
Workflow9.prototype.contextBuilder = CreateWorkflow9(ContextBuilderTask);
|
|
3095
2348
|
|
|
3096
2349
|
// src/task/DocumentEnricherTask.ts
|
|
3097
2350
|
import { getChildren, hasChildren } from "@workglow/knowledge-base";
|
|
3098
|
-
import { CreateWorkflow as
|
|
2351
|
+
import { CreateWorkflow as CreateWorkflow12, Task as Task8, Workflow as Workflow12 } from "@workglow/task-graph";
|
|
3099
2352
|
|
|
3100
2353
|
// src/task/TextNamedEntityRecognitionTask.ts
|
|
3101
|
-
import { CreateWorkflow as
|
|
3102
|
-
var
|
|
2354
|
+
import { CreateWorkflow as CreateWorkflow10, Workflow as Workflow10 } from "@workglow/task-graph";
|
|
2355
|
+
var modelSchema5 = TypeModel("model:TextNamedEntityRecognitionTask");
|
|
3103
2356
|
var TextNamedEntityRecognitionInputSchema = {
|
|
3104
2357
|
type: "object",
|
|
3105
2358
|
properties: {
|
|
@@ -3118,7 +2371,7 @@ var TextNamedEntityRecognitionInputSchema = {
|
|
|
3118
2371
|
"x-ui-group": "Configuration",
|
|
3119
2372
|
"x-ui-group-open": false
|
|
3120
2373
|
},
|
|
3121
|
-
model:
|
|
2374
|
+
model: modelSchema5
|
|
3122
2375
|
},
|
|
3123
2376
|
required: ["text", "model"],
|
|
3124
2377
|
additionalProperties: false
|
|
@@ -3173,11 +2426,48 @@ class TextNamedEntityRecognitionTask extends AiTask {
|
|
|
3173
2426
|
var textNamedEntityRecognition = (input, config) => {
|
|
3174
2427
|
return new TextNamedEntityRecognitionTask(config).run(input);
|
|
3175
2428
|
};
|
|
3176
|
-
|
|
2429
|
+
Workflow10.prototype.textNamedEntityRecognition = CreateWorkflow10(TextNamedEntityRecognitionTask);
|
|
2430
|
+
|
|
2431
|
+
// src/task/TextSummaryTask.ts
|
|
2432
|
+
import { CreateWorkflow as CreateWorkflow11, Workflow as Workflow11 } from "@workglow/task-graph";
|
|
2433
|
+
|
|
2434
|
+
// src/task/base/StreamingAiTask.ts
|
|
2435
|
+
import { getStreamingPorts, TaskConfigurationError as TaskConfigurationError3 } from "@workglow/task-graph";
|
|
2436
|
+
class StreamingAiTask extends AiTask {
|
|
2437
|
+
static type = "StreamingAiTask";
|
|
2438
|
+
async* executeStream(input, context) {
|
|
2439
|
+
const model = input.model;
|
|
2440
|
+
if (!model || typeof model !== "object") {
|
|
2441
|
+
throw new TaskConfigurationError3("StreamingAiTask: Model was not resolved to ModelConfig - this indicates a bug in the resolution system");
|
|
2442
|
+
}
|
|
2443
|
+
const jobInput = await this.getJobInput(input);
|
|
2444
|
+
const strategy = getAiProviderRegistry().getStrategy(model);
|
|
2445
|
+
const outSchema = this.outputSchema();
|
|
2446
|
+
const ports = getStreamingPorts(outSchema);
|
|
2447
|
+
let defaultPort = "text";
|
|
2448
|
+
if (ports.length > 0) {
|
|
2449
|
+
defaultPort = ports[0].port;
|
|
2450
|
+
} else {
|
|
2451
|
+
if (typeof outSchema === "object" && outSchema.properties) {
|
|
2452
|
+
const firstProp = Object.keys(outSchema.properties)[0];
|
|
2453
|
+
if (firstProp)
|
|
2454
|
+
defaultPort = firstProp;
|
|
2455
|
+
}
|
|
2456
|
+
}
|
|
2457
|
+
for await (const event of strategy.executeStream(jobInput, context, this.runConfig.runnerId)) {
|
|
2458
|
+
if (event.type === "text-delta") {
|
|
2459
|
+
yield { ...event, port: event.port ?? defaultPort };
|
|
2460
|
+
} else if (event.type === "object-delta") {
|
|
2461
|
+
yield { ...event, port: event.port ?? defaultPort };
|
|
2462
|
+
} else {
|
|
2463
|
+
yield event;
|
|
2464
|
+
}
|
|
2465
|
+
}
|
|
2466
|
+
}
|
|
2467
|
+
}
|
|
3177
2468
|
|
|
3178
2469
|
// src/task/TextSummaryTask.ts
|
|
3179
|
-
|
|
3180
|
-
var modelSchema8 = TypeModel("model:TextSummaryTask");
|
|
2470
|
+
var modelSchema6 = TypeModel("model:TextSummaryTask");
|
|
3181
2471
|
var TextSummaryInputSchema = {
|
|
3182
2472
|
type: "object",
|
|
3183
2473
|
properties: {
|
|
@@ -3186,7 +2476,7 @@ var TextSummaryInputSchema = {
|
|
|
3186
2476
|
title: "Text",
|
|
3187
2477
|
description: "The text to summarize"
|
|
3188
2478
|
},
|
|
3189
|
-
model:
|
|
2479
|
+
model: modelSchema6
|
|
3190
2480
|
},
|
|
3191
2481
|
required: ["text", "model"],
|
|
3192
2482
|
additionalProperties: false
|
|
@@ -3220,7 +2510,7 @@ class TextSummaryTask extends StreamingAiTask {
|
|
|
3220
2510
|
var textSummary = async (input, config) => {
|
|
3221
2511
|
return new TextSummaryTask(config).run(input);
|
|
3222
2512
|
};
|
|
3223
|
-
|
|
2513
|
+
Workflow11.prototype.textSummary = CreateWorkflow11(TextSummaryTask);
|
|
3224
2514
|
|
|
3225
2515
|
// src/task/DocumentEnricherTask.ts
|
|
3226
2516
|
var inputSchema7 = {
|
|
@@ -3294,7 +2584,7 @@ var outputSchema7 = {
|
|
|
3294
2584
|
additionalProperties: false
|
|
3295
2585
|
};
|
|
3296
2586
|
|
|
3297
|
-
class DocumentEnricherTask extends
|
|
2587
|
+
class DocumentEnricherTask extends Task8 {
|
|
3298
2588
|
static type = "DocumentEnricherTask";
|
|
3299
2589
|
static category = "Document";
|
|
3300
2590
|
static title = "Document Enricher";
|
|
@@ -3453,12 +2743,12 @@ class DocumentEnricherTask extends Task9 {
|
|
|
3453
2743
|
var documentEnricher = (input, config) => {
|
|
3454
2744
|
return new DocumentEnricherTask(config).run(input);
|
|
3455
2745
|
};
|
|
3456
|
-
|
|
2746
|
+
Workflow12.prototype.documentEnricher = CreateWorkflow12(DocumentEnricherTask);
|
|
3457
2747
|
|
|
3458
2748
|
// src/task/DocumentUpsertTask.ts
|
|
3459
2749
|
import { Document, TypeKnowledgeBase as TypeKnowledgeBase5 } from "@workglow/knowledge-base";
|
|
3460
2750
|
import { DocumentMetadataSchema } from "@workglow/knowledge-base";
|
|
3461
|
-
import { CreateWorkflow as
|
|
2751
|
+
import { CreateWorkflow as CreateWorkflow13, Task as Task9, Workflow as Workflow13 } from "@workglow/task-graph";
|
|
3462
2752
|
var inputSchema8 = {
|
|
3463
2753
|
type: "object",
|
|
3464
2754
|
properties: {
|
|
@@ -3503,7 +2793,7 @@ var outputSchema8 = {
|
|
|
3503
2793
|
additionalProperties: false
|
|
3504
2794
|
};
|
|
3505
2795
|
|
|
3506
|
-
class DocumentUpsertTask extends
|
|
2796
|
+
class DocumentUpsertTask extends Task9 {
|
|
3507
2797
|
static type = "DocumentUpsertTask";
|
|
3508
2798
|
static category = "Vector Store";
|
|
3509
2799
|
static title = "Add Document";
|
|
@@ -3536,15 +2826,15 @@ class DocumentUpsertTask extends Task10 {
|
|
|
3536
2826
|
var documentUpsert = (input, config) => {
|
|
3537
2827
|
return new DocumentUpsertTask(config).run(input);
|
|
3538
2828
|
};
|
|
3539
|
-
|
|
2829
|
+
Workflow13.prototype.documentUpsert = CreateWorkflow13(DocumentUpsertTask);
|
|
3540
2830
|
|
|
3541
2831
|
// src/task/DownloadModelTask.ts
|
|
3542
|
-
import { CreateWorkflow as
|
|
3543
|
-
var
|
|
2832
|
+
import { CreateWorkflow as CreateWorkflow14, Workflow as Workflow14 } from "@workglow/task-graph";
|
|
2833
|
+
var modelSchema7 = TypeModel("model");
|
|
3544
2834
|
var DownloadModelInputSchema = {
|
|
3545
2835
|
type: "object",
|
|
3546
2836
|
properties: {
|
|
3547
|
-
model:
|
|
2837
|
+
model: modelSchema7
|
|
3548
2838
|
},
|
|
3549
2839
|
required: ["model"],
|
|
3550
2840
|
additionalProperties: false
|
|
@@ -3552,7 +2842,7 @@ var DownloadModelInputSchema = {
|
|
|
3552
2842
|
var DownloadModelOutputSchema = {
|
|
3553
2843
|
type: "object",
|
|
3554
2844
|
properties: {
|
|
3555
|
-
model:
|
|
2845
|
+
model: modelSchema7
|
|
3556
2846
|
},
|
|
3557
2847
|
required: ["model"],
|
|
3558
2848
|
additionalProperties: false
|
|
@@ -3606,11 +2896,11 @@ class DownloadModelTask extends AiTask {
|
|
|
3606
2896
|
var downloadModel = (input, config) => {
|
|
3607
2897
|
return new DownloadModelTask(config).run(input);
|
|
3608
2898
|
};
|
|
3609
|
-
|
|
2899
|
+
Workflow14.prototype.downloadModel = CreateWorkflow14(DownloadModelTask);
|
|
3610
2900
|
|
|
3611
2901
|
// src/task/FaceDetectorTask.ts
|
|
3612
|
-
import { CreateWorkflow as
|
|
3613
|
-
var
|
|
2902
|
+
import { CreateWorkflow as CreateWorkflow15, Workflow as Workflow15 } from "@workglow/task-graph";
|
|
2903
|
+
var modelSchema8 = TypeModel("model:FaceDetectorTask");
|
|
3614
2904
|
var TypeBoundingBox2 = {
|
|
3615
2905
|
type: "object",
|
|
3616
2906
|
properties: {
|
|
@@ -3683,7 +2973,7 @@ var FaceDetectorInputSchema = {
|
|
|
3683
2973
|
type: "object",
|
|
3684
2974
|
properties: {
|
|
3685
2975
|
image: TypeImageInput,
|
|
3686
|
-
model:
|
|
2976
|
+
model: modelSchema8,
|
|
3687
2977
|
minDetectionConfidence: {
|
|
3688
2978
|
type: "number",
|
|
3689
2979
|
minimum: 0,
|
|
@@ -3737,11 +3027,11 @@ class FaceDetectorTask extends AiVisionTask {
|
|
|
3737
3027
|
var faceDetector = (input, config) => {
|
|
3738
3028
|
return new FaceDetectorTask(config).run(input);
|
|
3739
3029
|
};
|
|
3740
|
-
|
|
3030
|
+
Workflow15.prototype.faceDetector = CreateWorkflow15(FaceDetectorTask);
|
|
3741
3031
|
|
|
3742
3032
|
// src/task/FaceLandmarkerTask.ts
|
|
3743
|
-
import { CreateWorkflow as
|
|
3744
|
-
var
|
|
3033
|
+
import { CreateWorkflow as CreateWorkflow16, Workflow as Workflow16 } from "@workglow/task-graph";
|
|
3034
|
+
var modelSchema9 = TypeModel("model:FaceLandmarkerTask");
|
|
3745
3035
|
var TypeLandmark = {
|
|
3746
3036
|
type: "object",
|
|
3747
3037
|
properties: {
|
|
@@ -3813,7 +3103,7 @@ var FaceLandmarkerInputSchema = {
|
|
|
3813
3103
|
type: "object",
|
|
3814
3104
|
properties: {
|
|
3815
3105
|
image: TypeImageInput,
|
|
3816
|
-
model:
|
|
3106
|
+
model: modelSchema9,
|
|
3817
3107
|
numFaces: {
|
|
3818
3108
|
type: "number",
|
|
3819
3109
|
minimum: 1,
|
|
@@ -3899,11 +3189,11 @@ class FaceLandmarkerTask extends AiVisionTask {
|
|
|
3899
3189
|
var faceLandmarker = (input, config) => {
|
|
3900
3190
|
return new FaceLandmarkerTask(config).run(input);
|
|
3901
3191
|
};
|
|
3902
|
-
|
|
3192
|
+
Workflow16.prototype.faceLandmarker = CreateWorkflow16(FaceLandmarkerTask);
|
|
3903
3193
|
|
|
3904
3194
|
// src/task/GestureRecognizerTask.ts
|
|
3905
|
-
import { CreateWorkflow as
|
|
3906
|
-
var
|
|
3195
|
+
import { CreateWorkflow as CreateWorkflow17, Workflow as Workflow17 } from "@workglow/task-graph";
|
|
3196
|
+
var modelSchema10 = TypeModel("model:GestureRecognizerTask");
|
|
3907
3197
|
var TypeLandmark2 = {
|
|
3908
3198
|
type: "object",
|
|
3909
3199
|
properties: {
|
|
@@ -3995,7 +3285,7 @@ var GestureRecognizerInputSchema = {
|
|
|
3995
3285
|
type: "object",
|
|
3996
3286
|
properties: {
|
|
3997
3287
|
image: TypeImageInput,
|
|
3998
|
-
model:
|
|
3288
|
+
model: modelSchema10,
|
|
3999
3289
|
numHands: {
|
|
4000
3290
|
type: "number",
|
|
4001
3291
|
minimum: 1,
|
|
@@ -4067,11 +3357,11 @@ class GestureRecognizerTask extends AiVisionTask {
|
|
|
4067
3357
|
var gestureRecognizer = (input, config) => {
|
|
4068
3358
|
return new GestureRecognizerTask(config).run(input);
|
|
4069
3359
|
};
|
|
4070
|
-
|
|
3360
|
+
Workflow17.prototype.gestureRecognizer = CreateWorkflow17(GestureRecognizerTask);
|
|
4071
3361
|
|
|
4072
3362
|
// src/task/HandLandmarkerTask.ts
|
|
4073
|
-
import { CreateWorkflow as
|
|
4074
|
-
var
|
|
3363
|
+
import { CreateWorkflow as CreateWorkflow18, Workflow as Workflow18 } from "@workglow/task-graph";
|
|
3364
|
+
var modelSchema11 = TypeModel("model:HandLandmarkerTask");
|
|
4075
3365
|
var TypeLandmark3 = {
|
|
4076
3366
|
type: "object",
|
|
4077
3367
|
properties: {
|
|
@@ -4140,7 +3430,7 @@ var HandLandmarkerInputSchema = {
|
|
|
4140
3430
|
type: "object",
|
|
4141
3431
|
properties: {
|
|
4142
3432
|
image: TypeImageInput,
|
|
4143
|
-
model:
|
|
3433
|
+
model: modelSchema11,
|
|
4144
3434
|
numHands: {
|
|
4145
3435
|
type: "number",
|
|
4146
3436
|
minimum: 1,
|
|
@@ -4212,7 +3502,7 @@ class HandLandmarkerTask extends AiVisionTask {
|
|
|
4212
3502
|
var handLandmarker = (input, config) => {
|
|
4213
3503
|
return new HandLandmarkerTask(config).run(input);
|
|
4214
3504
|
};
|
|
4215
|
-
|
|
3505
|
+
Workflow18.prototype.handLandmarker = CreateWorkflow18(HandLandmarkerTask);
|
|
4216
3506
|
|
|
4217
3507
|
// src/task/HierarchicalChunkerTask.ts
|
|
4218
3508
|
import {
|
|
@@ -4221,9 +3511,9 @@ import {
|
|
|
4221
3511
|
getChildren as getChildren2,
|
|
4222
3512
|
hasChildren as hasChildren2
|
|
4223
3513
|
} from "@workglow/knowledge-base";
|
|
4224
|
-
import { CreateWorkflow as
|
|
3514
|
+
import { CreateWorkflow as CreateWorkflow19, Task as Task10, Workflow as Workflow19 } from "@workglow/task-graph";
|
|
4225
3515
|
import { uuid4 } from "@workglow/util";
|
|
4226
|
-
var
|
|
3516
|
+
var modelSchema12 = TypeModel("model", {
|
|
4227
3517
|
title: "Model",
|
|
4228
3518
|
description: "Model to use for token counting"
|
|
4229
3519
|
});
|
|
@@ -4269,7 +3559,7 @@ var inputSchema9 = {
|
|
|
4269
3559
|
description: "Strategy for chunking",
|
|
4270
3560
|
default: "hierarchical"
|
|
4271
3561
|
},
|
|
4272
|
-
model:
|
|
3562
|
+
model: modelSchema12
|
|
4273
3563
|
},
|
|
4274
3564
|
required: ["doc_id", "documentTree"],
|
|
4275
3565
|
additionalProperties: false
|
|
@@ -4304,7 +3594,7 @@ var outputSchema9 = {
|
|
|
4304
3594
|
additionalProperties: false
|
|
4305
3595
|
};
|
|
4306
3596
|
|
|
4307
|
-
class HierarchicalChunkerTask extends
|
|
3597
|
+
class HierarchicalChunkerTask extends Task10 {
|
|
4308
3598
|
static type = "HierarchicalChunkerTask";
|
|
4309
3599
|
static category = "Document";
|
|
4310
3600
|
static title = "Hierarchical Chunker";
|
|
@@ -4448,11 +3738,11 @@ class HierarchicalChunkerTask extends Task11 {
|
|
|
4448
3738
|
var hierarchicalChunker = (input, config) => {
|
|
4449
3739
|
return new HierarchicalChunkerTask(config).run(input);
|
|
4450
3740
|
};
|
|
4451
|
-
|
|
3741
|
+
Workflow19.prototype.hierarchicalChunker = CreateWorkflow19(HierarchicalChunkerTask);
|
|
4452
3742
|
|
|
4453
3743
|
// src/task/HierarchyJoinTask.ts
|
|
4454
3744
|
import { ChunkRecordArraySchema, TypeKnowledgeBase as TypeKnowledgeBase6 } from "@workglow/knowledge-base";
|
|
4455
|
-
import { CreateWorkflow as
|
|
3745
|
+
import { CreateWorkflow as CreateWorkflow20, Task as Task11, Workflow as Workflow20 } from "@workglow/task-graph";
|
|
4456
3746
|
var inputSchema10 = {
|
|
4457
3747
|
type: "object",
|
|
4458
3748
|
properties: {
|
|
@@ -4527,7 +3817,7 @@ var outputSchema10 = {
|
|
|
4527
3817
|
additionalProperties: false
|
|
4528
3818
|
};
|
|
4529
3819
|
|
|
4530
|
-
class HierarchyJoinTask extends
|
|
3820
|
+
class HierarchyJoinTask extends Task11 {
|
|
4531
3821
|
static type = "HierarchyJoinTask";
|
|
4532
3822
|
static category = "RAG";
|
|
4533
3823
|
static title = "Hierarchy Join";
|
|
@@ -4621,11 +3911,11 @@ class HierarchyJoinTask extends Task12 {
|
|
|
4621
3911
|
var hierarchyJoin = (input, config) => {
|
|
4622
3912
|
return new HierarchyJoinTask(config).run(input);
|
|
4623
3913
|
};
|
|
4624
|
-
|
|
3914
|
+
Workflow20.prototype.hierarchyJoin = CreateWorkflow20(HierarchyJoinTask);
|
|
4625
3915
|
|
|
4626
3916
|
// src/task/KbToDocumentsTask.ts
|
|
4627
3917
|
import { TypeKnowledgeBase as TypeKnowledgeBase7 } from "@workglow/knowledge-base";
|
|
4628
|
-
import { CreateWorkflow as
|
|
3918
|
+
import { CreateWorkflow as CreateWorkflow21, Task as Task12, Workflow as Workflow21 } from "@workglow/task-graph";
|
|
4629
3919
|
var inputSchema11 = {
|
|
4630
3920
|
type: "object",
|
|
4631
3921
|
properties: {
|
|
@@ -4669,7 +3959,7 @@ var outputSchema11 = {
|
|
|
4669
3959
|
additionalProperties: false
|
|
4670
3960
|
};
|
|
4671
3961
|
|
|
4672
|
-
class KbToDocumentsTask extends
|
|
3962
|
+
class KbToDocumentsTask extends Task12 {
|
|
4673
3963
|
static type = "KbToDocumentsTask";
|
|
4674
3964
|
static category = "Vector Store";
|
|
4675
3965
|
static title = "Knowledge Base to Documents";
|
|
@@ -4710,16 +4000,16 @@ class KbToDocumentsTask extends Task13 {
|
|
|
4710
4000
|
var kbToDocuments = (input, config) => {
|
|
4711
4001
|
return new KbToDocumentsTask(config).run(input);
|
|
4712
4002
|
};
|
|
4713
|
-
|
|
4003
|
+
Workflow21.prototype.kbToDocuments = CreateWorkflow21(KbToDocumentsTask);
|
|
4714
4004
|
|
|
4715
4005
|
// src/task/ImageClassificationTask.ts
|
|
4716
|
-
import { CreateWorkflow as
|
|
4717
|
-
var
|
|
4006
|
+
import { CreateWorkflow as CreateWorkflow22, Workflow as Workflow22 } from "@workglow/task-graph";
|
|
4007
|
+
var modelSchema13 = TypeModel("model:ImageClassificationTask");
|
|
4718
4008
|
var ImageClassificationInputSchema = {
|
|
4719
4009
|
type: "object",
|
|
4720
4010
|
properties: {
|
|
4721
4011
|
image: TypeImageInput,
|
|
4722
|
-
model:
|
|
4012
|
+
model: modelSchema13,
|
|
4723
4013
|
categories: {
|
|
4724
4014
|
type: "array",
|
|
4725
4015
|
items: {
|
|
@@ -4773,19 +4063,19 @@ class ImageClassificationTask extends AiVisionTask {
|
|
|
4773
4063
|
var imageClassification = (input, config) => {
|
|
4774
4064
|
return new ImageClassificationTask(config).run(input);
|
|
4775
4065
|
};
|
|
4776
|
-
|
|
4066
|
+
Workflow22.prototype.imageClassification = CreateWorkflow22(ImageClassificationTask);
|
|
4777
4067
|
|
|
4778
4068
|
// src/task/ImageEmbeddingTask.ts
|
|
4779
|
-
import { CreateWorkflow as
|
|
4069
|
+
import { CreateWorkflow as CreateWorkflow23, Workflow as Workflow23 } from "@workglow/task-graph";
|
|
4780
4070
|
import {
|
|
4781
4071
|
TypedArraySchema as TypedArraySchema7
|
|
4782
4072
|
} from "@workglow/util/schema";
|
|
4783
|
-
var
|
|
4073
|
+
var modelSchema14 = TypeModel("model:ImageEmbeddingTask");
|
|
4784
4074
|
var ImageEmbeddingInputSchema = {
|
|
4785
4075
|
type: "object",
|
|
4786
4076
|
properties: {
|
|
4787
4077
|
image: TypeSingleOrArray(TypeImageInput),
|
|
4788
|
-
model:
|
|
4078
|
+
model: modelSchema14
|
|
4789
4079
|
},
|
|
4790
4080
|
required: ["image", "model"],
|
|
4791
4081
|
additionalProperties: false
|
|
@@ -4817,16 +4107,16 @@ class ImageEmbeddingTask extends AiVisionTask {
|
|
|
4817
4107
|
var imageEmbedding = (input, config) => {
|
|
4818
4108
|
return new ImageEmbeddingTask(config).run(input);
|
|
4819
4109
|
};
|
|
4820
|
-
|
|
4110
|
+
Workflow23.prototype.imageEmbedding = CreateWorkflow23(ImageEmbeddingTask);
|
|
4821
4111
|
|
|
4822
4112
|
// src/task/ImageSegmentationTask.ts
|
|
4823
|
-
import { CreateWorkflow as
|
|
4824
|
-
var
|
|
4113
|
+
import { CreateWorkflow as CreateWorkflow24, Workflow as Workflow24 } from "@workglow/task-graph";
|
|
4114
|
+
var modelSchema15 = TypeModel("model:ImageSegmentationTask");
|
|
4825
4115
|
var ImageSegmentationInputSchema = {
|
|
4826
4116
|
type: "object",
|
|
4827
4117
|
properties: {
|
|
4828
4118
|
image: TypeImageInput,
|
|
4829
|
-
model:
|
|
4119
|
+
model: modelSchema15,
|
|
4830
4120
|
threshold: {
|
|
4831
4121
|
type: "number",
|
|
4832
4122
|
title: "Threshold",
|
|
@@ -4905,11 +4195,11 @@ class ImageSegmentationTask extends AiVisionTask {
|
|
|
4905
4195
|
var imageSegmentation = (input, config) => {
|
|
4906
4196
|
return new ImageSegmentationTask(config).run(input);
|
|
4907
4197
|
};
|
|
4908
|
-
|
|
4198
|
+
Workflow24.prototype.imageSegmentation = CreateWorkflow24(ImageSegmentationTask);
|
|
4909
4199
|
|
|
4910
4200
|
// src/task/ImageToTextTask.ts
|
|
4911
|
-
import { CreateWorkflow as
|
|
4912
|
-
var
|
|
4201
|
+
import { CreateWorkflow as CreateWorkflow25, Workflow as Workflow25 } from "@workglow/task-graph";
|
|
4202
|
+
var modelSchema16 = TypeModel("model:ImageToTextTask");
|
|
4913
4203
|
var generatedTextSchema = {
|
|
4914
4204
|
type: "string",
|
|
4915
4205
|
title: "Text",
|
|
@@ -4919,7 +4209,7 @@ var ImageToTextInputSchema = {
|
|
|
4919
4209
|
type: "object",
|
|
4920
4210
|
properties: {
|
|
4921
4211
|
image: TypeImageInput,
|
|
4922
|
-
model:
|
|
4212
|
+
model: modelSchema16,
|
|
4923
4213
|
maxTokens: {
|
|
4924
4214
|
type: "number",
|
|
4925
4215
|
title: "Max Tokens",
|
|
@@ -4960,15 +4250,15 @@ class ImageToTextTask extends AiVisionTask {
|
|
|
4960
4250
|
var imageToText = (input, config) => {
|
|
4961
4251
|
return new ImageToTextTask(config).run(input);
|
|
4962
4252
|
};
|
|
4963
|
-
|
|
4253
|
+
Workflow25.prototype.imageToText = CreateWorkflow25(ImageToTextTask);
|
|
4964
4254
|
|
|
4965
4255
|
// src/task/ModelInfoTask.ts
|
|
4966
|
-
import { CreateWorkflow as
|
|
4967
|
-
var
|
|
4256
|
+
import { CreateWorkflow as CreateWorkflow26, Workflow as Workflow26 } from "@workglow/task-graph";
|
|
4257
|
+
var modelSchema17 = TypeModel("model");
|
|
4968
4258
|
var ModelInfoInputSchema = {
|
|
4969
4259
|
type: "object",
|
|
4970
4260
|
properties: {
|
|
4971
|
-
model:
|
|
4261
|
+
model: modelSchema17,
|
|
4972
4262
|
detail: {
|
|
4973
4263
|
type: "string",
|
|
4974
4264
|
enum: ["cached_status", "files", "files_with_metadata", "dimensions"],
|
|
@@ -4981,7 +4271,7 @@ var ModelInfoInputSchema = {
|
|
|
4981
4271
|
var ModelInfoOutputSchema = {
|
|
4982
4272
|
type: "object",
|
|
4983
4273
|
properties: {
|
|
4984
|
-
model:
|
|
4274
|
+
model: modelSchema17,
|
|
4985
4275
|
is_local: { type: "boolean" },
|
|
4986
4276
|
is_remote: { type: "boolean" },
|
|
4987
4277
|
supports_browser: { type: "boolean" },
|
|
@@ -5039,10 +4329,10 @@ class ModelInfoTask extends AiTask {
|
|
|
5039
4329
|
var modelInfo = (input, config) => {
|
|
5040
4330
|
return new ModelInfoTask(config).run(input);
|
|
5041
4331
|
};
|
|
5042
|
-
|
|
4332
|
+
Workflow26.prototype.modelInfo = CreateWorkflow26(ModelInfoTask);
|
|
5043
4333
|
|
|
5044
4334
|
// src/task/ModelSearchTask.ts
|
|
5045
|
-
import { CreateWorkflow as
|
|
4335
|
+
import { CreateWorkflow as CreateWorkflow27, Task as Task13, Workflow as Workflow27 } from "@workglow/task-graph";
|
|
5046
4336
|
var ModelSearchInputSchema = {
|
|
5047
4337
|
type: "object",
|
|
5048
4338
|
properties: {
|
|
@@ -5107,7 +4397,7 @@ var ModelSearchOutputSchema = {
|
|
|
5107
4397
|
additionalProperties: false
|
|
5108
4398
|
};
|
|
5109
4399
|
|
|
5110
|
-
class ModelSearchTask extends
|
|
4400
|
+
class ModelSearchTask extends Task13 {
|
|
5111
4401
|
static type = "ModelSearchTask";
|
|
5112
4402
|
static category = "AI Model";
|
|
5113
4403
|
static title = "Model Search";
|
|
@@ -5133,11 +4423,11 @@ class ModelSearchTask extends Task14 {
|
|
|
5133
4423
|
var modelSearch = (input, config) => {
|
|
5134
4424
|
return new ModelSearchTask(config).run(input);
|
|
5135
4425
|
};
|
|
5136
|
-
|
|
4426
|
+
Workflow27.prototype.modelSearch = CreateWorkflow27(ModelSearchTask);
|
|
5137
4427
|
|
|
5138
4428
|
// src/task/ObjectDetectionTask.ts
|
|
5139
|
-
import { CreateWorkflow as
|
|
5140
|
-
var
|
|
4429
|
+
import { CreateWorkflow as CreateWorkflow28, Workflow as Workflow28 } from "@workglow/task-graph";
|
|
4430
|
+
var modelSchema18 = TypeModel("model:ObjectDetectionTask");
|
|
5141
4431
|
var detectionSchema = {
|
|
5142
4432
|
type: "object",
|
|
5143
4433
|
properties: {
|
|
@@ -5162,7 +4452,7 @@ var ObjectDetectionInputSchema = {
|
|
|
5162
4452
|
type: "object",
|
|
5163
4453
|
properties: {
|
|
5164
4454
|
image: TypeImageInput,
|
|
5165
|
-
model:
|
|
4455
|
+
model: modelSchema18,
|
|
5166
4456
|
labels: {
|
|
5167
4457
|
type: "array",
|
|
5168
4458
|
items: {
|
|
@@ -5216,11 +4506,11 @@ class ObjectDetectionTask extends AiVisionTask {
|
|
|
5216
4506
|
var objectDetection = (input, config) => {
|
|
5217
4507
|
return new ObjectDetectionTask(config).run(input);
|
|
5218
4508
|
};
|
|
5219
|
-
|
|
4509
|
+
Workflow28.prototype.objectDetection = CreateWorkflow28(ObjectDetectionTask);
|
|
5220
4510
|
|
|
5221
4511
|
// src/task/PoseLandmarkerTask.ts
|
|
5222
|
-
import { CreateWorkflow as
|
|
5223
|
-
var
|
|
4512
|
+
import { CreateWorkflow as CreateWorkflow29, Workflow as Workflow29 } from "@workglow/task-graph";
|
|
4513
|
+
var modelSchema19 = TypeModel("model:PoseLandmarkerTask");
|
|
5224
4514
|
var TypePoseLandmark = {
|
|
5225
4515
|
type: "object",
|
|
5226
4516
|
properties: {
|
|
@@ -5299,7 +4589,7 @@ var PoseLandmarkerInputSchema = {
|
|
|
5299
4589
|
type: "object",
|
|
5300
4590
|
properties: {
|
|
5301
4591
|
image: TypeImageInput,
|
|
5302
|
-
model:
|
|
4592
|
+
model: modelSchema19,
|
|
5303
4593
|
numPoses: {
|
|
5304
4594
|
type: "number",
|
|
5305
4595
|
minimum: 1,
|
|
@@ -5378,10 +4668,10 @@ class PoseLandmarkerTask extends AiVisionTask {
|
|
|
5378
4668
|
var poseLandmarker = (input, config) => {
|
|
5379
4669
|
return new PoseLandmarkerTask(config).run(input);
|
|
5380
4670
|
};
|
|
5381
|
-
|
|
4671
|
+
Workflow29.prototype.poseLandmarker = CreateWorkflow29(PoseLandmarkerTask);
|
|
5382
4672
|
|
|
5383
4673
|
// src/task/QueryExpanderTask.ts
|
|
5384
|
-
import { CreateWorkflow as
|
|
4674
|
+
import { CreateWorkflow as CreateWorkflow30, Task as Task14, Workflow as Workflow30 } from "@workglow/task-graph";
|
|
5385
4675
|
var QueryExpansionMethod = {
|
|
5386
4676
|
MULTI_QUERY: "multi-query",
|
|
5387
4677
|
HYDE: "hyde",
|
|
@@ -5449,7 +4739,7 @@ var outputSchema12 = {
|
|
|
5449
4739
|
additionalProperties: false
|
|
5450
4740
|
};
|
|
5451
4741
|
|
|
5452
|
-
class QueryExpanderTask extends
|
|
4742
|
+
class QueryExpanderTask extends Task14 {
|
|
5453
4743
|
static type = "QueryExpanderTask";
|
|
5454
4744
|
static category = "RAG";
|
|
5455
4745
|
static title = "Query Expander";
|
|
@@ -5591,14 +4881,14 @@ class QueryExpanderTask extends Task15 {
|
|
|
5591
4881
|
var queryExpander = (input, config) => {
|
|
5592
4882
|
return new QueryExpanderTask(config).run(input);
|
|
5593
4883
|
};
|
|
5594
|
-
|
|
4884
|
+
Workflow30.prototype.queryExpander = CreateWorkflow30(QueryExpanderTask);
|
|
5595
4885
|
|
|
5596
4886
|
// src/task/RerankerTask.ts
|
|
5597
|
-
import { CreateWorkflow as
|
|
4887
|
+
import { CreateWorkflow as CreateWorkflow32, Task as Task15, Workflow as Workflow32 } from "@workglow/task-graph";
|
|
5598
4888
|
|
|
5599
4889
|
// src/task/TextClassificationTask.ts
|
|
5600
|
-
import { CreateWorkflow as
|
|
5601
|
-
var
|
|
4890
|
+
import { CreateWorkflow as CreateWorkflow31, Workflow as Workflow31 } from "@workglow/task-graph";
|
|
4891
|
+
var modelSchema20 = TypeModel("model:TextClassificationTask");
|
|
5602
4892
|
var TextClassificationInputSchema = {
|
|
5603
4893
|
type: "object",
|
|
5604
4894
|
properties: {
|
|
@@ -5625,7 +4915,7 @@ var TextClassificationInputSchema = {
|
|
|
5625
4915
|
description: "The maximum number of categories to return",
|
|
5626
4916
|
"x-ui-group": "Configuration"
|
|
5627
4917
|
},
|
|
5628
|
-
model:
|
|
4918
|
+
model: modelSchema20
|
|
5629
4919
|
},
|
|
5630
4920
|
required: ["text", "model"],
|
|
5631
4921
|
additionalProperties: false
|
|
@@ -5675,7 +4965,7 @@ class TextClassificationTask extends AiTask {
|
|
|
5675
4965
|
var textClassification = (input, config) => {
|
|
5676
4966
|
return new TextClassificationTask(config).run(input);
|
|
5677
4967
|
};
|
|
5678
|
-
|
|
4968
|
+
Workflow31.prototype.textClassification = CreateWorkflow31(TextClassificationTask);
|
|
5679
4969
|
|
|
5680
4970
|
// src/task/RerankerTask.ts
|
|
5681
4971
|
var inputSchema13 = {
|
|
@@ -5770,7 +5060,7 @@ var outputSchema13 = {
|
|
|
5770
5060
|
additionalProperties: false
|
|
5771
5061
|
};
|
|
5772
5062
|
|
|
5773
|
-
class RerankerTask extends
|
|
5063
|
+
class RerankerTask extends Task15 {
|
|
5774
5064
|
static type = "RerankerTask";
|
|
5775
5065
|
static category = "RAG";
|
|
5776
5066
|
static title = "Reranker";
|
|
@@ -5898,11 +5188,11 @@ class RerankerTask extends Task16 {
|
|
|
5898
5188
|
var reranker = (input, config) => {
|
|
5899
5189
|
return new RerankerTask(config).run(input);
|
|
5900
5190
|
};
|
|
5901
|
-
|
|
5191
|
+
Workflow32.prototype.reranker = CreateWorkflow32(RerankerTask);
|
|
5902
5192
|
|
|
5903
5193
|
// src/task/StructuralParserTask.ts
|
|
5904
5194
|
import { StructuralParser } from "@workglow/knowledge-base";
|
|
5905
|
-
import { CreateWorkflow as
|
|
5195
|
+
import { CreateWorkflow as CreateWorkflow33, Task as Task16, Workflow as Workflow33 } from "@workglow/task-graph";
|
|
5906
5196
|
import { uuid4 as uuid42 } from "@workglow/util";
|
|
5907
5197
|
var inputSchema14 = {
|
|
5908
5198
|
type: "object",
|
|
@@ -5962,7 +5252,7 @@ var outputSchema14 = {
|
|
|
5962
5252
|
additionalProperties: false
|
|
5963
5253
|
};
|
|
5964
5254
|
|
|
5965
|
-
class StructuralParserTask extends
|
|
5255
|
+
class StructuralParserTask extends Task16 {
|
|
5966
5256
|
static type = "StructuralParserTask";
|
|
5967
5257
|
static category = "Document";
|
|
5968
5258
|
static title = "Structural Parser";
|
|
@@ -6005,15 +5295,15 @@ class StructuralParserTask extends Task17 {
|
|
|
6005
5295
|
var structuralParser = (input, config) => {
|
|
6006
5296
|
return new StructuralParserTask(config).run(input);
|
|
6007
5297
|
};
|
|
6008
|
-
|
|
5298
|
+
Workflow33.prototype.structuralParser = CreateWorkflow33(StructuralParserTask);
|
|
6009
5299
|
|
|
6010
5300
|
// src/task/StructuredGenerationTask.ts
|
|
6011
|
-
import { CreateWorkflow as
|
|
6012
|
-
var
|
|
5301
|
+
import { CreateWorkflow as CreateWorkflow34, Workflow as Workflow34 } from "@workglow/task-graph";
|
|
5302
|
+
var modelSchema21 = TypeModel("model:StructuredGenerationTask");
|
|
6013
5303
|
var StructuredGenerationInputSchema = {
|
|
6014
5304
|
type: "object",
|
|
6015
5305
|
properties: {
|
|
6016
|
-
model:
|
|
5306
|
+
model: modelSchema21,
|
|
6017
5307
|
prompt: {
|
|
6018
5308
|
type: "string",
|
|
6019
5309
|
title: "Prompt",
|
|
@@ -6076,10 +5366,10 @@ class StructuredGenerationTask extends StreamingAiTask {
|
|
|
6076
5366
|
var structuredGeneration = (input, config) => {
|
|
6077
5367
|
return new StructuredGenerationTask(config).run(input);
|
|
6078
5368
|
};
|
|
6079
|
-
|
|
5369
|
+
Workflow34.prototype.structuredGeneration = CreateWorkflow34(StructuredGenerationTask);
|
|
6080
5370
|
|
|
6081
5371
|
// src/task/TextChunkerTask.ts
|
|
6082
|
-
import { CreateWorkflow as
|
|
5372
|
+
import { CreateWorkflow as CreateWorkflow35, Task as Task17, Workflow as Workflow35 } from "@workglow/task-graph";
|
|
6083
5373
|
var ChunkingStrategy = {
|
|
6084
5374
|
FIXED: "fixed",
|
|
6085
5375
|
SENTENCE: "sentence",
|
|
@@ -6148,7 +5438,7 @@ var outputSchema15 = {
|
|
|
6148
5438
|
additionalProperties: false
|
|
6149
5439
|
};
|
|
6150
5440
|
|
|
6151
|
-
class TextChunkerTask extends
|
|
5441
|
+
class TextChunkerTask extends Task17 {
|
|
6152
5442
|
static type = "TextChunkerTask";
|
|
6153
5443
|
static category = "Document";
|
|
6154
5444
|
static title = "Text Chunker";
|
|
@@ -6328,11 +5618,11 @@ class TextChunkerTask extends Task18 {
|
|
|
6328
5618
|
var textChunker = (input, config) => {
|
|
6329
5619
|
return new TextChunkerTask(config).run(input);
|
|
6330
5620
|
};
|
|
6331
|
-
|
|
5621
|
+
Workflow35.prototype.textChunker = CreateWorkflow35(TextChunkerTask);
|
|
6332
5622
|
|
|
6333
5623
|
// src/task/TextFillMaskTask.ts
|
|
6334
|
-
import { CreateWorkflow as
|
|
6335
|
-
var
|
|
5624
|
+
import { CreateWorkflow as CreateWorkflow36, Workflow as Workflow36 } from "@workglow/task-graph";
|
|
5625
|
+
var modelSchema22 = TypeModel("model:TextFillMaskTask");
|
|
6336
5626
|
var TextFillMaskInputSchema = {
|
|
6337
5627
|
type: "object",
|
|
6338
5628
|
properties: {
|
|
@@ -6341,7 +5631,7 @@ var TextFillMaskInputSchema = {
|
|
|
6341
5631
|
title: "Text",
|
|
6342
5632
|
description: "The text with a mask token to fill"
|
|
6343
5633
|
},
|
|
6344
|
-
model:
|
|
5634
|
+
model: modelSchema22
|
|
6345
5635
|
},
|
|
6346
5636
|
required: ["text", "model"],
|
|
6347
5637
|
additionalProperties: false
|
|
@@ -6396,21 +5686,21 @@ class TextFillMaskTask extends AiTask {
|
|
|
6396
5686
|
var textFillMask = (input, config) => {
|
|
6397
5687
|
return new TextFillMaskTask(config).run(input);
|
|
6398
5688
|
};
|
|
6399
|
-
|
|
5689
|
+
Workflow36.prototype.textFillMask = CreateWorkflow36(TextFillMaskTask);
|
|
6400
5690
|
|
|
6401
5691
|
// src/task/TextGenerationTask.ts
|
|
6402
|
-
import { CreateWorkflow as
|
|
5692
|
+
import { CreateWorkflow as CreateWorkflow37, Workflow as Workflow37 } from "@workglow/task-graph";
|
|
6403
5693
|
var generatedTextSchema2 = {
|
|
6404
5694
|
type: "string",
|
|
6405
5695
|
title: "Text",
|
|
6406
5696
|
description: "The generated text",
|
|
6407
5697
|
"x-stream": "append"
|
|
6408
5698
|
};
|
|
6409
|
-
var
|
|
5699
|
+
var modelSchema23 = TypeModel("model:TextGenerationTask");
|
|
6410
5700
|
var TextGenerationInputSchema = {
|
|
6411
5701
|
type: "object",
|
|
6412
5702
|
properties: {
|
|
6413
|
-
model:
|
|
5703
|
+
model: modelSchema23,
|
|
6414
5704
|
prompt: {
|
|
6415
5705
|
type: "string",
|
|
6416
5706
|
title: "Prompt",
|
|
@@ -6484,11 +5774,11 @@ class TextGenerationTask extends StreamingAiTask {
|
|
|
6484
5774
|
var textGeneration = (input, config) => {
|
|
6485
5775
|
return new TextGenerationTask(config).run(input);
|
|
6486
5776
|
};
|
|
6487
|
-
|
|
5777
|
+
Workflow37.prototype.textGeneration = CreateWorkflow37(TextGenerationTask);
|
|
6488
5778
|
|
|
6489
5779
|
// src/task/TextLanguageDetectionTask.ts
|
|
6490
|
-
import { CreateWorkflow as
|
|
6491
|
-
var
|
|
5780
|
+
import { CreateWorkflow as CreateWorkflow38, Workflow as Workflow38 } from "@workglow/task-graph";
|
|
5781
|
+
var modelSchema24 = TypeModel("model:TextLanguageDetectionTask");
|
|
6492
5782
|
var TextLanguageDetectionInputSchema = {
|
|
6493
5783
|
type: "object",
|
|
6494
5784
|
properties: {
|
|
@@ -6505,7 +5795,7 @@ var TextLanguageDetectionInputSchema = {
|
|
|
6505
5795
|
title: "Max Languages",
|
|
6506
5796
|
description: "The maximum number of languages to return"
|
|
6507
5797
|
},
|
|
6508
|
-
model:
|
|
5798
|
+
model: modelSchema24
|
|
6509
5799
|
},
|
|
6510
5800
|
required: ["text", "model"],
|
|
6511
5801
|
additionalProperties: false
|
|
@@ -6555,10 +5845,10 @@ class TextLanguageDetectionTask extends AiTask {
|
|
|
6555
5845
|
var textLanguageDetection = (input, config) => {
|
|
6556
5846
|
return new TextLanguageDetectionTask(config).run(input);
|
|
6557
5847
|
};
|
|
6558
|
-
|
|
5848
|
+
Workflow38.prototype.textLanguageDetection = CreateWorkflow38(TextLanguageDetectionTask);
|
|
6559
5849
|
|
|
6560
5850
|
// src/task/TextQuestionAnswerTask.ts
|
|
6561
|
-
import { CreateWorkflow as
|
|
5851
|
+
import { CreateWorkflow as CreateWorkflow39, Workflow as Workflow39 } from "@workglow/task-graph";
|
|
6562
5852
|
var contextSchema = {
|
|
6563
5853
|
type: "string",
|
|
6564
5854
|
title: "Context",
|
|
@@ -6575,13 +5865,13 @@ var textSchema = {
|
|
|
6575
5865
|
description: "The generated text",
|
|
6576
5866
|
"x-stream": "append"
|
|
6577
5867
|
};
|
|
6578
|
-
var
|
|
5868
|
+
var modelSchema25 = TypeModel("model:TextQuestionAnswerTask");
|
|
6579
5869
|
var TextQuestionAnswerInputSchema = {
|
|
6580
5870
|
type: "object",
|
|
6581
5871
|
properties: {
|
|
6582
5872
|
context: contextSchema,
|
|
6583
5873
|
question: questionSchema,
|
|
6584
|
-
model:
|
|
5874
|
+
model: modelSchema25
|
|
6585
5875
|
},
|
|
6586
5876
|
required: ["context", "question", "model"],
|
|
6587
5877
|
additionalProperties: false
|
|
@@ -6610,11 +5900,11 @@ class TextQuestionAnswerTask extends StreamingAiTask {
|
|
|
6610
5900
|
var textQuestionAnswer = (input, config) => {
|
|
6611
5901
|
return new TextQuestionAnswerTask(config).run(input);
|
|
6612
5902
|
};
|
|
6613
|
-
|
|
5903
|
+
Workflow39.prototype.textQuestionAnswer = CreateWorkflow39(TextQuestionAnswerTask);
|
|
6614
5904
|
|
|
6615
5905
|
// src/task/TextRewriterTask.ts
|
|
6616
|
-
import { CreateWorkflow as
|
|
6617
|
-
var
|
|
5906
|
+
import { CreateWorkflow as CreateWorkflow40, Workflow as Workflow40 } from "@workglow/task-graph";
|
|
5907
|
+
var modelSchema26 = TypeModel("model:TextRewriterTask");
|
|
6618
5908
|
var TextRewriterInputSchema = {
|
|
6619
5909
|
type: "object",
|
|
6620
5910
|
properties: {
|
|
@@ -6628,7 +5918,7 @@ var TextRewriterInputSchema = {
|
|
|
6628
5918
|
title: "Prompt",
|
|
6629
5919
|
description: "The prompt to direct the rewriting"
|
|
6630
5920
|
},
|
|
6631
|
-
model:
|
|
5921
|
+
model: modelSchema26
|
|
6632
5922
|
},
|
|
6633
5923
|
required: ["text", "prompt", "model"],
|
|
6634
5924
|
additionalProperties: false
|
|
@@ -6662,11 +5952,11 @@ class TextRewriterTask extends StreamingAiTask {
|
|
|
6662
5952
|
var textRewriter = (input, config) => {
|
|
6663
5953
|
return new TextRewriterTask(config).run(input);
|
|
6664
5954
|
};
|
|
6665
|
-
|
|
5955
|
+
Workflow40.prototype.textRewriter = CreateWorkflow40(TextRewriterTask);
|
|
6666
5956
|
|
|
6667
5957
|
// src/task/TextTranslationTask.ts
|
|
6668
|
-
import { CreateWorkflow as
|
|
6669
|
-
var
|
|
5958
|
+
import { CreateWorkflow as CreateWorkflow41, Workflow as Workflow41 } from "@workglow/task-graph";
|
|
5959
|
+
var modelSchema27 = TypeModel("model:TextTranslationTask");
|
|
6670
5960
|
var translationTextSchema = {
|
|
6671
5961
|
type: "string",
|
|
6672
5962
|
title: "Text",
|
|
@@ -6693,7 +5983,7 @@ var TextTranslationInputSchema = {
|
|
|
6693
5983
|
minLength: 2,
|
|
6694
5984
|
maxLength: 2
|
|
6695
5985
|
}),
|
|
6696
|
-
model:
|
|
5986
|
+
model: modelSchema27
|
|
6697
5987
|
},
|
|
6698
5988
|
required: ["text", "source_lang", "target_lang", "model"],
|
|
6699
5989
|
additionalProperties: false
|
|
@@ -6728,10 +6018,253 @@ class TextTranslationTask extends StreamingAiTask {
|
|
|
6728
6018
|
var textTranslation = (input, config) => {
|
|
6729
6019
|
return new TextTranslationTask(config).run(input);
|
|
6730
6020
|
};
|
|
6731
|
-
|
|
6021
|
+
Workflow41.prototype.textTranslation = CreateWorkflow41(TextTranslationTask);
|
|
6022
|
+
|
|
6023
|
+
// src/task/ToolCallingTask.ts
|
|
6024
|
+
import { CreateWorkflow as CreateWorkflow42, getTaskConstructors, Workflow as Workflow42 } from "@workglow/task-graph";
|
|
6025
|
+
import { makeFingerprint } from "@workglow/util";
|
|
6026
|
+
function taskTypesToTools(taskNames, registry) {
|
|
6027
|
+
const constructors = getTaskConstructors(registry);
|
|
6028
|
+
return taskNames.map((name) => {
|
|
6029
|
+
const ctor = constructors.get(name);
|
|
6030
|
+
if (!ctor) {
|
|
6031
|
+
throw new Error(`taskTypesToTools: Unknown task type "${name}" — not found in task constructors registry (ServiceRegistry: ${registry ? "custom" : "default"})`);
|
|
6032
|
+
}
|
|
6033
|
+
const configSchema = "configSchema" in ctor && typeof ctor.configSchema === "function" ? ctor.configSchema() : undefined;
|
|
6034
|
+
return {
|
|
6035
|
+
name: ctor.type,
|
|
6036
|
+
description: ctor.description ?? "",
|
|
6037
|
+
inputSchema: ctor.inputSchema(),
|
|
6038
|
+
outputSchema: ctor.outputSchema(),
|
|
6039
|
+
...configSchema ? { configSchema } : {},
|
|
6040
|
+
taskType: name
|
|
6041
|
+
};
|
|
6042
|
+
});
|
|
6043
|
+
}
|
|
6044
|
+
var ToolDefinitionSchema = {
|
|
6045
|
+
type: "object",
|
|
6046
|
+
properties: {
|
|
6047
|
+
name: {
|
|
6048
|
+
type: "string",
|
|
6049
|
+
title: "Name",
|
|
6050
|
+
description: "The tool name"
|
|
6051
|
+
},
|
|
6052
|
+
description: {
|
|
6053
|
+
type: "string",
|
|
6054
|
+
title: "Description",
|
|
6055
|
+
description: "A description of what the tool does"
|
|
6056
|
+
},
|
|
6057
|
+
inputSchema: {
|
|
6058
|
+
type: "object",
|
|
6059
|
+
title: "Input Schema",
|
|
6060
|
+
description: "JSON Schema describing the tool's input parameters",
|
|
6061
|
+
additionalProperties: true
|
|
6062
|
+
},
|
|
6063
|
+
outputSchema: {
|
|
6064
|
+
type: "object",
|
|
6065
|
+
title: "Output Schema",
|
|
6066
|
+
description: "JSON Schema describing what the tool returns",
|
|
6067
|
+
additionalProperties: true
|
|
6068
|
+
},
|
|
6069
|
+
configSchema: {
|
|
6070
|
+
type: "object",
|
|
6071
|
+
title: "Config Schema",
|
|
6072
|
+
description: "JSON Schema describing the task's configuration options (not sent to the LLM)",
|
|
6073
|
+
additionalProperties: true
|
|
6074
|
+
},
|
|
6075
|
+
config: {
|
|
6076
|
+
type: "object",
|
|
6077
|
+
title: "Config",
|
|
6078
|
+
description: "Concrete configuration values for the backing task (not sent to the LLM)",
|
|
6079
|
+
additionalProperties: true
|
|
6080
|
+
}
|
|
6081
|
+
},
|
|
6082
|
+
required: ["name", "description", "inputSchema"],
|
|
6083
|
+
additionalProperties: true
|
|
6084
|
+
};
|
|
6085
|
+
var ToolCallSchema = {
|
|
6086
|
+
type: "object",
|
|
6087
|
+
properties: {
|
|
6088
|
+
id: {
|
|
6089
|
+
type: "string",
|
|
6090
|
+
title: "ID",
|
|
6091
|
+
description: "Unique identifier for this tool call"
|
|
6092
|
+
},
|
|
6093
|
+
name: {
|
|
6094
|
+
type: "string",
|
|
6095
|
+
title: "Name",
|
|
6096
|
+
description: "The name of the tool to invoke"
|
|
6097
|
+
},
|
|
6098
|
+
input: {
|
|
6099
|
+
type: "object",
|
|
6100
|
+
title: "Input",
|
|
6101
|
+
description: "The input arguments for the tool call",
|
|
6102
|
+
additionalProperties: true
|
|
6103
|
+
}
|
|
6104
|
+
},
|
|
6105
|
+
required: ["id", "name", "input"],
|
|
6106
|
+
additionalProperties: false
|
|
6107
|
+
};
|
|
6108
|
+
var modelSchema28 = TypeModel("model:ToolCallingTask");
|
|
6109
|
+
var ToolCallingInputSchema = {
|
|
6110
|
+
type: "object",
|
|
6111
|
+
properties: {
|
|
6112
|
+
model: modelSchema28,
|
|
6113
|
+
prompt: {
|
|
6114
|
+
oneOf: [
|
|
6115
|
+
{ type: "string", title: "Prompt", description: "The prompt to send to the model" },
|
|
6116
|
+
{
|
|
6117
|
+
type: "array",
|
|
6118
|
+
title: "Prompt",
|
|
6119
|
+
description: "The prompt as an array of strings or content blocks",
|
|
6120
|
+
items: {
|
|
6121
|
+
oneOf: [
|
|
6122
|
+
{ type: "string" },
|
|
6123
|
+
{
|
|
6124
|
+
type: "object",
|
|
6125
|
+
properties: {
|
|
6126
|
+
type: { type: "string", enum: ["text", "image", "audio"] }
|
|
6127
|
+
},
|
|
6128
|
+
required: ["type"],
|
|
6129
|
+
additionalProperties: true
|
|
6130
|
+
}
|
|
6131
|
+
]
|
|
6132
|
+
}
|
|
6133
|
+
}
|
|
6134
|
+
],
|
|
6135
|
+
title: "Prompt",
|
|
6136
|
+
description: "The prompt to send to the model"
|
|
6137
|
+
},
|
|
6138
|
+
systemPrompt: {
|
|
6139
|
+
type: "string",
|
|
6140
|
+
title: "System Prompt",
|
|
6141
|
+
description: "Optional system instructions for the model"
|
|
6142
|
+
},
|
|
6143
|
+
messages: {
|
|
6144
|
+
type: "array",
|
|
6145
|
+
title: "Messages",
|
|
6146
|
+
description: "Full conversation history for multi-turn interactions. When provided, used instead of prompt to construct the messages array sent to the provider.",
|
|
6147
|
+
items: {
|
|
6148
|
+
type: "object",
|
|
6149
|
+
properties: {
|
|
6150
|
+
role: { type: "string", enum: ["user", "assistant", "tool"] },
|
|
6151
|
+
content: {}
|
|
6152
|
+
},
|
|
6153
|
+
required: ["role", "content"],
|
|
6154
|
+
additionalProperties: true
|
|
6155
|
+
}
|
|
6156
|
+
},
|
|
6157
|
+
tools: {
|
|
6158
|
+
type: "array",
|
|
6159
|
+
format: "tasks",
|
|
6160
|
+
title: "Tools",
|
|
6161
|
+
description: "Tool definitions available for the model to call",
|
|
6162
|
+
items: {
|
|
6163
|
+
oneOf: [
|
|
6164
|
+
{ type: "string", format: "tasks", description: "Task type name" },
|
|
6165
|
+
ToolDefinitionSchema
|
|
6166
|
+
]
|
|
6167
|
+
}
|
|
6168
|
+
},
|
|
6169
|
+
toolChoice: {
|
|
6170
|
+
type: "string",
|
|
6171
|
+
title: "Tool Choice",
|
|
6172
|
+
description: 'Controls tool selection: "auto" (model decides), "none" (no tools), "required" (must call a tool), or a specific tool name',
|
|
6173
|
+
"x-ui-group": "Configuration"
|
|
6174
|
+
},
|
|
6175
|
+
maxTokens: {
|
|
6176
|
+
type: "number",
|
|
6177
|
+
title: "Max Tokens",
|
|
6178
|
+
description: "The maximum number of tokens to generate",
|
|
6179
|
+
minimum: 1,
|
|
6180
|
+
"x-ui-group": "Configuration"
|
|
6181
|
+
},
|
|
6182
|
+
temperature: {
|
|
6183
|
+
type: "number",
|
|
6184
|
+
title: "Temperature",
|
|
6185
|
+
description: "The temperature to use for sampling",
|
|
6186
|
+
minimum: 0,
|
|
6187
|
+
maximum: 2,
|
|
6188
|
+
"x-ui-group": "Configuration"
|
|
6189
|
+
}
|
|
6190
|
+
},
|
|
6191
|
+
required: ["model", "prompt", "tools"],
|
|
6192
|
+
additionalProperties: false
|
|
6193
|
+
};
|
|
6194
|
+
var ToolCallingOutputSchema = {
|
|
6195
|
+
type: "object",
|
|
6196
|
+
properties: {
|
|
6197
|
+
text: {
|
|
6198
|
+
type: "string",
|
|
6199
|
+
title: "Text",
|
|
6200
|
+
description: "Any text content generated by the model",
|
|
6201
|
+
"x-stream": "append"
|
|
6202
|
+
},
|
|
6203
|
+
toolCalls: {
|
|
6204
|
+
type: "array",
|
|
6205
|
+
items: ToolCallSchema,
|
|
6206
|
+
title: "Tool Calls",
|
|
6207
|
+
description: "Tool calls requested by the model",
|
|
6208
|
+
"x-stream": "object"
|
|
6209
|
+
}
|
|
6210
|
+
},
|
|
6211
|
+
required: ["text", "toolCalls"],
|
|
6212
|
+
additionalProperties: false
|
|
6213
|
+
};
|
|
6214
|
+
|
|
6215
|
+
class ToolCallingTask extends StreamingAiTask {
|
|
6216
|
+
static type = "ToolCallingTask";
|
|
6217
|
+
static category = "AI Text Model";
|
|
6218
|
+
static title = "Tool Calling";
|
|
6219
|
+
static description = "Sends a prompt with tool definitions to a language model and returns text along with any tool calls the model requests";
|
|
6220
|
+
static inputSchema() {
|
|
6221
|
+
return ToolCallingInputSchema;
|
|
6222
|
+
}
|
|
6223
|
+
static outputSchema() {
|
|
6224
|
+
return ToolCallingOutputSchema;
|
|
6225
|
+
}
|
|
6226
|
+
_computedSessionId;
|
|
6227
|
+
async getJobInput(input) {
|
|
6228
|
+
const jobInput = await super.getJobInput(input);
|
|
6229
|
+
if (!jobInput.sessionId && input.tools && input.tools.length > 0) {
|
|
6230
|
+
jobInput.sessionId = await makeFingerprint({
|
|
6231
|
+
tools: input.tools,
|
|
6232
|
+
systemPrompt: input.systemPrompt,
|
|
6233
|
+
runnerId: this.runConfig.runnerId
|
|
6234
|
+
});
|
|
6235
|
+
this._computedSessionId = jobInput.sessionId;
|
|
6236
|
+
}
|
|
6237
|
+
return jobInput;
|
|
6238
|
+
}
|
|
6239
|
+
registerSessionDispose(input, context) {
|
|
6240
|
+
const sessionId = this._computedSessionId;
|
|
6241
|
+
if (!sessionId || !context.resourceScope)
|
|
6242
|
+
return;
|
|
6243
|
+
const model = input.model;
|
|
6244
|
+
if (!model || typeof model !== "object")
|
|
6245
|
+
return;
|
|
6246
|
+
const providerName = model.provider;
|
|
6247
|
+
context.resourceScope.register(`ai:session:${sessionId}`, async () => {
|
|
6248
|
+
await getAiProviderRegistry().disposeSession(providerName, sessionId);
|
|
6249
|
+
});
|
|
6250
|
+
}
|
|
6251
|
+
async execute(input, executeContext) {
|
|
6252
|
+
const result = await super.execute(input, executeContext);
|
|
6253
|
+
this.registerSessionDispose(input, executeContext);
|
|
6254
|
+
return result;
|
|
6255
|
+
}
|
|
6256
|
+
async* executeStream(input, context) {
|
|
6257
|
+
yield* super.executeStream(input, context);
|
|
6258
|
+
this.registerSessionDispose(input, context);
|
|
6259
|
+
}
|
|
6260
|
+
}
|
|
6261
|
+
var toolCalling = (input, config) => {
|
|
6262
|
+
return new ToolCallingTask(config).run(input);
|
|
6263
|
+
};
|
|
6264
|
+
Workflow42.prototype.toolCalling = CreateWorkflow42(ToolCallingTask);
|
|
6732
6265
|
|
|
6733
6266
|
// src/task/TopicSegmenterTask.ts
|
|
6734
|
-
import { CreateWorkflow as
|
|
6267
|
+
import { CreateWorkflow as CreateWorkflow43, Task as Task18, Workflow as Workflow43 } from "@workglow/task-graph";
|
|
6735
6268
|
var SegmentationMethod = {
|
|
6736
6269
|
HEURISTIC: "heuristic",
|
|
6737
6270
|
EMBEDDING_SIMILARITY: "embedding-similarity",
|
|
@@ -6806,7 +6339,7 @@ var outputSchema16 = {
|
|
|
6806
6339
|
additionalProperties: false
|
|
6807
6340
|
};
|
|
6808
6341
|
|
|
6809
|
-
class TopicSegmenterTask extends
|
|
6342
|
+
class TopicSegmenterTask extends Task18 {
|
|
6810
6343
|
static type = "TopicSegmenterTask";
|
|
6811
6344
|
static category = "Document";
|
|
6812
6345
|
static title = "Topic Segmenter";
|
|
@@ -7011,15 +6544,15 @@ class TopicSegmenterTask extends Task19 {
|
|
|
7011
6544
|
var topicSegmenter = (input, config) => {
|
|
7012
6545
|
return new TopicSegmenterTask(config).run(input);
|
|
7013
6546
|
};
|
|
7014
|
-
|
|
6547
|
+
Workflow43.prototype.topicSegmenter = CreateWorkflow43(TopicSegmenterTask);
|
|
7015
6548
|
|
|
7016
6549
|
// src/task/UnloadModelTask.ts
|
|
7017
|
-
import { CreateWorkflow as
|
|
7018
|
-
var
|
|
6550
|
+
import { CreateWorkflow as CreateWorkflow44, Workflow as Workflow44 } from "@workglow/task-graph";
|
|
6551
|
+
var modelSchema29 = TypeModel("model");
|
|
7019
6552
|
var UnloadModelInputSchema = {
|
|
7020
6553
|
type: "object",
|
|
7021
6554
|
properties: {
|
|
7022
|
-
model:
|
|
6555
|
+
model: modelSchema29
|
|
7023
6556
|
},
|
|
7024
6557
|
required: ["model"],
|
|
7025
6558
|
additionalProperties: false
|
|
@@ -7027,7 +6560,7 @@ var UnloadModelInputSchema = {
|
|
|
7027
6560
|
var UnloadModelOutputSchema = {
|
|
7028
6561
|
type: "object",
|
|
7029
6562
|
properties: {
|
|
7030
|
-
model:
|
|
6563
|
+
model: modelSchema29
|
|
7031
6564
|
},
|
|
7032
6565
|
required: ["model"],
|
|
7033
6566
|
additionalProperties: false
|
|
@@ -7049,10 +6582,10 @@ class UnloadModelTask extends AiTask {
|
|
|
7049
6582
|
var unloadModel = (input, config) => {
|
|
7050
6583
|
return new UnloadModelTask(config).run(input);
|
|
7051
6584
|
};
|
|
7052
|
-
|
|
6585
|
+
Workflow44.prototype.unloadModel = CreateWorkflow44(UnloadModelTask);
|
|
7053
6586
|
|
|
7054
6587
|
// src/task/VectorQuantizeTask.ts
|
|
7055
|
-
import { CreateWorkflow as
|
|
6588
|
+
import { CreateWorkflow as CreateWorkflow45, Task as Task19, Workflow as Workflow45 } from "@workglow/task-graph";
|
|
7056
6589
|
import {
|
|
7057
6590
|
normalizeNumberArray,
|
|
7058
6591
|
TensorType,
|
|
@@ -7132,7 +6665,7 @@ var outputSchema17 = {
|
|
|
7132
6665
|
additionalProperties: false
|
|
7133
6666
|
};
|
|
7134
6667
|
|
|
7135
|
-
class VectorQuantizeTask extends
|
|
6668
|
+
class VectorQuantizeTask extends Task19 {
|
|
7136
6669
|
static type = "VectorQuantizeTask";
|
|
7137
6670
|
static category = "Vector";
|
|
7138
6671
|
static title = "Quantize";
|
|
@@ -7232,10 +6765,10 @@ class VectorQuantizeTask extends Task20 {
|
|
|
7232
6765
|
var vectorQuantize = (input, config) => {
|
|
7233
6766
|
return new VectorQuantizeTask(config).run(input);
|
|
7234
6767
|
};
|
|
7235
|
-
|
|
6768
|
+
Workflow45.prototype.vectorQuantize = CreateWorkflow45(VectorQuantizeTask);
|
|
7236
6769
|
|
|
7237
6770
|
// src/task/VectorSimilarityTask.ts
|
|
7238
|
-
import { CreateWorkflow as
|
|
6771
|
+
import { CreateWorkflow as CreateWorkflow46, GraphAsTask, Workflow as Workflow46 } from "@workglow/task-graph";
|
|
7239
6772
|
import {
|
|
7240
6773
|
cosineSimilarity,
|
|
7241
6774
|
hammingSimilarity,
|
|
@@ -7341,7 +6874,8 @@ class VectorSimilarityTask extends GraphAsTask {
|
|
|
7341
6874
|
var similarity = (input, config) => {
|
|
7342
6875
|
return new VectorSimilarityTask(config).run(input);
|
|
7343
6876
|
};
|
|
7344
|
-
|
|
6877
|
+
Workflow46.prototype.similarity = CreateWorkflow46(VectorSimilarityTask);
|
|
6878
|
+
|
|
7345
6879
|
// src/task/MessageConversion.ts
|
|
7346
6880
|
function getInputMessages(input) {
|
|
7347
6881
|
const messages = input.messages;
|
|
@@ -7542,7 +7076,6 @@ function toTextFlatMessages(input) {
|
|
|
7542
7076
|
// src/task/index.ts
|
|
7543
7077
|
var registerAiTasks = () => {
|
|
7544
7078
|
const tasks = [
|
|
7545
|
-
AgentTask,
|
|
7546
7079
|
BackgroundRemovalTask,
|
|
7547
7080
|
ChunkToVectorTask,
|
|
7548
7081
|
CountTokensTask,
|
|
@@ -7596,11 +7129,8 @@ var registerAiTasks = () => {
|
|
|
7596
7129
|
export {
|
|
7597
7130
|
vectorStoreSearch,
|
|
7598
7131
|
vectorQuantize,
|
|
7599
|
-
userMessage,
|
|
7600
7132
|
unloadModel,
|
|
7601
7133
|
topicSegmenter,
|
|
7602
|
-
toolSourceDefinitions,
|
|
7603
|
-
toolMessage,
|
|
7604
7134
|
toolCalling,
|
|
7605
7135
|
toTextFlatMessages,
|
|
7606
7136
|
toOpenAIMessages,
|
|
@@ -7635,38 +7165,26 @@ export {
|
|
|
7635
7165
|
imageSegmentation,
|
|
7636
7166
|
imageEmbedding,
|
|
7637
7167
|
imageClassification,
|
|
7638
|
-
imageBlockFromDataUri,
|
|
7639
|
-
imageBlock,
|
|
7640
7168
|
hybridSearch,
|
|
7641
7169
|
hierarchyJoin,
|
|
7642
7170
|
hierarchicalChunker,
|
|
7643
|
-
hasToolCalls,
|
|
7644
7171
|
handLandmarker,
|
|
7645
7172
|
getGlobalModelRepository,
|
|
7646
7173
|
getAiProviderRegistry,
|
|
7647
7174
|
gestureRecognizer,
|
|
7648
|
-
findToolSource,
|
|
7649
7175
|
filterValidToolCalls,
|
|
7650
7176
|
faceLandmarker,
|
|
7651
7177
|
faceDetector,
|
|
7652
|
-
executeToolCalls,
|
|
7653
|
-
executeToolCall,
|
|
7654
7178
|
downloadModel,
|
|
7655
7179
|
documentUpsert,
|
|
7656
7180
|
documentEnricher,
|
|
7657
7181
|
countTokens,
|
|
7658
|
-
countAssistantToolUses,
|
|
7659
7182
|
contextBuilder,
|
|
7660
7183
|
chunkVectorUpsert,
|
|
7661
7184
|
chunkToVector,
|
|
7662
7185
|
chunkRetrieval,
|
|
7663
|
-
buildToolSources,
|
|
7664
7186
|
buildToolDescription,
|
|
7665
7187
|
backgroundRemoval,
|
|
7666
|
-
audioBlockFromDataUri,
|
|
7667
|
-
audioBlock,
|
|
7668
|
-
assistantMessage,
|
|
7669
|
-
agent,
|
|
7670
7188
|
VectorSimilarityTask,
|
|
7671
7189
|
VectorQuantizeTask,
|
|
7672
7190
|
UnloadModelTask,
|
|
@@ -7790,10 +7308,7 @@ export {
|
|
|
7790
7308
|
AiTask,
|
|
7791
7309
|
AiProviderRegistry,
|
|
7792
7310
|
AiProvider,
|
|
7793
|
-
AiJob
|
|
7794
|
-
AgentTask,
|
|
7795
|
-
AgentOutputSchema,
|
|
7796
|
-
AgentInputSchema
|
|
7311
|
+
AiJob
|
|
7797
7312
|
};
|
|
7798
7313
|
|
|
7799
|
-
//# debugId=
|
|
7314
|
+
//# debugId=44C200F7AF4AF24D64756E2164756E21
|