@workglow/ai 0.0.116 → 0.0.118
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 +1145 -393
- package/dist/browser.js.map +13 -9
- package/dist/bun.js +1145 -393
- package/dist/bun.js.map +13 -9
- package/dist/node.js +1145 -393
- package/dist/node.js.map +13 -9
- package/dist/task/AgentTask.d.ts +524 -0
- package/dist/task/AgentTask.d.ts.map +1 -0
- package/dist/task/AgentTypes.d.ts +181 -0
- package/dist/task/AgentTypes.d.ts.map +1 -0
- package/dist/task/AgentUtils.d.ts +50 -0
- package/dist/task/AgentUtils.d.ts.map +1 -0
- package/dist/task/ChunkRetrievalTask.d.ts +2 -2
- package/dist/task/ChunkVectorSearchTask.d.ts +2 -2
- package/dist/task/ChunkVectorUpsertTask.d.ts +1 -1
- package/dist/task/HierarchicalChunkerTask.d.ts +2 -2
- package/dist/task/HierarchyJoinTask.d.ts +1 -1
- package/dist/task/MessageConversion.d.ts +52 -0
- package/dist/task/MessageConversion.d.ts.map +1 -0
- package/dist/task/QueryExpanderTask.d.ts +1 -1
- package/dist/task/RerankerTask.d.ts +1 -1
- package/dist/task/ToolCallingTask.d.ts +152 -25
- package/dist/task/ToolCallingTask.d.ts.map +1 -1
- package/dist/task/VectorSimilarityTask.d.ts +1 -1
- package/dist/task/VectorSimilarityTask.d.ts.map +1 -1
- package/dist/task/index.d.ts +6 -1
- package/dist/task/index.d.ts.map +1 -1
- package/package.json +11 -11
package/dist/bun.js
CHANGED
|
@@ -422,8 +422,83 @@ class AiProvider {
|
|
|
422
422
|
// src/task/index.ts
|
|
423
423
|
import { TaskRegistry } from "@workglow/task-graph";
|
|
424
424
|
|
|
425
|
-
// src/task/
|
|
426
|
-
import {
|
|
425
|
+
// src/task/AgentTask.ts
|
|
426
|
+
import {
|
|
427
|
+
CreateWorkflow as CreateWorkflow2,
|
|
428
|
+
Task,
|
|
429
|
+
Workflow as Workflow2
|
|
430
|
+
} from "@workglow/task-graph";
|
|
431
|
+
import { getLogger as getLogger3 } from "@workglow/util";
|
|
432
|
+
|
|
433
|
+
// src/task/AgentTypes.ts
|
|
434
|
+
import { parseDataUri } from "@workglow/util";
|
|
435
|
+
function imageBlock(mimeType, data) {
|
|
436
|
+
return { type: "image", mimeType, data };
|
|
437
|
+
}
|
|
438
|
+
function audioBlock(mimeType, data) {
|
|
439
|
+
return { type: "audio", mimeType, data };
|
|
440
|
+
}
|
|
441
|
+
function imageBlockFromDataUri(dataUri) {
|
|
442
|
+
const { mimeType, base64 } = parseDataUri(dataUri);
|
|
443
|
+
return { type: "image", mimeType, data: base64 };
|
|
444
|
+
}
|
|
445
|
+
function audioBlockFromDataUri(dataUri) {
|
|
446
|
+
const { mimeType, base64 } = parseDataUri(dataUri);
|
|
447
|
+
return { type: "audio", mimeType, data: base64 };
|
|
448
|
+
}
|
|
449
|
+
function userMessage(prompt) {
|
|
450
|
+
return { role: "user", content: prompt };
|
|
451
|
+
}
|
|
452
|
+
function assistantMessage(text, toolCalls) {
|
|
453
|
+
const content = [];
|
|
454
|
+
if (text) {
|
|
455
|
+
content.push({ type: "text", text });
|
|
456
|
+
}
|
|
457
|
+
if (toolCalls) {
|
|
458
|
+
for (const tc of toolCalls) {
|
|
459
|
+
content.push({
|
|
460
|
+
type: "tool_use",
|
|
461
|
+
id: tc.id,
|
|
462
|
+
name: tc.name,
|
|
463
|
+
input: tc.input
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
return { role: "assistant", content };
|
|
468
|
+
}
|
|
469
|
+
function toolMessage(results) {
|
|
470
|
+
return {
|
|
471
|
+
role: "tool",
|
|
472
|
+
content: results.map((r) => {
|
|
473
|
+
const jsonText = JSON.stringify(r.output);
|
|
474
|
+
const content = r.mediaContent && r.mediaContent.length > 0 ? [{ type: "text", text: jsonText }, ...r.mediaContent] : jsonText;
|
|
475
|
+
return {
|
|
476
|
+
type: "tool_result",
|
|
477
|
+
tool_use_id: r.toolCallId,
|
|
478
|
+
content,
|
|
479
|
+
is_error: r.isError || undefined
|
|
480
|
+
};
|
|
481
|
+
})
|
|
482
|
+
};
|
|
483
|
+
}
|
|
484
|
+
function toolSourceDefinitions(sources) {
|
|
485
|
+
return sources.map((s) => s.definition);
|
|
486
|
+
}
|
|
487
|
+
function findToolSource(sources, name) {
|
|
488
|
+
return sources.find((s) => s.definition.name === name);
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
// src/task/AgentUtils.ts
|
|
492
|
+
import { getTaskConstructors as getTaskConstructors2 } from "@workglow/task-graph";
|
|
493
|
+
import { getLogger as getLogger2 } from "@workglow/util";
|
|
494
|
+
|
|
495
|
+
// src/task/ToolCallingTask.ts
|
|
496
|
+
import {
|
|
497
|
+
CreateWorkflow,
|
|
498
|
+
getTaskConstructors,
|
|
499
|
+
Workflow
|
|
500
|
+
} from "@workglow/task-graph";
|
|
501
|
+
import { getLogger } from "@workglow/util";
|
|
427
502
|
|
|
428
503
|
// src/task/base/AiTaskSchemas.ts
|
|
429
504
|
var TypeLanguage = (annotations = {}) => ({
|
|
@@ -582,8 +657,10 @@ var TypeCategory = {
|
|
|
582
657
|
description: "Classification category with label and score"
|
|
583
658
|
};
|
|
584
659
|
|
|
585
|
-
// src/task/base/
|
|
586
|
-
import {
|
|
660
|
+
// src/task/base/StreamingAiTask.ts
|
|
661
|
+
import {
|
|
662
|
+
getStreamingPorts
|
|
663
|
+
} from "@workglow/task-graph";
|
|
587
664
|
|
|
588
665
|
// src/task/base/AiTask.ts
|
|
589
666
|
import {
|
|
@@ -712,7 +789,667 @@ class AiTask extends JobQueueTask {
|
|
|
712
789
|
}
|
|
713
790
|
}
|
|
714
791
|
|
|
792
|
+
// src/task/base/StreamingAiTask.ts
|
|
793
|
+
class StreamingAiTask extends AiTask {
|
|
794
|
+
static type = "StreamingAiTask";
|
|
795
|
+
async* executeStream(input, context) {
|
|
796
|
+
const jobInput = await this.getJobInput(input);
|
|
797
|
+
const queueName = await this.getDefaultQueueName(input);
|
|
798
|
+
const job = new AiJob({
|
|
799
|
+
queueName: queueName ?? this.type,
|
|
800
|
+
jobRunId: this.runConfig.runnerId,
|
|
801
|
+
input: jobInput
|
|
802
|
+
});
|
|
803
|
+
const ports = getStreamingPorts(this.outputSchema());
|
|
804
|
+
const defaultPort = ports.length > 0 ? ports[0].port : "text";
|
|
805
|
+
for await (const event of job.executeStream(jobInput, {
|
|
806
|
+
signal: context.signal,
|
|
807
|
+
updateProgress: context.updateProgress.bind(this)
|
|
808
|
+
})) {
|
|
809
|
+
if (event.type === "text-delta") {
|
|
810
|
+
yield { ...event, port: event.port ?? defaultPort };
|
|
811
|
+
} else if (event.type === "object-delta") {
|
|
812
|
+
yield { ...event, port: event.port ?? defaultPort };
|
|
813
|
+
} else {
|
|
814
|
+
yield event;
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
// src/task/ToolCallingTask.ts
|
|
821
|
+
function buildToolDescription(tool) {
|
|
822
|
+
let desc = tool.description;
|
|
823
|
+
if (tool.outputSchema && typeof tool.outputSchema === "object") {
|
|
824
|
+
desc += `
|
|
825
|
+
|
|
826
|
+
Returns: ${JSON.stringify(tool.outputSchema)}`;
|
|
827
|
+
}
|
|
828
|
+
return desc;
|
|
829
|
+
}
|
|
830
|
+
function isAllowedToolName(name, allowedTools) {
|
|
831
|
+
return allowedTools.some((t) => t.name === name);
|
|
832
|
+
}
|
|
833
|
+
function filterValidToolCalls(toolCalls, allowedTools) {
|
|
834
|
+
return toolCalls.filter((tc) => {
|
|
835
|
+
if (tc.name && isAllowedToolName(tc.name, allowedTools)) {
|
|
836
|
+
return true;
|
|
837
|
+
}
|
|
838
|
+
getLogger().warn(`Filtered out tool call with unknown name "${tc.name ?? "(missing)"}"`, {
|
|
839
|
+
callId: tc.id,
|
|
840
|
+
toolName: tc.name
|
|
841
|
+
});
|
|
842
|
+
return false;
|
|
843
|
+
});
|
|
844
|
+
}
|
|
845
|
+
function taskTypesToTools(taskNames, registry) {
|
|
846
|
+
const constructors = getTaskConstructors(registry);
|
|
847
|
+
return taskNames.map((name) => {
|
|
848
|
+
const ctor = constructors.get(name);
|
|
849
|
+
if (!ctor) {
|
|
850
|
+
throw new Error(`taskTypesToTools: Unknown task type "${name}" \u2014 not found in task constructors registry (ServiceRegistry: ${registry ? "custom" : "default"})`);
|
|
851
|
+
}
|
|
852
|
+
const configSchema = "configSchema" in ctor && typeof ctor.configSchema === "function" ? ctor.configSchema() : undefined;
|
|
853
|
+
return {
|
|
854
|
+
name: ctor.type,
|
|
855
|
+
description: ctor.description ?? "",
|
|
856
|
+
inputSchema: ctor.inputSchema(),
|
|
857
|
+
outputSchema: ctor.outputSchema(),
|
|
858
|
+
...configSchema ? { configSchema } : {},
|
|
859
|
+
taskType: name
|
|
860
|
+
};
|
|
861
|
+
});
|
|
862
|
+
}
|
|
863
|
+
var ToolDefinitionSchema = {
|
|
864
|
+
type: "object",
|
|
865
|
+
properties: {
|
|
866
|
+
name: {
|
|
867
|
+
type: "string",
|
|
868
|
+
title: "Name",
|
|
869
|
+
description: "The tool name"
|
|
870
|
+
},
|
|
871
|
+
description: {
|
|
872
|
+
type: "string",
|
|
873
|
+
title: "Description",
|
|
874
|
+
description: "A description of what the tool does"
|
|
875
|
+
},
|
|
876
|
+
inputSchema: {
|
|
877
|
+
type: "object",
|
|
878
|
+
title: "Input Schema",
|
|
879
|
+
description: "JSON Schema describing the tool's input parameters",
|
|
880
|
+
additionalProperties: true
|
|
881
|
+
},
|
|
882
|
+
outputSchema: {
|
|
883
|
+
type: "object",
|
|
884
|
+
title: "Output Schema",
|
|
885
|
+
description: "JSON Schema describing what the tool returns",
|
|
886
|
+
additionalProperties: true
|
|
887
|
+
},
|
|
888
|
+
configSchema: {
|
|
889
|
+
type: "object",
|
|
890
|
+
title: "Config Schema",
|
|
891
|
+
description: "JSON Schema describing the task's configuration options (not sent to the LLM)",
|
|
892
|
+
additionalProperties: true
|
|
893
|
+
},
|
|
894
|
+
config: {
|
|
895
|
+
type: "object",
|
|
896
|
+
title: "Config",
|
|
897
|
+
description: "Concrete configuration values for the backing task (not sent to the LLM)",
|
|
898
|
+
additionalProperties: true
|
|
899
|
+
}
|
|
900
|
+
},
|
|
901
|
+
required: ["name", "description", "inputSchema"],
|
|
902
|
+
additionalProperties: true
|
|
903
|
+
};
|
|
904
|
+
var ToolCallSchema = {
|
|
905
|
+
type: "object",
|
|
906
|
+
properties: {
|
|
907
|
+
id: {
|
|
908
|
+
type: "string",
|
|
909
|
+
title: "ID",
|
|
910
|
+
description: "Unique identifier for this tool call"
|
|
911
|
+
},
|
|
912
|
+
name: {
|
|
913
|
+
type: "string",
|
|
914
|
+
title: "Name",
|
|
915
|
+
description: "The name of the tool to invoke"
|
|
916
|
+
},
|
|
917
|
+
input: {
|
|
918
|
+
type: "object",
|
|
919
|
+
title: "Input",
|
|
920
|
+
description: "The input arguments for the tool call",
|
|
921
|
+
additionalProperties: true
|
|
922
|
+
}
|
|
923
|
+
},
|
|
924
|
+
required: ["id", "name", "input"],
|
|
925
|
+
additionalProperties: false
|
|
926
|
+
};
|
|
927
|
+
var modelSchema = TypeModel("model:ToolCallingTask");
|
|
928
|
+
var ToolCallingInputSchema = {
|
|
929
|
+
type: "object",
|
|
930
|
+
properties: {
|
|
931
|
+
model: modelSchema,
|
|
932
|
+
prompt: {
|
|
933
|
+
oneOf: [
|
|
934
|
+
{ type: "string", title: "Prompt", description: "The prompt to send to the model" },
|
|
935
|
+
{
|
|
936
|
+
type: "array",
|
|
937
|
+
title: "Prompt",
|
|
938
|
+
description: "The prompt as an array of strings or content blocks",
|
|
939
|
+
items: {
|
|
940
|
+
oneOf: [
|
|
941
|
+
{ type: "string" },
|
|
942
|
+
{
|
|
943
|
+
type: "object",
|
|
944
|
+
properties: {
|
|
945
|
+
type: { type: "string", enum: ["text", "image", "audio"] }
|
|
946
|
+
},
|
|
947
|
+
required: ["type"],
|
|
948
|
+
additionalProperties: true
|
|
949
|
+
}
|
|
950
|
+
]
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
],
|
|
954
|
+
title: "Prompt",
|
|
955
|
+
description: "The prompt to send to the model"
|
|
956
|
+
},
|
|
957
|
+
systemPrompt: {
|
|
958
|
+
type: "string",
|
|
959
|
+
title: "System Prompt",
|
|
960
|
+
description: "Optional system instructions for the model"
|
|
961
|
+
},
|
|
962
|
+
messages: {
|
|
963
|
+
type: "array",
|
|
964
|
+
title: "Messages",
|
|
965
|
+
description: "Full conversation history for multi-turn interactions. When provided, used instead of prompt to construct the messages array sent to the provider.",
|
|
966
|
+
items: {
|
|
967
|
+
type: "object",
|
|
968
|
+
properties: {
|
|
969
|
+
role: { type: "string", enum: ["user", "assistant", "tool"] },
|
|
970
|
+
content: {}
|
|
971
|
+
},
|
|
972
|
+
required: ["role", "content"],
|
|
973
|
+
additionalProperties: true
|
|
974
|
+
}
|
|
975
|
+
},
|
|
976
|
+
tools: {
|
|
977
|
+
type: "array",
|
|
978
|
+
format: "tasks",
|
|
979
|
+
title: "Tools",
|
|
980
|
+
description: "Tool definitions available for the model to call",
|
|
981
|
+
items: {
|
|
982
|
+
oneOf: [
|
|
983
|
+
{ type: "string", format: "tasks", description: "Task type name" },
|
|
984
|
+
ToolDefinitionSchema
|
|
985
|
+
]
|
|
986
|
+
}
|
|
987
|
+
},
|
|
988
|
+
toolChoice: {
|
|
989
|
+
type: "string",
|
|
990
|
+
title: "Tool Choice",
|
|
991
|
+
description: 'Controls tool selection: "auto" (model decides), "none" (no tools), "required" (must call a tool), or a specific tool name',
|
|
992
|
+
"x-ui-group": "Configuration"
|
|
993
|
+
},
|
|
994
|
+
maxTokens: {
|
|
995
|
+
type: "number",
|
|
996
|
+
title: "Max Tokens",
|
|
997
|
+
description: "The maximum number of tokens to generate",
|
|
998
|
+
minimum: 1,
|
|
999
|
+
"x-ui-group": "Configuration"
|
|
1000
|
+
},
|
|
1001
|
+
temperature: {
|
|
1002
|
+
type: "number",
|
|
1003
|
+
title: "Temperature",
|
|
1004
|
+
description: "The temperature to use for sampling",
|
|
1005
|
+
minimum: 0,
|
|
1006
|
+
maximum: 2,
|
|
1007
|
+
"x-ui-group": "Configuration"
|
|
1008
|
+
}
|
|
1009
|
+
},
|
|
1010
|
+
required: ["model", "prompt", "tools"],
|
|
1011
|
+
additionalProperties: false
|
|
1012
|
+
};
|
|
1013
|
+
var ToolCallingOutputSchema = {
|
|
1014
|
+
type: "object",
|
|
1015
|
+
properties: {
|
|
1016
|
+
text: TypeSingleOrArray({
|
|
1017
|
+
type: "string",
|
|
1018
|
+
title: "Text",
|
|
1019
|
+
description: "Any text content generated by the model",
|
|
1020
|
+
"x-stream": "append"
|
|
1021
|
+
}),
|
|
1022
|
+
toolCalls: TypeSingleOrArray({
|
|
1023
|
+
...ToolCallSchema,
|
|
1024
|
+
"x-stream": "object"
|
|
1025
|
+
})
|
|
1026
|
+
},
|
|
1027
|
+
required: ["text", "toolCalls"],
|
|
1028
|
+
additionalProperties: false
|
|
1029
|
+
};
|
|
1030
|
+
|
|
1031
|
+
class ToolCallingTask extends StreamingAiTask {
|
|
1032
|
+
static type = "ToolCallingTask";
|
|
1033
|
+
static category = "AI Text Model";
|
|
1034
|
+
static title = "Tool Calling";
|
|
1035
|
+
static description = "Sends a prompt with tool definitions to a language model and returns text along with any tool calls the model requests";
|
|
1036
|
+
static inputSchema() {
|
|
1037
|
+
return ToolCallingInputSchema;
|
|
1038
|
+
}
|
|
1039
|
+
static outputSchema() {
|
|
1040
|
+
return ToolCallingOutputSchema;
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
1043
|
+
var toolCalling = (input, config) => {
|
|
1044
|
+
return new ToolCallingTask({}, config).run(input);
|
|
1045
|
+
};
|
|
1046
|
+
Workflow.prototype.toolCalling = CreateWorkflow(ToolCallingTask);
|
|
1047
|
+
|
|
1048
|
+
// src/task/AgentUtils.ts
|
|
1049
|
+
function buildToolSources(tools, registry) {
|
|
1050
|
+
if (!tools || tools.length === 0)
|
|
1051
|
+
return [];
|
|
1052
|
+
const stringNames = tools.filter((t) => typeof t === "string");
|
|
1053
|
+
const resolvedDefs = new Map(taskTypesToTools(stringNames, registry).map((d) => [d.taskType, d]));
|
|
1054
|
+
const constructors = getTaskConstructors2(registry);
|
|
1055
|
+
const sources = [];
|
|
1056
|
+
for (const tool of tools) {
|
|
1057
|
+
if (typeof tool === "string") {
|
|
1058
|
+
const def = resolvedDefs.get(tool);
|
|
1059
|
+
if (def) {
|
|
1060
|
+
const { taskType, ...definition } = def;
|
|
1061
|
+
sources.push({
|
|
1062
|
+
type: "registry",
|
|
1063
|
+
definition,
|
|
1064
|
+
taskType
|
|
1065
|
+
});
|
|
1066
|
+
}
|
|
1067
|
+
} else if (tool.execute) {
|
|
1068
|
+
const { execute, configSchema: _cs, config: _c, ...definition } = tool;
|
|
1069
|
+
sources.push({
|
|
1070
|
+
type: "function",
|
|
1071
|
+
definition,
|
|
1072
|
+
run: execute
|
|
1073
|
+
});
|
|
1074
|
+
} else {
|
|
1075
|
+
const ctor = constructors.get(tool.name);
|
|
1076
|
+
if (ctor) {
|
|
1077
|
+
const { execute: _e, configSchema: _cs, config: _c, ...definition } = tool;
|
|
1078
|
+
sources.push({
|
|
1079
|
+
type: "registry",
|
|
1080
|
+
definition,
|
|
1081
|
+
taskType: tool.name,
|
|
1082
|
+
config: tool.config
|
|
1083
|
+
});
|
|
1084
|
+
} else {
|
|
1085
|
+
const { execute: _e, configSchema: _cs, config: _c, ...definition } = tool;
|
|
1086
|
+
sources.push({
|
|
1087
|
+
type: "function",
|
|
1088
|
+
definition,
|
|
1089
|
+
run: async () => {
|
|
1090
|
+
throw new Error(`No executor registered for tool "${tool.name}"`);
|
|
1091
|
+
}
|
|
1092
|
+
});
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
return sources;
|
|
1097
|
+
}
|
|
1098
|
+
async function executeToolCall(toolCall, sources, context, hooks) {
|
|
1099
|
+
const source = findToolSource(sources, toolCall.name);
|
|
1100
|
+
if (!source) {
|
|
1101
|
+
getLogger2().warn(`AgentTask: Unknown tool "${toolCall.name}" \u2014 not found in tool sources`);
|
|
1102
|
+
return {
|
|
1103
|
+
toolCallId: toolCall.id,
|
|
1104
|
+
toolName: toolCall.name,
|
|
1105
|
+
output: { error: `Unknown tool: ${toolCall.name}` },
|
|
1106
|
+
isError: true
|
|
1107
|
+
};
|
|
1108
|
+
}
|
|
1109
|
+
let effectiveCall = toolCall;
|
|
1110
|
+
if (hooks?.beforeToolCall) {
|
|
1111
|
+
const decision = await hooks.beforeToolCall(toolCall, source);
|
|
1112
|
+
if (decision.action === "deny") {
|
|
1113
|
+
return {
|
|
1114
|
+
toolCallId: toolCall.id,
|
|
1115
|
+
toolName: toolCall.name,
|
|
1116
|
+
output: { error: decision.reason ?? "Tool call denied by hook" },
|
|
1117
|
+
isError: true
|
|
1118
|
+
};
|
|
1119
|
+
}
|
|
1120
|
+
if (decision.action === "modify") {
|
|
1121
|
+
effectiveCall = { ...toolCall, input: decision.input };
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
try {
|
|
1125
|
+
let output;
|
|
1126
|
+
switch (source.type) {
|
|
1127
|
+
case "registry": {
|
|
1128
|
+
const ctor = getTaskConstructors2(context.registry).get(source.taskType);
|
|
1129
|
+
if (!ctor) {
|
|
1130
|
+
throw new Error(`Task type "${source.taskType}" not found in TaskRegistry`);
|
|
1131
|
+
}
|
|
1132
|
+
const taskConfig = source.config ?? {};
|
|
1133
|
+
const task = context.own(new ctor({}, taskConfig));
|
|
1134
|
+
output = await task.run(effectiveCall.input) ?? {};
|
|
1135
|
+
break;
|
|
1136
|
+
}
|
|
1137
|
+
case "function": {
|
|
1138
|
+
output = await source.run(effectiveCall.input);
|
|
1139
|
+
break;
|
|
1140
|
+
}
|
|
1141
|
+
}
|
|
1142
|
+
let result = {
|
|
1143
|
+
toolCallId: toolCall.id,
|
|
1144
|
+
toolName: toolCall.name,
|
|
1145
|
+
output,
|
|
1146
|
+
isError: false
|
|
1147
|
+
};
|
|
1148
|
+
if (hooks?.afterToolCall) {
|
|
1149
|
+
result = await hooks.afterToolCall(toolCall, result);
|
|
1150
|
+
}
|
|
1151
|
+
return result;
|
|
1152
|
+
} catch (err) {
|
|
1153
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
1154
|
+
if (hooks?.onToolError) {
|
|
1155
|
+
const action = await hooks.onToolError(toolCall, error);
|
|
1156
|
+
if (action.action === "result") {
|
|
1157
|
+
return {
|
|
1158
|
+
toolCallId: toolCall.id,
|
|
1159
|
+
toolName: toolCall.name,
|
|
1160
|
+
output: action.output,
|
|
1161
|
+
isError: false
|
|
1162
|
+
};
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
getLogger2().warn(`AgentTask: Tool "${toolCall.name}" failed: ${error.message}`);
|
|
1166
|
+
return {
|
|
1167
|
+
toolCallId: toolCall.id,
|
|
1168
|
+
toolName: toolCall.name,
|
|
1169
|
+
output: { error: error.message },
|
|
1170
|
+
isError: true
|
|
1171
|
+
};
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
async function executeToolCalls(toolCalls, sources, context, hooks, maxConcurrency = 5) {
|
|
1175
|
+
const calls = toolCalls;
|
|
1176
|
+
if (calls.length === 0)
|
|
1177
|
+
return [];
|
|
1178
|
+
const concurrency = Math.max(1, Math.min(maxConcurrency, calls.length));
|
|
1179
|
+
const results = new Array(calls.length);
|
|
1180
|
+
let cursor = 0;
|
|
1181
|
+
const workers = Array.from({ length: concurrency }, async () => {
|
|
1182
|
+
while (true) {
|
|
1183
|
+
if (context.signal.aborted) {
|
|
1184
|
+
throw context.signal.reason ?? new DOMException("The operation was aborted", "AbortError");
|
|
1185
|
+
}
|
|
1186
|
+
const position = cursor;
|
|
1187
|
+
cursor += 1;
|
|
1188
|
+
if (position >= calls.length)
|
|
1189
|
+
return;
|
|
1190
|
+
results[position] = await executeToolCall(calls[position], sources, context, hooks);
|
|
1191
|
+
}
|
|
1192
|
+
});
|
|
1193
|
+
await Promise.all(workers);
|
|
1194
|
+
return results;
|
|
1195
|
+
}
|
|
1196
|
+
function hasToolCalls(toolCalls) {
|
|
1197
|
+
return toolCalls !== undefined && toolCalls.length > 0;
|
|
1198
|
+
}
|
|
1199
|
+
|
|
1200
|
+
// src/task/AgentTask.ts
|
|
1201
|
+
var modelSchema2 = TypeModel("model:ToolCallingTask");
|
|
1202
|
+
var AgentInputSchema = {
|
|
1203
|
+
type: "object",
|
|
1204
|
+
properties: {
|
|
1205
|
+
model: modelSchema2,
|
|
1206
|
+
prompt: {
|
|
1207
|
+
oneOf: [
|
|
1208
|
+
{ type: "string" },
|
|
1209
|
+
{
|
|
1210
|
+
type: "array",
|
|
1211
|
+
items: {
|
|
1212
|
+
type: "object",
|
|
1213
|
+
properties: {
|
|
1214
|
+
type: { type: "string", enum: ["text", "image", "audio"] }
|
|
1215
|
+
},
|
|
1216
|
+
required: ["type"],
|
|
1217
|
+
additionalProperties: true
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1220
|
+
],
|
|
1221
|
+
title: "Prompt",
|
|
1222
|
+
description: "The user prompt to start the agent loop. Can be a string or an array of content blocks (text, image, audio)."
|
|
1223
|
+
},
|
|
1224
|
+
systemPrompt: {
|
|
1225
|
+
type: "string",
|
|
1226
|
+
title: "System Prompt",
|
|
1227
|
+
description: "Optional system instructions for the agent"
|
|
1228
|
+
},
|
|
1229
|
+
tools: {
|
|
1230
|
+
type: "array",
|
|
1231
|
+
format: "tasks",
|
|
1232
|
+
title: "Tools",
|
|
1233
|
+
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.",
|
|
1234
|
+
items: {
|
|
1235
|
+
oneOf: [
|
|
1236
|
+
{ type: "string", format: "tasks", description: "Task type name" },
|
|
1237
|
+
ToolDefinitionSchema
|
|
1238
|
+
]
|
|
1239
|
+
}
|
|
1240
|
+
},
|
|
1241
|
+
stopTool: {
|
|
1242
|
+
type: "string",
|
|
1243
|
+
title: "Stop Tool",
|
|
1244
|
+
description: "Name of a tool that signals agent completion. When called, the loop ends and the tool input becomes structuredOutput.",
|
|
1245
|
+
"x-ui-group": "Configuration"
|
|
1246
|
+
},
|
|
1247
|
+
maxIterations: {
|
|
1248
|
+
type: "number",
|
|
1249
|
+
title: "Max Iterations",
|
|
1250
|
+
description: "Maximum number of agent loop iterations (default: 10)",
|
|
1251
|
+
minimum: 1,
|
|
1252
|
+
"x-ui-group": "Configuration"
|
|
1253
|
+
},
|
|
1254
|
+
maxContextMessages: {
|
|
1255
|
+
type: "number",
|
|
1256
|
+
title: "Max Context Messages",
|
|
1257
|
+
description: "Maximum messages in conversation history. Older messages are trimmed to prevent context overflow.",
|
|
1258
|
+
minimum: 3,
|
|
1259
|
+
"x-ui-group": "Configuration"
|
|
1260
|
+
},
|
|
1261
|
+
maxTokens: {
|
|
1262
|
+
type: "number",
|
|
1263
|
+
title: "Max Tokens",
|
|
1264
|
+
description: "Maximum tokens per LLM call",
|
|
1265
|
+
minimum: 1,
|
|
1266
|
+
"x-ui-group": "Configuration"
|
|
1267
|
+
},
|
|
1268
|
+
temperature: {
|
|
1269
|
+
type: "number",
|
|
1270
|
+
title: "Temperature",
|
|
1271
|
+
description: "Sampling temperature for LLM calls",
|
|
1272
|
+
minimum: 0,
|
|
1273
|
+
maximum: 2,
|
|
1274
|
+
"x-ui-group": "Configuration"
|
|
1275
|
+
}
|
|
1276
|
+
},
|
|
1277
|
+
required: ["model", "prompt"],
|
|
1278
|
+
additionalProperties: false
|
|
1279
|
+
};
|
|
1280
|
+
var AgentOutputSchema = {
|
|
1281
|
+
type: "object",
|
|
1282
|
+
properties: {
|
|
1283
|
+
text: {
|
|
1284
|
+
type: "string",
|
|
1285
|
+
title: "Text",
|
|
1286
|
+
description: "The final text response from the agent",
|
|
1287
|
+
"x-stream": "append"
|
|
1288
|
+
},
|
|
1289
|
+
messages: {
|
|
1290
|
+
type: "array",
|
|
1291
|
+
title: "Messages",
|
|
1292
|
+
description: "Full conversation history including all tool calls and results",
|
|
1293
|
+
items: {
|
|
1294
|
+
type: "object",
|
|
1295
|
+
additionalProperties: true
|
|
1296
|
+
}
|
|
1297
|
+
},
|
|
1298
|
+
iterations: {
|
|
1299
|
+
type: "number",
|
|
1300
|
+
title: "Iterations",
|
|
1301
|
+
description: "Number of LLM calls made during the agent loop"
|
|
1302
|
+
},
|
|
1303
|
+
toolCallCount: {
|
|
1304
|
+
type: "number",
|
|
1305
|
+
title: "Tool Call Count",
|
|
1306
|
+
description: "Total number of tool calls executed"
|
|
1307
|
+
},
|
|
1308
|
+
structuredOutput: {
|
|
1309
|
+
type: "object",
|
|
1310
|
+
title: "Structured Output",
|
|
1311
|
+
description: "Present when the agent terminated via a stop tool",
|
|
1312
|
+
additionalProperties: true
|
|
1313
|
+
}
|
|
1314
|
+
},
|
|
1315
|
+
required: ["text", "messages", "iterations", "toolCallCount"],
|
|
1316
|
+
additionalProperties: false
|
|
1317
|
+
};
|
|
1318
|
+
|
|
1319
|
+
class AgentTask extends Task {
|
|
1320
|
+
static type = "AgentTask";
|
|
1321
|
+
static category = "AI Agent";
|
|
1322
|
+
static title = "Agent";
|
|
1323
|
+
static description = "Multi-turn agentic loop that calls an LLM with tools, executes tool calls, and iterates until done";
|
|
1324
|
+
static cacheable = false;
|
|
1325
|
+
static inputSchema() {
|
|
1326
|
+
return AgentInputSchema;
|
|
1327
|
+
}
|
|
1328
|
+
static outputSchema() {
|
|
1329
|
+
return AgentOutputSchema;
|
|
1330
|
+
}
|
|
1331
|
+
async execute(input, context) {
|
|
1332
|
+
let result;
|
|
1333
|
+
for await (const event of this.agentLoop(input, context)) {
|
|
1334
|
+
if (event.type === "finish") {
|
|
1335
|
+
result = event.data;
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1338
|
+
if (!result) {
|
|
1339
|
+
throw new Error("AgentTask: loop ended without producing output");
|
|
1340
|
+
}
|
|
1341
|
+
return result;
|
|
1342
|
+
}
|
|
1343
|
+
async* executeStream(input, context) {
|
|
1344
|
+
yield* this.agentLoop(input, context);
|
|
1345
|
+
}
|
|
1346
|
+
async* agentLoop(input, context) {
|
|
1347
|
+
const maxIterations = input.maxIterations ?? 10;
|
|
1348
|
+
const hooks = this.config.hooks;
|
|
1349
|
+
const maxConcurrency = this.config.maxConcurrency ?? 5;
|
|
1350
|
+
const toolSources = this.resolveToolSources(input, context);
|
|
1351
|
+
const toolDefs = this.resolveToolDefs(toolSources, input.stopTool);
|
|
1352
|
+
const messages = [userMessage(input.prompt)];
|
|
1353
|
+
let totalToolCalls = 0;
|
|
1354
|
+
let finalText = "";
|
|
1355
|
+
let structuredOutput;
|
|
1356
|
+
for (let iteration = 0;iteration < maxIterations; iteration++) {
|
|
1357
|
+
if (context.signal.aborted)
|
|
1358
|
+
break;
|
|
1359
|
+
if (hooks?.onIteration) {
|
|
1360
|
+
const action = await hooks.onIteration(iteration, messages, { totalToolCalls });
|
|
1361
|
+
if (action.action === "stop")
|
|
1362
|
+
break;
|
|
1363
|
+
}
|
|
1364
|
+
await context.updateProgress(Math.round(iteration / maxIterations * 100), `Agent iteration ${iteration + 1}`);
|
|
1365
|
+
const contextMessages = this.trimMessages(messages, input.maxContextMessages);
|
|
1366
|
+
const llmTask = context.own(new ToolCallingTask({}, {}));
|
|
1367
|
+
let iterationText = "";
|
|
1368
|
+
let toolCalls = [];
|
|
1369
|
+
for await (const event of llmTask.executeStream({
|
|
1370
|
+
model: input.model,
|
|
1371
|
+
prompt: input.prompt,
|
|
1372
|
+
systemPrompt: input.systemPrompt,
|
|
1373
|
+
tools: toolDefs,
|
|
1374
|
+
messages: contextMessages,
|
|
1375
|
+
maxTokens: input.maxTokens,
|
|
1376
|
+
temperature: input.temperature
|
|
1377
|
+
}, context)) {
|
|
1378
|
+
if (event.type === "text-delta") {
|
|
1379
|
+
yield { type: "text-delta", port: "text", textDelta: event.textDelta };
|
|
1380
|
+
iterationText += event.textDelta;
|
|
1381
|
+
} else if (event.type === "finish") {
|
|
1382
|
+
const data = event.data;
|
|
1383
|
+
iterationText = data?.text ?? iterationText;
|
|
1384
|
+
if (data?.toolCalls) {
|
|
1385
|
+
toolCalls = data.toolCalls ?? [];
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
1388
|
+
}
|
|
1389
|
+
finalText = iterationText;
|
|
1390
|
+
messages.push(assistantMessage(iterationText, toolCalls));
|
|
1391
|
+
if (input.stopTool) {
|
|
1392
|
+
const stopCall = toolCalls.find((tc) => tc.name === input.stopTool);
|
|
1393
|
+
if (stopCall) {
|
|
1394
|
+
structuredOutput = stopCall.input;
|
|
1395
|
+
break;
|
|
1396
|
+
}
|
|
1397
|
+
}
|
|
1398
|
+
if (!hasToolCalls(toolCalls)) {
|
|
1399
|
+
break;
|
|
1400
|
+
}
|
|
1401
|
+
const results = await executeToolCalls(toolCalls, toolSources, context, hooks, maxConcurrency);
|
|
1402
|
+
totalToolCalls += results.length;
|
|
1403
|
+
messages.push(toolMessage(results));
|
|
1404
|
+
}
|
|
1405
|
+
const output = {
|
|
1406
|
+
text: finalText,
|
|
1407
|
+
messages,
|
|
1408
|
+
iterations: messages.filter((m) => m.role === "assistant").length,
|
|
1409
|
+
toolCallCount: totalToolCalls,
|
|
1410
|
+
...structuredOutput !== undefined ? { structuredOutput } : {}
|
|
1411
|
+
};
|
|
1412
|
+
yield { type: "finish", data: output };
|
|
1413
|
+
}
|
|
1414
|
+
resolveToolSources(input, context) {
|
|
1415
|
+
return buildToolSources(input.tools, context.registry);
|
|
1416
|
+
}
|
|
1417
|
+
resolveToolDefs(toolSources, stopTool) {
|
|
1418
|
+
const defs = toolSourceDefinitions(toolSources);
|
|
1419
|
+
if (stopTool && !defs.some((d) => d.name === stopTool)) {
|
|
1420
|
+
defs.push({
|
|
1421
|
+
name: stopTool,
|
|
1422
|
+
description: "Call this tool when you have completed the task. Pass your final structured result as the input.",
|
|
1423
|
+
inputSchema: { type: "object", additionalProperties: true }
|
|
1424
|
+
});
|
|
1425
|
+
}
|
|
1426
|
+
return defs;
|
|
1427
|
+
}
|
|
1428
|
+
trimMessages(messages, maxContextMessages) {
|
|
1429
|
+
if (!maxContextMessages || messages.length <= maxContextMessages) {
|
|
1430
|
+
return messages;
|
|
1431
|
+
}
|
|
1432
|
+
getLogger3().debug(`AgentTask: Trimming context from ${messages.length} to ${maxContextMessages} messages`);
|
|
1433
|
+
const tail = messages.slice(1);
|
|
1434
|
+
let startIdx = tail.length - (maxContextMessages - 1);
|
|
1435
|
+
if (startIdx < 0)
|
|
1436
|
+
startIdx = 0;
|
|
1437
|
+
if (startIdx > 0 && startIdx < tail.length && tail[startIdx].role === "tool") {
|
|
1438
|
+
startIdx -= 1;
|
|
1439
|
+
}
|
|
1440
|
+
return [messages[0], ...tail.slice(startIdx)];
|
|
1441
|
+
}
|
|
1442
|
+
}
|
|
1443
|
+
var agent = (input, config) => {
|
|
1444
|
+
return new AgentTask({}, config).run(input);
|
|
1445
|
+
};
|
|
1446
|
+
Workflow2.prototype.agent = CreateWorkflow2(AgentTask);
|
|
1447
|
+
|
|
1448
|
+
// src/task/BackgroundRemovalTask.ts
|
|
1449
|
+
import { CreateWorkflow as CreateWorkflow3, Workflow as Workflow3 } from "@workglow/task-graph";
|
|
1450
|
+
|
|
715
1451
|
// src/task/base/AiVisionTask.ts
|
|
1452
|
+
import { convertImageDataToUseableForm } from "@workglow/util";
|
|
716
1453
|
class AiVisionTask extends AiTask {
|
|
717
1454
|
static type = "AiVisionTask";
|
|
718
1455
|
async getJobInput(input) {
|
|
@@ -734,7 +1471,7 @@ class AiVisionTask extends AiTask {
|
|
|
734
1471
|
}
|
|
735
1472
|
|
|
736
1473
|
// src/task/BackgroundRemovalTask.ts
|
|
737
|
-
var
|
|
1474
|
+
var modelSchema3 = TypeModel("model:BackgroundRemovalTask");
|
|
738
1475
|
var processedImageSchema = {
|
|
739
1476
|
type: "string",
|
|
740
1477
|
contentEncoding: "base64",
|
|
@@ -746,7 +1483,7 @@ var BackgroundRemovalInputSchema = {
|
|
|
746
1483
|
type: "object",
|
|
747
1484
|
properties: {
|
|
748
1485
|
image: TypeImageInput,
|
|
749
|
-
model:
|
|
1486
|
+
model: modelSchema3
|
|
750
1487
|
},
|
|
751
1488
|
required: ["image", "model"],
|
|
752
1489
|
additionalProperties: false
|
|
@@ -775,14 +1512,14 @@ class BackgroundRemovalTask extends AiVisionTask {
|
|
|
775
1512
|
var backgroundRemoval = (input, config) => {
|
|
776
1513
|
return new BackgroundRemovalTask({}, config).run(input);
|
|
777
1514
|
};
|
|
778
|
-
|
|
1515
|
+
Workflow3.prototype.backgroundRemoval = CreateWorkflow3(BackgroundRemovalTask);
|
|
779
1516
|
|
|
780
1517
|
// src/task/ChunkRetrievalTask.ts
|
|
781
1518
|
import { TypeKnowledgeBase } from "@workglow/knowledge-base";
|
|
782
1519
|
import {
|
|
783
|
-
CreateWorkflow as
|
|
784
|
-
Task,
|
|
785
|
-
Workflow as
|
|
1520
|
+
CreateWorkflow as CreateWorkflow5,
|
|
1521
|
+
Task as Task2,
|
|
1522
|
+
Workflow as Workflow5
|
|
786
1523
|
} from "@workglow/task-graph";
|
|
787
1524
|
import {
|
|
788
1525
|
isTypedArray,
|
|
@@ -790,11 +1527,11 @@ import {
|
|
|
790
1527
|
} from "@workglow/util";
|
|
791
1528
|
|
|
792
1529
|
// src/task/TextEmbeddingTask.ts
|
|
793
|
-
import { CreateWorkflow as
|
|
1530
|
+
import { CreateWorkflow as CreateWorkflow4, Workflow as Workflow4 } from "@workglow/task-graph";
|
|
794
1531
|
import {
|
|
795
1532
|
TypedArraySchema
|
|
796
1533
|
} from "@workglow/util";
|
|
797
|
-
var
|
|
1534
|
+
var modelSchema4 = TypeModel("model:TextEmbeddingTask");
|
|
798
1535
|
var TextEmbeddingInputSchema = {
|
|
799
1536
|
type: "object",
|
|
800
1537
|
properties: {
|
|
@@ -803,7 +1540,7 @@ var TextEmbeddingInputSchema = {
|
|
|
803
1540
|
title: "Text",
|
|
804
1541
|
description: "The text to embed"
|
|
805
1542
|
}),
|
|
806
|
-
model:
|
|
1543
|
+
model: modelSchema4
|
|
807
1544
|
},
|
|
808
1545
|
required: ["text", "model"],
|
|
809
1546
|
additionalProperties: false
|
|
@@ -835,7 +1572,7 @@ class TextEmbeddingTask extends AiTask {
|
|
|
835
1572
|
var textEmbedding = async (input, config) => {
|
|
836
1573
|
return new TextEmbeddingTask({}, config).run(input);
|
|
837
1574
|
};
|
|
838
|
-
|
|
1575
|
+
Workflow4.prototype.textEmbedding = CreateWorkflow4(TextEmbeddingTask);
|
|
839
1576
|
|
|
840
1577
|
// src/task/ChunkRetrievalTask.ts
|
|
841
1578
|
var inputSchema = {
|
|
@@ -960,7 +1697,7 @@ var outputSchema = {
|
|
|
960
1697
|
additionalProperties: false
|
|
961
1698
|
};
|
|
962
1699
|
|
|
963
|
-
class ChunkRetrievalTask extends
|
|
1700
|
+
class ChunkRetrievalTask extends Task2 {
|
|
964
1701
|
static type = "ChunkRetrievalTask";
|
|
965
1702
|
static category = "RAG";
|
|
966
1703
|
static title = "Chunk Retrieval";
|
|
@@ -1027,14 +1764,14 @@ class ChunkRetrievalTask extends Task {
|
|
|
1027
1764
|
var chunkRetrieval = (input, config) => {
|
|
1028
1765
|
return new ChunkRetrievalTask({}, config).run(input);
|
|
1029
1766
|
};
|
|
1030
|
-
|
|
1767
|
+
Workflow5.prototype.chunkRetrieval = CreateWorkflow5(ChunkRetrievalTask);
|
|
1031
1768
|
|
|
1032
1769
|
// src/task/ChunkToVectorTask.ts
|
|
1033
1770
|
import { ChunkRecordSchema } from "@workglow/knowledge-base";
|
|
1034
1771
|
import {
|
|
1035
|
-
CreateWorkflow as
|
|
1036
|
-
Task as
|
|
1037
|
-
Workflow as
|
|
1772
|
+
CreateWorkflow as CreateWorkflow6,
|
|
1773
|
+
Task as Task3,
|
|
1774
|
+
Workflow as Workflow6
|
|
1038
1775
|
} from "@workglow/task-graph";
|
|
1039
1776
|
import {
|
|
1040
1777
|
TypedArraySchema as TypedArraySchema3
|
|
@@ -1110,7 +1847,7 @@ var outputSchema2 = {
|
|
|
1110
1847
|
additionalProperties: false
|
|
1111
1848
|
};
|
|
1112
1849
|
|
|
1113
|
-
class ChunkToVectorTask extends
|
|
1850
|
+
class ChunkToVectorTask extends Task3 {
|
|
1114
1851
|
static type = "ChunkToVectorTask";
|
|
1115
1852
|
static category = "Document";
|
|
1116
1853
|
static title = "Chunk to Vector";
|
|
@@ -1161,14 +1898,14 @@ class ChunkToVectorTask extends Task2 {
|
|
|
1161
1898
|
var chunkToVector = (input, config) => {
|
|
1162
1899
|
return new ChunkToVectorTask({}, config).run(input);
|
|
1163
1900
|
};
|
|
1164
|
-
|
|
1901
|
+
Workflow6.prototype.chunkToVector = CreateWorkflow6(ChunkToVectorTask);
|
|
1165
1902
|
|
|
1166
1903
|
// src/task/ChunkVectorHybridSearchTask.ts
|
|
1167
1904
|
import { TypeKnowledgeBase as TypeKnowledgeBase2 } from "@workglow/knowledge-base";
|
|
1168
1905
|
import {
|
|
1169
|
-
CreateWorkflow as
|
|
1170
|
-
Task as
|
|
1171
|
-
Workflow as
|
|
1906
|
+
CreateWorkflow as CreateWorkflow7,
|
|
1907
|
+
Task as Task4,
|
|
1908
|
+
Workflow as Workflow7
|
|
1172
1909
|
} from "@workglow/task-graph";
|
|
1173
1910
|
import {
|
|
1174
1911
|
TypedArraySchema as TypedArraySchema4
|
|
@@ -1282,7 +2019,7 @@ var outputSchema3 = {
|
|
|
1282
2019
|
additionalProperties: false
|
|
1283
2020
|
};
|
|
1284
2021
|
|
|
1285
|
-
class ChunkVectorHybridSearchTask extends
|
|
2022
|
+
class ChunkVectorHybridSearchTask extends Task4 {
|
|
1286
2023
|
static type = "ChunkVectorHybridSearchTask";
|
|
1287
2024
|
static category = "RAG";
|
|
1288
2025
|
static title = "Hybrid Search";
|
|
@@ -1335,14 +2072,14 @@ class ChunkVectorHybridSearchTask extends Task3 {
|
|
|
1335
2072
|
var hybridSearch = async (input, config) => {
|
|
1336
2073
|
return new ChunkVectorHybridSearchTask({}, config).run(input);
|
|
1337
2074
|
};
|
|
1338
|
-
|
|
2075
|
+
Workflow7.prototype.hybridSearch = CreateWorkflow7(ChunkVectorHybridSearchTask);
|
|
1339
2076
|
|
|
1340
2077
|
// src/task/ChunkVectorSearchTask.ts
|
|
1341
2078
|
import { TypeKnowledgeBase as TypeKnowledgeBase3 } from "@workglow/knowledge-base";
|
|
1342
2079
|
import {
|
|
1343
|
-
CreateWorkflow as
|
|
1344
|
-
Task as
|
|
1345
|
-
Workflow as
|
|
2080
|
+
CreateWorkflow as CreateWorkflow8,
|
|
2081
|
+
Task as Task5,
|
|
2082
|
+
Workflow as Workflow8
|
|
1346
2083
|
} from "@workglow/task-graph";
|
|
1347
2084
|
import {
|
|
1348
2085
|
TypedArraySchema as TypedArraySchema5
|
|
@@ -1426,7 +2163,7 @@ var outputSchema4 = {
|
|
|
1426
2163
|
additionalProperties: false
|
|
1427
2164
|
};
|
|
1428
2165
|
|
|
1429
|
-
class ChunkVectorSearchTask extends
|
|
2166
|
+
class ChunkVectorSearchTask extends Task5 {
|
|
1430
2167
|
static type = "ChunkVectorSearchTask";
|
|
1431
2168
|
static category = "Vector Store";
|
|
1432
2169
|
static title = "Vector Store Search";
|
|
@@ -1458,14 +2195,14 @@ class ChunkVectorSearchTask extends Task4 {
|
|
|
1458
2195
|
var vectorStoreSearch = (input, config) => {
|
|
1459
2196
|
return new ChunkVectorSearchTask({}, config).run(input);
|
|
1460
2197
|
};
|
|
1461
|
-
|
|
2198
|
+
Workflow8.prototype.vectorStoreSearch = CreateWorkflow8(ChunkVectorSearchTask);
|
|
1462
2199
|
|
|
1463
2200
|
// src/task/ChunkVectorUpsertTask.ts
|
|
1464
2201
|
import { TypeKnowledgeBase as TypeKnowledgeBase4 } from "@workglow/knowledge-base";
|
|
1465
2202
|
import {
|
|
1466
|
-
CreateWorkflow as
|
|
1467
|
-
Task as
|
|
1468
|
-
Workflow as
|
|
2203
|
+
CreateWorkflow as CreateWorkflow9,
|
|
2204
|
+
Task as Task6,
|
|
2205
|
+
Workflow as Workflow9
|
|
1469
2206
|
} from "@workglow/task-graph";
|
|
1470
2207
|
import {
|
|
1471
2208
|
TypedArraySchema as TypedArraySchema6
|
|
@@ -1520,7 +2257,7 @@ var outputSchema5 = {
|
|
|
1520
2257
|
additionalProperties: false
|
|
1521
2258
|
};
|
|
1522
2259
|
|
|
1523
|
-
class ChunkVectorUpsertTask extends
|
|
2260
|
+
class ChunkVectorUpsertTask extends Task6 {
|
|
1524
2261
|
static type = "ChunkVectorUpsertTask";
|
|
1525
2262
|
static category = "Vector Store";
|
|
1526
2263
|
static title = "Add to Vector Store";
|
|
@@ -1580,19 +2317,19 @@ class ChunkVectorUpsertTask extends Task5 {
|
|
|
1580
2317
|
var chunkVectorUpsert = (input, config) => {
|
|
1581
2318
|
return new ChunkVectorUpsertTask({}, config).run(input);
|
|
1582
2319
|
};
|
|
1583
|
-
|
|
2320
|
+
Workflow9.prototype.chunkVectorUpsert = CreateWorkflow9(ChunkVectorUpsertTask);
|
|
1584
2321
|
|
|
1585
2322
|
// src/task/ContextBuilderTask.ts
|
|
1586
2323
|
import { estimateTokens } from "@workglow/knowledge-base";
|
|
1587
2324
|
import {
|
|
1588
|
-
CreateWorkflow as
|
|
1589
|
-
Task as
|
|
1590
|
-
Workflow as
|
|
2325
|
+
CreateWorkflow as CreateWorkflow11,
|
|
2326
|
+
Task as Task7,
|
|
2327
|
+
Workflow as Workflow11
|
|
1591
2328
|
} from "@workglow/task-graph";
|
|
1592
2329
|
|
|
1593
2330
|
// src/task/CountTokensTask.ts
|
|
1594
|
-
import { CreateWorkflow as
|
|
1595
|
-
var
|
|
2331
|
+
import { CreateWorkflow as CreateWorkflow10, Workflow as Workflow10 } from "@workglow/task-graph";
|
|
2332
|
+
var modelSchema5 = TypeModel("model");
|
|
1596
2333
|
var CountTokensInputSchema = {
|
|
1597
2334
|
type: "object",
|
|
1598
2335
|
properties: {
|
|
@@ -1601,7 +2338,7 @@ var CountTokensInputSchema = {
|
|
|
1601
2338
|
title: "Text",
|
|
1602
2339
|
description: "The text to count tokens for"
|
|
1603
2340
|
}),
|
|
1604
|
-
model:
|
|
2341
|
+
model: modelSchema5
|
|
1605
2342
|
},
|
|
1606
2343
|
required: ["text", "model"],
|
|
1607
2344
|
additionalProperties: false
|
|
@@ -1635,7 +2372,7 @@ class CountTokensTask extends AiTask {
|
|
|
1635
2372
|
var countTokens = async (input, config) => {
|
|
1636
2373
|
return new CountTokensTask({}, config).run(input);
|
|
1637
2374
|
};
|
|
1638
|
-
|
|
2375
|
+
Workflow10.prototype.countTokens = CreateWorkflow10(CountTokensTask);
|
|
1639
2376
|
|
|
1640
2377
|
// src/task/ContextBuilderTask.ts
|
|
1641
2378
|
var ContextFormat = {
|
|
@@ -1645,7 +2382,7 @@ var ContextFormat = {
|
|
|
1645
2382
|
MARKDOWN: "markdown",
|
|
1646
2383
|
JSON: "json"
|
|
1647
2384
|
};
|
|
1648
|
-
var
|
|
2385
|
+
var modelSchema6 = TypeModel("model", {
|
|
1649
2386
|
title: "Model",
|
|
1650
2387
|
description: "Model to use for token counting (optional, falls back to estimation)"
|
|
1651
2388
|
});
|
|
@@ -1709,7 +2446,7 @@ var inputSchema6 = {
|
|
|
1709
2446
|
|
|
1710
2447
|
`
|
|
1711
2448
|
},
|
|
1712
|
-
model:
|
|
2449
|
+
model: modelSchema6
|
|
1713
2450
|
},
|
|
1714
2451
|
required: ["chunks"],
|
|
1715
2452
|
additionalProperties: false
|
|
@@ -1742,7 +2479,7 @@ var outputSchema6 = {
|
|
|
1742
2479
|
additionalProperties: false
|
|
1743
2480
|
};
|
|
1744
2481
|
|
|
1745
|
-
class ContextBuilderTask extends
|
|
2482
|
+
class ContextBuilderTask extends Task7 {
|
|
1746
2483
|
static type = "ContextBuilderTask";
|
|
1747
2484
|
static category = "RAG";
|
|
1748
2485
|
static title = "Context Builder";
|
|
@@ -1935,7 +2672,7 @@ class ContextBuilderTask extends Task6 {
|
|
|
1935
2672
|
var contextBuilder = (input, config) => {
|
|
1936
2673
|
return new ContextBuilderTask({}, config).run(input);
|
|
1937
2674
|
};
|
|
1938
|
-
|
|
2675
|
+
Workflow11.prototype.contextBuilder = CreateWorkflow11(ContextBuilderTask);
|
|
1939
2676
|
|
|
1940
2677
|
// src/task/DocumentEnricherTask.ts
|
|
1941
2678
|
import {
|
|
@@ -1943,14 +2680,14 @@ import {
|
|
|
1943
2680
|
hasChildren
|
|
1944
2681
|
} from "@workglow/knowledge-base";
|
|
1945
2682
|
import {
|
|
1946
|
-
CreateWorkflow as
|
|
1947
|
-
Task as
|
|
1948
|
-
Workflow as
|
|
2683
|
+
CreateWorkflow as CreateWorkflow14,
|
|
2684
|
+
Task as Task8,
|
|
2685
|
+
Workflow as Workflow14
|
|
1949
2686
|
} from "@workglow/task-graph";
|
|
1950
2687
|
|
|
1951
2688
|
// src/task/TextNamedEntityRecognitionTask.ts
|
|
1952
|
-
import { CreateWorkflow as
|
|
1953
|
-
var
|
|
2689
|
+
import { CreateWorkflow as CreateWorkflow12, Workflow as Workflow12 } from "@workglow/task-graph";
|
|
2690
|
+
var modelSchema7 = TypeModel("model:TextNamedEntityRecognitionTask");
|
|
1954
2691
|
var TextNamedEntityRecognitionInputSchema = {
|
|
1955
2692
|
type: "object",
|
|
1956
2693
|
properties: {
|
|
@@ -1969,7 +2706,7 @@ var TextNamedEntityRecognitionInputSchema = {
|
|
|
1969
2706
|
"x-ui-group": "Configuration",
|
|
1970
2707
|
"x-ui-group-open": false
|
|
1971
2708
|
},
|
|
1972
|
-
model:
|
|
2709
|
+
model: modelSchema7
|
|
1973
2710
|
},
|
|
1974
2711
|
required: ["text", "model"],
|
|
1975
2712
|
additionalProperties: false
|
|
@@ -2024,44 +2761,11 @@ class TextNamedEntityRecognitionTask extends AiTask {
|
|
|
2024
2761
|
var textNamedEntityRecognition = (input, config) => {
|
|
2025
2762
|
return new TextNamedEntityRecognitionTask({}, config).run(input);
|
|
2026
2763
|
};
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
// src/task/TextSummaryTask.ts
|
|
2030
|
-
import { CreateWorkflow as CreateWorkflow11, Workflow as Workflow11 } from "@workglow/task-graph";
|
|
2031
|
-
|
|
2032
|
-
// src/task/base/StreamingAiTask.ts
|
|
2033
|
-
import {
|
|
2034
|
-
getStreamingPorts
|
|
2035
|
-
} from "@workglow/task-graph";
|
|
2036
|
-
class StreamingAiTask extends AiTask {
|
|
2037
|
-
static type = "StreamingAiTask";
|
|
2038
|
-
async* executeStream(input, context) {
|
|
2039
|
-
const jobInput = await this.getJobInput(input);
|
|
2040
|
-
const queueName = await this.getDefaultQueueName(input);
|
|
2041
|
-
const job = new AiJob({
|
|
2042
|
-
queueName: queueName ?? this.type,
|
|
2043
|
-
jobRunId: this.runConfig.runnerId,
|
|
2044
|
-
input: jobInput
|
|
2045
|
-
});
|
|
2046
|
-
const ports = getStreamingPorts(this.outputSchema());
|
|
2047
|
-
const defaultPort = ports.length > 0 ? ports[0].port : "text";
|
|
2048
|
-
for await (const event of job.executeStream(jobInput, {
|
|
2049
|
-
signal: context.signal,
|
|
2050
|
-
updateProgress: context.updateProgress.bind(this)
|
|
2051
|
-
})) {
|
|
2052
|
-
if (event.type === "text-delta") {
|
|
2053
|
-
yield { ...event, port: event.port ?? defaultPort };
|
|
2054
|
-
} else if (event.type === "object-delta") {
|
|
2055
|
-
yield { ...event, port: event.port ?? defaultPort };
|
|
2056
|
-
} else {
|
|
2057
|
-
yield event;
|
|
2058
|
-
}
|
|
2059
|
-
}
|
|
2060
|
-
}
|
|
2061
|
-
}
|
|
2764
|
+
Workflow12.prototype.textNamedEntityRecognition = CreateWorkflow12(TextNamedEntityRecognitionTask);
|
|
2062
2765
|
|
|
2063
2766
|
// src/task/TextSummaryTask.ts
|
|
2064
|
-
|
|
2767
|
+
import { CreateWorkflow as CreateWorkflow13, Workflow as Workflow13 } from "@workglow/task-graph";
|
|
2768
|
+
var modelSchema8 = TypeModel("model:TextSummaryTask");
|
|
2065
2769
|
var TextSummaryInputSchema = {
|
|
2066
2770
|
type: "object",
|
|
2067
2771
|
properties: {
|
|
@@ -2070,7 +2774,7 @@ var TextSummaryInputSchema = {
|
|
|
2070
2774
|
title: "Text",
|
|
2071
2775
|
description: "The text to summarize"
|
|
2072
2776
|
}),
|
|
2073
|
-
model:
|
|
2777
|
+
model: modelSchema8
|
|
2074
2778
|
},
|
|
2075
2779
|
required: ["text", "model"],
|
|
2076
2780
|
additionalProperties: false
|
|
@@ -2104,7 +2808,7 @@ class TextSummaryTask extends StreamingAiTask {
|
|
|
2104
2808
|
var textSummary = async (input, config) => {
|
|
2105
2809
|
return new TextSummaryTask({}, config).run(input);
|
|
2106
2810
|
};
|
|
2107
|
-
|
|
2811
|
+
Workflow13.prototype.textSummary = CreateWorkflow13(TextSummaryTask);
|
|
2108
2812
|
|
|
2109
2813
|
// src/task/DocumentEnricherTask.ts
|
|
2110
2814
|
var inputSchema7 = {
|
|
@@ -2176,7 +2880,7 @@ var outputSchema7 = {
|
|
|
2176
2880
|
additionalProperties: false
|
|
2177
2881
|
};
|
|
2178
2882
|
|
|
2179
|
-
class DocumentEnricherTask extends
|
|
2883
|
+
class DocumentEnricherTask extends Task8 {
|
|
2180
2884
|
static type = "DocumentEnricherTask";
|
|
2181
2885
|
static category = "Document";
|
|
2182
2886
|
static title = "Document Enricher";
|
|
@@ -2335,15 +3039,15 @@ class DocumentEnricherTask extends Task7 {
|
|
|
2335
3039
|
var documentEnricher = (input, config) => {
|
|
2336
3040
|
return new DocumentEnricherTask({}, config).run(input);
|
|
2337
3041
|
};
|
|
2338
|
-
|
|
3042
|
+
Workflow14.prototype.documentEnricher = CreateWorkflow14(DocumentEnricherTask);
|
|
2339
3043
|
|
|
2340
3044
|
// src/task/DownloadModelTask.ts
|
|
2341
|
-
import { CreateWorkflow as
|
|
2342
|
-
var
|
|
3045
|
+
import { CreateWorkflow as CreateWorkflow15, Workflow as Workflow15 } from "@workglow/task-graph";
|
|
3046
|
+
var modelSchema9 = TypeModel("model");
|
|
2343
3047
|
var DownloadModelInputSchema = {
|
|
2344
3048
|
type: "object",
|
|
2345
3049
|
properties: {
|
|
2346
|
-
model:
|
|
3050
|
+
model: modelSchema9
|
|
2347
3051
|
},
|
|
2348
3052
|
required: ["model"],
|
|
2349
3053
|
additionalProperties: false
|
|
@@ -2351,7 +3055,7 @@ var DownloadModelInputSchema = {
|
|
|
2351
3055
|
var DownloadModelOutputSchema = {
|
|
2352
3056
|
type: "object",
|
|
2353
3057
|
properties: {
|
|
2354
|
-
model:
|
|
3058
|
+
model: modelSchema9
|
|
2355
3059
|
},
|
|
2356
3060
|
required: ["model"],
|
|
2357
3061
|
additionalProperties: false
|
|
@@ -2394,11 +3098,11 @@ class DownloadModelTask extends AiTask {
|
|
|
2394
3098
|
var downloadModel = (input, config) => {
|
|
2395
3099
|
return new DownloadModelTask({}, config).run(input);
|
|
2396
3100
|
};
|
|
2397
|
-
|
|
3101
|
+
Workflow15.prototype.downloadModel = CreateWorkflow15(DownloadModelTask);
|
|
2398
3102
|
|
|
2399
3103
|
// src/task/FaceDetectorTask.ts
|
|
2400
|
-
import { CreateWorkflow as
|
|
2401
|
-
var
|
|
3104
|
+
import { CreateWorkflow as CreateWorkflow16, Workflow as Workflow16 } from "@workglow/task-graph";
|
|
3105
|
+
var modelSchema10 = TypeModel("model:FaceDetectorTask");
|
|
2402
3106
|
var TypeBoundingBox2 = {
|
|
2403
3107
|
type: "object",
|
|
2404
3108
|
properties: {
|
|
@@ -2471,7 +3175,7 @@ var FaceDetectorInputSchema = {
|
|
|
2471
3175
|
type: "object",
|
|
2472
3176
|
properties: {
|
|
2473
3177
|
image: TypeImageInput,
|
|
2474
|
-
model:
|
|
3178
|
+
model: modelSchema10,
|
|
2475
3179
|
minDetectionConfidence: {
|
|
2476
3180
|
type: "number",
|
|
2477
3181
|
minimum: 0,
|
|
@@ -2525,11 +3229,11 @@ class FaceDetectorTask extends AiVisionTask {
|
|
|
2525
3229
|
var faceDetector = (input, config) => {
|
|
2526
3230
|
return new FaceDetectorTask({}, config).run(input);
|
|
2527
3231
|
};
|
|
2528
|
-
|
|
3232
|
+
Workflow16.prototype.faceDetector = CreateWorkflow16(FaceDetectorTask);
|
|
2529
3233
|
|
|
2530
3234
|
// src/task/FaceLandmarkerTask.ts
|
|
2531
|
-
import { CreateWorkflow as
|
|
2532
|
-
var
|
|
3235
|
+
import { CreateWorkflow as CreateWorkflow17, Workflow as Workflow17 } from "@workglow/task-graph";
|
|
3236
|
+
var modelSchema11 = TypeModel("model:FaceLandmarkerTask");
|
|
2533
3237
|
var TypeLandmark = {
|
|
2534
3238
|
type: "object",
|
|
2535
3239
|
properties: {
|
|
@@ -2601,7 +3305,7 @@ var FaceLandmarkerInputSchema = {
|
|
|
2601
3305
|
type: "object",
|
|
2602
3306
|
properties: {
|
|
2603
3307
|
image: TypeImageInput,
|
|
2604
|
-
model:
|
|
3308
|
+
model: modelSchema11,
|
|
2605
3309
|
numFaces: {
|
|
2606
3310
|
type: "number",
|
|
2607
3311
|
minimum: 1,
|
|
@@ -2687,11 +3391,11 @@ class FaceLandmarkerTask extends AiVisionTask {
|
|
|
2687
3391
|
var faceLandmarker = (input, config) => {
|
|
2688
3392
|
return new FaceLandmarkerTask({}, config).run(input);
|
|
2689
3393
|
};
|
|
2690
|
-
|
|
3394
|
+
Workflow17.prototype.faceLandmarker = CreateWorkflow17(FaceLandmarkerTask);
|
|
2691
3395
|
|
|
2692
3396
|
// src/task/GestureRecognizerTask.ts
|
|
2693
|
-
import { CreateWorkflow as
|
|
2694
|
-
var
|
|
3397
|
+
import { CreateWorkflow as CreateWorkflow18, Workflow as Workflow18 } from "@workglow/task-graph";
|
|
3398
|
+
var modelSchema12 = TypeModel("model:GestureRecognizerTask");
|
|
2695
3399
|
var TypeLandmark2 = {
|
|
2696
3400
|
type: "object",
|
|
2697
3401
|
properties: {
|
|
@@ -2783,7 +3487,7 @@ var GestureRecognizerInputSchema = {
|
|
|
2783
3487
|
type: "object",
|
|
2784
3488
|
properties: {
|
|
2785
3489
|
image: TypeImageInput,
|
|
2786
|
-
model:
|
|
3490
|
+
model: modelSchema12,
|
|
2787
3491
|
numHands: {
|
|
2788
3492
|
type: "number",
|
|
2789
3493
|
minimum: 1,
|
|
@@ -2855,11 +3559,11 @@ class GestureRecognizerTask extends AiVisionTask {
|
|
|
2855
3559
|
var gestureRecognizer = (input, config) => {
|
|
2856
3560
|
return new GestureRecognizerTask({}, config).run(input);
|
|
2857
3561
|
};
|
|
2858
|
-
|
|
3562
|
+
Workflow18.prototype.gestureRecognizer = CreateWorkflow18(GestureRecognizerTask);
|
|
2859
3563
|
|
|
2860
3564
|
// src/task/HandLandmarkerTask.ts
|
|
2861
|
-
import { CreateWorkflow as
|
|
2862
|
-
var
|
|
3565
|
+
import { CreateWorkflow as CreateWorkflow19, Workflow as Workflow19 } from "@workglow/task-graph";
|
|
3566
|
+
var modelSchema13 = TypeModel("model:HandLandmarkerTask");
|
|
2863
3567
|
var TypeLandmark3 = {
|
|
2864
3568
|
type: "object",
|
|
2865
3569
|
properties: {
|
|
@@ -2928,7 +3632,7 @@ var HandLandmarkerInputSchema = {
|
|
|
2928
3632
|
type: "object",
|
|
2929
3633
|
properties: {
|
|
2930
3634
|
image: TypeImageInput,
|
|
2931
|
-
model:
|
|
3635
|
+
model: modelSchema13,
|
|
2932
3636
|
numHands: {
|
|
2933
3637
|
type: "number",
|
|
2934
3638
|
minimum: 1,
|
|
@@ -3000,7 +3704,7 @@ class HandLandmarkerTask extends AiVisionTask {
|
|
|
3000
3704
|
var handLandmarker = (input, config) => {
|
|
3001
3705
|
return new HandLandmarkerTask({}, config).run(input);
|
|
3002
3706
|
};
|
|
3003
|
-
|
|
3707
|
+
Workflow19.prototype.handLandmarker = CreateWorkflow19(HandLandmarkerTask);
|
|
3004
3708
|
|
|
3005
3709
|
// src/task/HierarchicalChunkerTask.ts
|
|
3006
3710
|
import {
|
|
@@ -3010,12 +3714,12 @@ import {
|
|
|
3010
3714
|
hasChildren as hasChildren2
|
|
3011
3715
|
} from "@workglow/knowledge-base";
|
|
3012
3716
|
import {
|
|
3013
|
-
CreateWorkflow as
|
|
3014
|
-
Task as
|
|
3015
|
-
Workflow as
|
|
3717
|
+
CreateWorkflow as CreateWorkflow20,
|
|
3718
|
+
Task as Task9,
|
|
3719
|
+
Workflow as Workflow20
|
|
3016
3720
|
} from "@workglow/task-graph";
|
|
3017
3721
|
import { uuid4 } from "@workglow/util";
|
|
3018
|
-
var
|
|
3722
|
+
var modelSchema14 = TypeModel("model", {
|
|
3019
3723
|
title: "Model",
|
|
3020
3724
|
description: "Model to use for token counting"
|
|
3021
3725
|
});
|
|
@@ -3059,7 +3763,7 @@ var inputSchema8 = {
|
|
|
3059
3763
|
description: "Strategy for chunking",
|
|
3060
3764
|
default: "hierarchical"
|
|
3061
3765
|
},
|
|
3062
|
-
model:
|
|
3766
|
+
model: modelSchema14
|
|
3063
3767
|
},
|
|
3064
3768
|
required: ["doc_id", "documentTree"],
|
|
3065
3769
|
additionalProperties: false
|
|
@@ -3094,7 +3798,7 @@ var outputSchema8 = {
|
|
|
3094
3798
|
additionalProperties: false
|
|
3095
3799
|
};
|
|
3096
3800
|
|
|
3097
|
-
class HierarchicalChunkerTask extends
|
|
3801
|
+
class HierarchicalChunkerTask extends Task9 {
|
|
3098
3802
|
static type = "HierarchicalChunkerTask";
|
|
3099
3803
|
static category = "Document";
|
|
3100
3804
|
static title = "Hierarchical Chunker";
|
|
@@ -3238,7 +3942,7 @@ class HierarchicalChunkerTask extends Task8 {
|
|
|
3238
3942
|
var hierarchicalChunker = (input, config) => {
|
|
3239
3943
|
return new HierarchicalChunkerTask({}, config).run(input);
|
|
3240
3944
|
};
|
|
3241
|
-
|
|
3945
|
+
Workflow20.prototype.hierarchicalChunker = CreateWorkflow20(HierarchicalChunkerTask);
|
|
3242
3946
|
|
|
3243
3947
|
// src/task/HierarchyJoinTask.ts
|
|
3244
3948
|
import {
|
|
@@ -3246,9 +3950,9 @@ import {
|
|
|
3246
3950
|
TypeKnowledgeBase as TypeKnowledgeBase5
|
|
3247
3951
|
} from "@workglow/knowledge-base";
|
|
3248
3952
|
import {
|
|
3249
|
-
CreateWorkflow as
|
|
3250
|
-
Task as
|
|
3251
|
-
Workflow as
|
|
3953
|
+
CreateWorkflow as CreateWorkflow21,
|
|
3954
|
+
Task as Task10,
|
|
3955
|
+
Workflow as Workflow21
|
|
3252
3956
|
} from "@workglow/task-graph";
|
|
3253
3957
|
var inputSchema9 = {
|
|
3254
3958
|
type: "object",
|
|
@@ -3324,7 +4028,7 @@ var outputSchema9 = {
|
|
|
3324
4028
|
additionalProperties: false
|
|
3325
4029
|
};
|
|
3326
4030
|
|
|
3327
|
-
class HierarchyJoinTask extends
|
|
4031
|
+
class HierarchyJoinTask extends Task10 {
|
|
3328
4032
|
static type = "HierarchyJoinTask";
|
|
3329
4033
|
static category = "RAG";
|
|
3330
4034
|
static title = "Hierarchy Join";
|
|
@@ -3418,16 +4122,16 @@ class HierarchyJoinTask extends Task9 {
|
|
|
3418
4122
|
var hierarchyJoin = (input, config) => {
|
|
3419
4123
|
return new HierarchyJoinTask({}, config).run(input);
|
|
3420
4124
|
};
|
|
3421
|
-
|
|
4125
|
+
Workflow21.prototype.hierarchyJoin = CreateWorkflow21(HierarchyJoinTask);
|
|
3422
4126
|
|
|
3423
4127
|
// src/task/ImageClassificationTask.ts
|
|
3424
|
-
import { CreateWorkflow as
|
|
3425
|
-
var
|
|
4128
|
+
import { CreateWorkflow as CreateWorkflow22, Workflow as Workflow22 } from "@workglow/task-graph";
|
|
4129
|
+
var modelSchema15 = TypeModel("model:ImageClassificationTask");
|
|
3426
4130
|
var ImageClassificationInputSchema = {
|
|
3427
4131
|
type: "object",
|
|
3428
4132
|
properties: {
|
|
3429
4133
|
image: TypeImageInput,
|
|
3430
|
-
model:
|
|
4134
|
+
model: modelSchema15,
|
|
3431
4135
|
categories: {
|
|
3432
4136
|
type: "array",
|
|
3433
4137
|
items: {
|
|
@@ -3481,14 +4185,14 @@ class ImageClassificationTask extends AiVisionTask {
|
|
|
3481
4185
|
var imageClassification = (input, config) => {
|
|
3482
4186
|
return new ImageClassificationTask({}, config).run(input);
|
|
3483
4187
|
};
|
|
3484
|
-
|
|
4188
|
+
Workflow22.prototype.imageClassification = CreateWorkflow22(ImageClassificationTask);
|
|
3485
4189
|
|
|
3486
4190
|
// src/task/ImageEmbeddingTask.ts
|
|
3487
|
-
import { CreateWorkflow as
|
|
4191
|
+
import { CreateWorkflow as CreateWorkflow23, Workflow as Workflow23 } from "@workglow/task-graph";
|
|
3488
4192
|
import {
|
|
3489
4193
|
TypedArraySchema as TypedArraySchema7
|
|
3490
4194
|
} from "@workglow/util";
|
|
3491
|
-
var
|
|
4195
|
+
var modelSchema16 = TypeModel("model:ImageEmbeddingTask");
|
|
3492
4196
|
var embeddingSchema = TypedArraySchema7({
|
|
3493
4197
|
title: "Embedding",
|
|
3494
4198
|
description: "The image embedding vector"
|
|
@@ -3497,7 +4201,7 @@ var ImageEmbeddingInputSchema = {
|
|
|
3497
4201
|
type: "object",
|
|
3498
4202
|
properties: {
|
|
3499
4203
|
image: TypeImageInput,
|
|
3500
|
-
model:
|
|
4204
|
+
model: modelSchema16
|
|
3501
4205
|
},
|
|
3502
4206
|
required: ["image", "model"],
|
|
3503
4207
|
additionalProperties: false
|
|
@@ -3526,16 +4230,16 @@ class ImageEmbeddingTask extends AiVisionTask {
|
|
|
3526
4230
|
var imageEmbedding = (input, config) => {
|
|
3527
4231
|
return new ImageEmbeddingTask({}, config).run(input);
|
|
3528
4232
|
};
|
|
3529
|
-
|
|
4233
|
+
Workflow23.prototype.imageEmbedding = CreateWorkflow23(ImageEmbeddingTask);
|
|
3530
4234
|
|
|
3531
4235
|
// src/task/ImageSegmentationTask.ts
|
|
3532
|
-
import { CreateWorkflow as
|
|
3533
|
-
var
|
|
4236
|
+
import { CreateWorkflow as CreateWorkflow24, Workflow as Workflow24 } from "@workglow/task-graph";
|
|
4237
|
+
var modelSchema17 = TypeModel("model:ImageSegmentationTask");
|
|
3534
4238
|
var ImageSegmentationInputSchema = {
|
|
3535
4239
|
type: "object",
|
|
3536
4240
|
properties: {
|
|
3537
4241
|
image: TypeImageInput,
|
|
3538
|
-
model:
|
|
4242
|
+
model: modelSchema17,
|
|
3539
4243
|
threshold: {
|
|
3540
4244
|
type: "number",
|
|
3541
4245
|
title: "Threshold",
|
|
@@ -3614,11 +4318,11 @@ class ImageSegmentationTask extends AiVisionTask {
|
|
|
3614
4318
|
var imageSegmentation = (input, config) => {
|
|
3615
4319
|
return new ImageSegmentationTask({}, config).run(input);
|
|
3616
4320
|
};
|
|
3617
|
-
|
|
4321
|
+
Workflow24.prototype.imageSegmentation = CreateWorkflow24(ImageSegmentationTask);
|
|
3618
4322
|
|
|
3619
4323
|
// src/task/ImageToTextTask.ts
|
|
3620
|
-
import { CreateWorkflow as
|
|
3621
|
-
var
|
|
4324
|
+
import { CreateWorkflow as CreateWorkflow25, Workflow as Workflow25 } from "@workglow/task-graph";
|
|
4325
|
+
var modelSchema18 = TypeModel("model:ImageToTextTask");
|
|
3622
4326
|
var generatedTextSchema = {
|
|
3623
4327
|
type: "string",
|
|
3624
4328
|
title: "Text",
|
|
@@ -3628,7 +4332,7 @@ var ImageToTextInputSchema = {
|
|
|
3628
4332
|
type: "object",
|
|
3629
4333
|
properties: {
|
|
3630
4334
|
image: TypeImageInput,
|
|
3631
|
-
model:
|
|
4335
|
+
model: modelSchema18,
|
|
3632
4336
|
maxTokens: {
|
|
3633
4337
|
type: "number",
|
|
3634
4338
|
title: "Max Tokens",
|
|
@@ -3669,15 +4373,15 @@ class ImageToTextTask extends AiVisionTask {
|
|
|
3669
4373
|
var imageToText = (input, config) => {
|
|
3670
4374
|
return new ImageToTextTask({}, config).run(input);
|
|
3671
4375
|
};
|
|
3672
|
-
|
|
4376
|
+
Workflow25.prototype.imageToText = CreateWorkflow25(ImageToTextTask);
|
|
3673
4377
|
|
|
3674
4378
|
// src/task/ModelInfoTask.ts
|
|
3675
|
-
import { CreateWorkflow as
|
|
3676
|
-
var
|
|
4379
|
+
import { CreateWorkflow as CreateWorkflow26, Workflow as Workflow26 } from "@workglow/task-graph";
|
|
4380
|
+
var modelSchema19 = TypeModel("model");
|
|
3677
4381
|
var ModelInfoInputSchema = {
|
|
3678
4382
|
type: "object",
|
|
3679
4383
|
properties: {
|
|
3680
|
-
model:
|
|
4384
|
+
model: modelSchema19,
|
|
3681
4385
|
detail: {
|
|
3682
4386
|
type: "string",
|
|
3683
4387
|
enum: ["cached_status", "files", "files_with_metadata"],
|
|
@@ -3690,7 +4394,7 @@ var ModelInfoInputSchema = {
|
|
|
3690
4394
|
var ModelInfoOutputSchema = {
|
|
3691
4395
|
type: "object",
|
|
3692
4396
|
properties: {
|
|
3693
|
-
model:
|
|
4397
|
+
model: modelSchema19,
|
|
3694
4398
|
is_local: { type: "boolean" },
|
|
3695
4399
|
is_remote: { type: "boolean" },
|
|
3696
4400
|
supports_browser: { type: "boolean" },
|
|
@@ -3728,11 +4432,11 @@ class ModelInfoTask extends AiTask {
|
|
|
3728
4432
|
var modelInfo = (input, config) => {
|
|
3729
4433
|
return new ModelInfoTask({}, config).run(input);
|
|
3730
4434
|
};
|
|
3731
|
-
|
|
4435
|
+
Workflow26.prototype.modelInfo = CreateWorkflow26(ModelInfoTask);
|
|
3732
4436
|
|
|
3733
4437
|
// src/task/ObjectDetectionTask.ts
|
|
3734
|
-
import { CreateWorkflow as
|
|
3735
|
-
var
|
|
4438
|
+
import { CreateWorkflow as CreateWorkflow27, Workflow as Workflow27 } from "@workglow/task-graph";
|
|
4439
|
+
var modelSchema20 = TypeModel("model:ObjectDetectionTask");
|
|
3736
4440
|
var detectionSchema = {
|
|
3737
4441
|
type: "object",
|
|
3738
4442
|
properties: {
|
|
@@ -3757,7 +4461,7 @@ var ObjectDetectionInputSchema = {
|
|
|
3757
4461
|
type: "object",
|
|
3758
4462
|
properties: {
|
|
3759
4463
|
image: TypeImageInput,
|
|
3760
|
-
model:
|
|
4464
|
+
model: modelSchema20,
|
|
3761
4465
|
labels: {
|
|
3762
4466
|
type: "array",
|
|
3763
4467
|
items: {
|
|
@@ -3811,11 +4515,11 @@ class ObjectDetectionTask extends AiVisionTask {
|
|
|
3811
4515
|
var objectDetection = (input, config) => {
|
|
3812
4516
|
return new ObjectDetectionTask({}, config).run(input);
|
|
3813
4517
|
};
|
|
3814
|
-
|
|
4518
|
+
Workflow27.prototype.objectDetection = CreateWorkflow27(ObjectDetectionTask);
|
|
3815
4519
|
|
|
3816
4520
|
// src/task/PoseLandmarkerTask.ts
|
|
3817
|
-
import { CreateWorkflow as
|
|
3818
|
-
var
|
|
4521
|
+
import { CreateWorkflow as CreateWorkflow28, Workflow as Workflow28 } from "@workglow/task-graph";
|
|
4522
|
+
var modelSchema21 = TypeModel("model:PoseLandmarkerTask");
|
|
3819
4523
|
var TypePoseLandmark = {
|
|
3820
4524
|
type: "object",
|
|
3821
4525
|
properties: {
|
|
@@ -3894,7 +4598,7 @@ var PoseLandmarkerInputSchema = {
|
|
|
3894
4598
|
type: "object",
|
|
3895
4599
|
properties: {
|
|
3896
4600
|
image: TypeImageInput,
|
|
3897
|
-
model:
|
|
4601
|
+
model: modelSchema21,
|
|
3898
4602
|
numPoses: {
|
|
3899
4603
|
type: "number",
|
|
3900
4604
|
minimum: 1,
|
|
@@ -3973,13 +4677,13 @@ class PoseLandmarkerTask extends AiVisionTask {
|
|
|
3973
4677
|
var poseLandmarker = (input, config) => {
|
|
3974
4678
|
return new PoseLandmarkerTask({}, config).run(input);
|
|
3975
4679
|
};
|
|
3976
|
-
|
|
4680
|
+
Workflow28.prototype.poseLandmarker = CreateWorkflow28(PoseLandmarkerTask);
|
|
3977
4681
|
|
|
3978
4682
|
// src/task/QueryExpanderTask.ts
|
|
3979
4683
|
import {
|
|
3980
|
-
CreateWorkflow as
|
|
3981
|
-
Task as
|
|
3982
|
-
Workflow as
|
|
4684
|
+
CreateWorkflow as CreateWorkflow29,
|
|
4685
|
+
Task as Task11,
|
|
4686
|
+
Workflow as Workflow29
|
|
3983
4687
|
} from "@workglow/task-graph";
|
|
3984
4688
|
var QueryExpansionMethod = {
|
|
3985
4689
|
MULTI_QUERY: "multi-query",
|
|
@@ -4048,7 +4752,7 @@ var outputSchema10 = {
|
|
|
4048
4752
|
additionalProperties: false
|
|
4049
4753
|
};
|
|
4050
4754
|
|
|
4051
|
-
class QueryExpanderTask extends
|
|
4755
|
+
class QueryExpanderTask extends Task11 {
|
|
4052
4756
|
static type = "QueryExpanderTask";
|
|
4053
4757
|
static category = "RAG";
|
|
4054
4758
|
static title = "Query Expander";
|
|
@@ -4190,18 +4894,18 @@ class QueryExpanderTask extends Task10 {
|
|
|
4190
4894
|
var queryExpander = (input, config) => {
|
|
4191
4895
|
return new QueryExpanderTask({}, config).run(input);
|
|
4192
4896
|
};
|
|
4193
|
-
|
|
4897
|
+
Workflow29.prototype.queryExpander = CreateWorkflow29(QueryExpanderTask);
|
|
4194
4898
|
|
|
4195
4899
|
// src/task/RerankerTask.ts
|
|
4196
4900
|
import {
|
|
4197
|
-
CreateWorkflow as
|
|
4198
|
-
Task as
|
|
4199
|
-
Workflow as
|
|
4901
|
+
CreateWorkflow as CreateWorkflow31,
|
|
4902
|
+
Task as Task12,
|
|
4903
|
+
Workflow as Workflow31
|
|
4200
4904
|
} from "@workglow/task-graph";
|
|
4201
4905
|
|
|
4202
4906
|
// src/task/TextClassificationTask.ts
|
|
4203
|
-
import { CreateWorkflow as
|
|
4204
|
-
var
|
|
4907
|
+
import { CreateWorkflow as CreateWorkflow30, Workflow as Workflow30 } from "@workglow/task-graph";
|
|
4908
|
+
var modelSchema22 = TypeModel("model:TextClassificationTask");
|
|
4205
4909
|
var TextClassificationInputSchema = {
|
|
4206
4910
|
type: "object",
|
|
4207
4911
|
properties: {
|
|
@@ -4228,7 +4932,7 @@ var TextClassificationInputSchema = {
|
|
|
4228
4932
|
description: "The maximum number of categories to return",
|
|
4229
4933
|
"x-ui-group": "Configuration"
|
|
4230
4934
|
},
|
|
4231
|
-
model:
|
|
4935
|
+
model: modelSchema22
|
|
4232
4936
|
},
|
|
4233
4937
|
required: ["text", "model"],
|
|
4234
4938
|
additionalProperties: false
|
|
@@ -4278,7 +4982,7 @@ class TextClassificationTask extends AiTask {
|
|
|
4278
4982
|
var textClassification = (input, config) => {
|
|
4279
4983
|
return new TextClassificationTask({}, config).run(input);
|
|
4280
4984
|
};
|
|
4281
|
-
|
|
4985
|
+
Workflow30.prototype.textClassification = CreateWorkflow30(TextClassificationTask);
|
|
4282
4986
|
|
|
4283
4987
|
// src/task/RerankerTask.ts
|
|
4284
4988
|
var inputSchema11 = {
|
|
@@ -4373,7 +5077,7 @@ var outputSchema11 = {
|
|
|
4373
5077
|
additionalProperties: false
|
|
4374
5078
|
};
|
|
4375
5079
|
|
|
4376
|
-
class RerankerTask extends
|
|
5080
|
+
class RerankerTask extends Task12 {
|
|
4377
5081
|
static type = "RerankerTask";
|
|
4378
5082
|
static category = "RAG";
|
|
4379
5083
|
static title = "Reranker";
|
|
@@ -4502,14 +5206,14 @@ class RerankerTask extends Task11 {
|
|
|
4502
5206
|
var reranker = (input, config) => {
|
|
4503
5207
|
return new RerankerTask({}, config).run(input);
|
|
4504
5208
|
};
|
|
4505
|
-
|
|
5209
|
+
Workflow31.prototype.reranker = CreateWorkflow31(RerankerTask);
|
|
4506
5210
|
|
|
4507
5211
|
// src/task/StructuralParserTask.ts
|
|
4508
5212
|
import { StructuralParser } from "@workglow/knowledge-base";
|
|
4509
5213
|
import {
|
|
4510
|
-
CreateWorkflow as
|
|
4511
|
-
Task as
|
|
4512
|
-
Workflow as
|
|
5214
|
+
CreateWorkflow as CreateWorkflow32,
|
|
5215
|
+
Task as Task13,
|
|
5216
|
+
Workflow as Workflow32
|
|
4513
5217
|
} from "@workglow/task-graph";
|
|
4514
5218
|
import { uuid4 as uuid42 } from "@workglow/util";
|
|
4515
5219
|
var inputSchema12 = {
|
|
@@ -4568,7 +5272,7 @@ var outputSchema12 = {
|
|
|
4568
5272
|
additionalProperties: false
|
|
4569
5273
|
};
|
|
4570
5274
|
|
|
4571
|
-
class StructuralParserTask extends
|
|
5275
|
+
class StructuralParserTask extends Task13 {
|
|
4572
5276
|
static type = "StructuralParserTask";
|
|
4573
5277
|
static category = "Document";
|
|
4574
5278
|
static title = "Structural Parser";
|
|
@@ -4611,15 +5315,15 @@ class StructuralParserTask extends Task12 {
|
|
|
4611
5315
|
var structuralParser = (input, config) => {
|
|
4612
5316
|
return new StructuralParserTask({}, config).run(input);
|
|
4613
5317
|
};
|
|
4614
|
-
|
|
5318
|
+
Workflow32.prototype.structuralParser = CreateWorkflow32(StructuralParserTask);
|
|
4615
5319
|
|
|
4616
5320
|
// src/task/StructuredGenerationTask.ts
|
|
4617
|
-
import { CreateWorkflow as
|
|
4618
|
-
var
|
|
5321
|
+
import { CreateWorkflow as CreateWorkflow33, Workflow as Workflow33 } from "@workglow/task-graph";
|
|
5322
|
+
var modelSchema23 = TypeModel("model:StructuredGenerationTask");
|
|
4619
5323
|
var StructuredGenerationInputSchema = {
|
|
4620
5324
|
type: "object",
|
|
4621
5325
|
properties: {
|
|
4622
|
-
model:
|
|
5326
|
+
model: modelSchema23,
|
|
4623
5327
|
prompt: {
|
|
4624
5328
|
type: "string",
|
|
4625
5329
|
title: "Prompt",
|
|
@@ -4682,13 +5386,13 @@ class StructuredGenerationTask extends StreamingAiTask {
|
|
|
4682
5386
|
var structuredGeneration = (input, config) => {
|
|
4683
5387
|
return new StructuredGenerationTask({}, config).run(input);
|
|
4684
5388
|
};
|
|
4685
|
-
|
|
5389
|
+
Workflow33.prototype.structuredGeneration = CreateWorkflow33(StructuredGenerationTask);
|
|
4686
5390
|
|
|
4687
5391
|
// src/task/TextChunkerTask.ts
|
|
4688
5392
|
import {
|
|
4689
|
-
CreateWorkflow as
|
|
4690
|
-
Task as
|
|
4691
|
-
Workflow as
|
|
5393
|
+
CreateWorkflow as CreateWorkflow34,
|
|
5394
|
+
Task as Task14,
|
|
5395
|
+
Workflow as Workflow34
|
|
4692
5396
|
} from "@workglow/task-graph";
|
|
4693
5397
|
var ChunkingStrategy = {
|
|
4694
5398
|
FIXED: "fixed",
|
|
@@ -4758,7 +5462,7 @@ var outputSchema13 = {
|
|
|
4758
5462
|
additionalProperties: false
|
|
4759
5463
|
};
|
|
4760
5464
|
|
|
4761
|
-
class TextChunkerTask extends
|
|
5465
|
+
class TextChunkerTask extends Task14 {
|
|
4762
5466
|
static type = "TextChunkerTask";
|
|
4763
5467
|
static category = "Document";
|
|
4764
5468
|
static title = "Text Chunker";
|
|
@@ -4938,11 +5642,11 @@ class TextChunkerTask extends Task13 {
|
|
|
4938
5642
|
var textChunker = (input, config) => {
|
|
4939
5643
|
return new TextChunkerTask({}, config).run(input);
|
|
4940
5644
|
};
|
|
4941
|
-
|
|
5645
|
+
Workflow34.prototype.textChunker = CreateWorkflow34(TextChunkerTask);
|
|
4942
5646
|
|
|
4943
5647
|
// src/task/TextFillMaskTask.ts
|
|
4944
|
-
import { CreateWorkflow as
|
|
4945
|
-
var
|
|
5648
|
+
import { CreateWorkflow as CreateWorkflow35, Workflow as Workflow35 } from "@workglow/task-graph";
|
|
5649
|
+
var modelSchema24 = TypeModel("model:TextFillMaskTask");
|
|
4946
5650
|
var TextFillMaskInputSchema = {
|
|
4947
5651
|
type: "object",
|
|
4948
5652
|
properties: {
|
|
@@ -4951,7 +5655,7 @@ var TextFillMaskInputSchema = {
|
|
|
4951
5655
|
title: "Text",
|
|
4952
5656
|
description: "The text with a mask token to fill"
|
|
4953
5657
|
}),
|
|
4954
|
-
model:
|
|
5658
|
+
model: modelSchema24
|
|
4955
5659
|
},
|
|
4956
5660
|
required: ["text", "model"],
|
|
4957
5661
|
additionalProperties: false
|
|
@@ -5006,21 +5710,21 @@ class TextFillMaskTask extends AiTask {
|
|
|
5006
5710
|
var textFillMask = (input, config) => {
|
|
5007
5711
|
return new TextFillMaskTask({}, config).run(input);
|
|
5008
5712
|
};
|
|
5009
|
-
|
|
5713
|
+
Workflow35.prototype.textFillMask = CreateWorkflow35(TextFillMaskTask);
|
|
5010
5714
|
|
|
5011
5715
|
// src/task/TextGenerationTask.ts
|
|
5012
|
-
import { CreateWorkflow as
|
|
5716
|
+
import { CreateWorkflow as CreateWorkflow36, Workflow as Workflow36 } from "@workglow/task-graph";
|
|
5013
5717
|
var generatedTextSchema2 = TypeSingleOrArray({
|
|
5014
5718
|
type: "string",
|
|
5015
5719
|
title: "Text",
|
|
5016
5720
|
description: "The generated text",
|
|
5017
5721
|
"x-stream": "append"
|
|
5018
5722
|
});
|
|
5019
|
-
var
|
|
5723
|
+
var modelSchema25 = TypeModel("model:TextGenerationTask");
|
|
5020
5724
|
var TextGenerationInputSchema = {
|
|
5021
5725
|
type: "object",
|
|
5022
5726
|
properties: {
|
|
5023
|
-
model:
|
|
5727
|
+
model: modelSchema25,
|
|
5024
5728
|
prompt: TypeSingleOrArray({
|
|
5025
5729
|
type: "string",
|
|
5026
5730
|
title: "Prompt",
|
|
@@ -5094,11 +5798,11 @@ class TextGenerationTask extends StreamingAiTask {
|
|
|
5094
5798
|
var textGeneration = (input, config) => {
|
|
5095
5799
|
return new TextGenerationTask({}, config).run(input);
|
|
5096
5800
|
};
|
|
5097
|
-
|
|
5801
|
+
Workflow36.prototype.textGeneration = CreateWorkflow36(TextGenerationTask);
|
|
5098
5802
|
|
|
5099
5803
|
// src/task/TextLanguageDetectionTask.ts
|
|
5100
|
-
import { CreateWorkflow as
|
|
5101
|
-
var
|
|
5804
|
+
import { CreateWorkflow as CreateWorkflow37, Workflow as Workflow37 } from "@workglow/task-graph";
|
|
5805
|
+
var modelSchema26 = TypeModel("model:TextLanguageDetectionTask");
|
|
5102
5806
|
var TextLanguageDetectionInputSchema = {
|
|
5103
5807
|
type: "object",
|
|
5104
5808
|
properties: {
|
|
@@ -5115,7 +5819,7 @@ var TextLanguageDetectionInputSchema = {
|
|
|
5115
5819
|
title: "Max Languages",
|
|
5116
5820
|
description: "The maximum number of languages to return"
|
|
5117
5821
|
},
|
|
5118
|
-
model:
|
|
5822
|
+
model: modelSchema26
|
|
5119
5823
|
},
|
|
5120
5824
|
required: ["text", "model"],
|
|
5121
5825
|
additionalProperties: false
|
|
@@ -5165,10 +5869,10 @@ class TextLanguageDetectionTask extends AiTask {
|
|
|
5165
5869
|
var textLanguageDetection = (input, config) => {
|
|
5166
5870
|
return new TextLanguageDetectionTask({}, config).run(input);
|
|
5167
5871
|
};
|
|
5168
|
-
|
|
5872
|
+
Workflow37.prototype.textLanguageDetection = CreateWorkflow37(TextLanguageDetectionTask);
|
|
5169
5873
|
|
|
5170
5874
|
// src/task/TextQuestionAnswerTask.ts
|
|
5171
|
-
import { CreateWorkflow as
|
|
5875
|
+
import { CreateWorkflow as CreateWorkflow38, Workflow as Workflow38 } from "@workglow/task-graph";
|
|
5172
5876
|
var contextSchema = TypeSingleOrArray({
|
|
5173
5877
|
type: "string",
|
|
5174
5878
|
title: "Context",
|
|
@@ -5185,13 +5889,13 @@ var textSchema = TypeSingleOrArray({
|
|
|
5185
5889
|
description: "The generated text",
|
|
5186
5890
|
"x-stream": "append"
|
|
5187
5891
|
});
|
|
5188
|
-
var
|
|
5892
|
+
var modelSchema27 = TypeModel("model:TextQuestionAnswerTask");
|
|
5189
5893
|
var TextQuestionAnswerInputSchema = {
|
|
5190
5894
|
type: "object",
|
|
5191
5895
|
properties: {
|
|
5192
5896
|
context: contextSchema,
|
|
5193
5897
|
question: questionSchema,
|
|
5194
|
-
model:
|
|
5898
|
+
model: modelSchema27
|
|
5195
5899
|
},
|
|
5196
5900
|
required: ["context", "question", "model"],
|
|
5197
5901
|
additionalProperties: false
|
|
@@ -5220,11 +5924,11 @@ class TextQuestionAnswerTask extends StreamingAiTask {
|
|
|
5220
5924
|
var textQuestionAnswer = (input, config) => {
|
|
5221
5925
|
return new TextQuestionAnswerTask({}, config).run(input);
|
|
5222
5926
|
};
|
|
5223
|
-
|
|
5927
|
+
Workflow38.prototype.textQuestionAnswer = CreateWorkflow38(TextQuestionAnswerTask);
|
|
5224
5928
|
|
|
5225
5929
|
// src/task/TextRewriterTask.ts
|
|
5226
|
-
import { CreateWorkflow as
|
|
5227
|
-
var
|
|
5930
|
+
import { CreateWorkflow as CreateWorkflow39, Workflow as Workflow39 } from "@workglow/task-graph";
|
|
5931
|
+
var modelSchema28 = TypeModel("model:TextRewriterTask");
|
|
5228
5932
|
var TextRewriterInputSchema = {
|
|
5229
5933
|
type: "object",
|
|
5230
5934
|
properties: {
|
|
@@ -5238,7 +5942,7 @@ var TextRewriterInputSchema = {
|
|
|
5238
5942
|
title: "Prompt",
|
|
5239
5943
|
description: "The prompt to direct the rewriting"
|
|
5240
5944
|
},
|
|
5241
|
-
model:
|
|
5945
|
+
model: modelSchema28
|
|
5242
5946
|
},
|
|
5243
5947
|
required: ["text", "prompt", "model"],
|
|
5244
5948
|
additionalProperties: false
|
|
@@ -5272,11 +5976,11 @@ class TextRewriterTask extends StreamingAiTask {
|
|
|
5272
5976
|
var textRewriter = (input, config) => {
|
|
5273
5977
|
return new TextRewriterTask({}, config).run(input);
|
|
5274
5978
|
};
|
|
5275
|
-
|
|
5979
|
+
Workflow39.prototype.textRewriter = CreateWorkflow39(TextRewriterTask);
|
|
5276
5980
|
|
|
5277
5981
|
// src/task/TextTranslationTask.ts
|
|
5278
|
-
import { CreateWorkflow as
|
|
5279
|
-
var
|
|
5982
|
+
import { CreateWorkflow as CreateWorkflow40, Workflow as Workflow40 } from "@workglow/task-graph";
|
|
5983
|
+
var modelSchema29 = TypeModel("model:TextTranslationTask");
|
|
5280
5984
|
var translationTextSchema = TypeSingleOrArray({
|
|
5281
5985
|
type: "string",
|
|
5282
5986
|
title: "Text",
|
|
@@ -5303,7 +6007,7 @@ var TextTranslationInputSchema = {
|
|
|
5303
6007
|
minLength: 2,
|
|
5304
6008
|
maxLength: 2
|
|
5305
6009
|
}),
|
|
5306
|
-
model:
|
|
6010
|
+
model: modelSchema29
|
|
5307
6011
|
},
|
|
5308
6012
|
required: ["text", "source_lang", "target_lang", "model"],
|
|
5309
6013
|
additionalProperties: false
|
|
@@ -5338,181 +6042,13 @@ class TextTranslationTask extends StreamingAiTask {
|
|
|
5338
6042
|
var textTranslation = (input, config) => {
|
|
5339
6043
|
return new TextTranslationTask({}, config).run(input);
|
|
5340
6044
|
};
|
|
5341
|
-
|
|
5342
|
-
|
|
5343
|
-
// src/task/ToolCallingTask.ts
|
|
5344
|
-
import {
|
|
5345
|
-
CreateWorkflow as CreateWorkflow39,
|
|
5346
|
-
getTaskConstructors,
|
|
5347
|
-
Workflow as Workflow39
|
|
5348
|
-
} from "@workglow/task-graph";
|
|
5349
|
-
import { getLogger } from "@workglow/util";
|
|
5350
|
-
function buildToolDescription(tool) {
|
|
5351
|
-
let desc = tool.description;
|
|
5352
|
-
if (tool.outputSchema && typeof tool.outputSchema === "object") {
|
|
5353
|
-
desc += `
|
|
5354
|
-
|
|
5355
|
-
Returns: ${JSON.stringify(tool.outputSchema)}`;
|
|
5356
|
-
}
|
|
5357
|
-
return desc;
|
|
5358
|
-
}
|
|
5359
|
-
function isAllowedToolName(name, allowedTools) {
|
|
5360
|
-
return allowedTools.some((t) => t.name === name);
|
|
5361
|
-
}
|
|
5362
|
-
function filterValidToolCalls(toolCalls, allowedTools) {
|
|
5363
|
-
const filtered = {};
|
|
5364
|
-
for (const [key, value] of Object.entries(toolCalls)) {
|
|
5365
|
-
const tc = value;
|
|
5366
|
-
if (tc.name && isAllowedToolName(tc.name, allowedTools)) {
|
|
5367
|
-
filtered[key] = value;
|
|
5368
|
-
} else {
|
|
5369
|
-
getLogger().warn(`Filtered out tool call with unknown name "${tc.name ?? "(missing)"}"`, {
|
|
5370
|
-
callId: key,
|
|
5371
|
-
toolName: tc.name
|
|
5372
|
-
});
|
|
5373
|
-
}
|
|
5374
|
-
}
|
|
5375
|
-
return filtered;
|
|
5376
|
-
}
|
|
5377
|
-
function taskTypesToTools(taskNames, registry) {
|
|
5378
|
-
const constructors = getTaskConstructors(registry);
|
|
5379
|
-
return taskNames.map((name) => {
|
|
5380
|
-
const ctor = constructors.get(name);
|
|
5381
|
-
if (!ctor) {
|
|
5382
|
-
throw new Error(`taskTypesToTools: Unknown task type "${name}" \u2014 not found in task constructors registry (ServiceRegistry: ${registry ? "custom" : "default"})`);
|
|
5383
|
-
}
|
|
5384
|
-
return {
|
|
5385
|
-
name: ctor.type,
|
|
5386
|
-
description: ctor.description ?? "",
|
|
5387
|
-
inputSchema: ctor.inputSchema(),
|
|
5388
|
-
outputSchema: ctor.outputSchema()
|
|
5389
|
-
};
|
|
5390
|
-
});
|
|
5391
|
-
}
|
|
5392
|
-
var ToolDefinitionSchema = {
|
|
5393
|
-
type: "object",
|
|
5394
|
-
properties: {
|
|
5395
|
-
name: {
|
|
5396
|
-
type: "string",
|
|
5397
|
-
title: "Name",
|
|
5398
|
-
description: "The tool name"
|
|
5399
|
-
},
|
|
5400
|
-
description: {
|
|
5401
|
-
type: "string",
|
|
5402
|
-
title: "Description",
|
|
5403
|
-
description: "A description of what the tool does"
|
|
5404
|
-
},
|
|
5405
|
-
inputSchema: {
|
|
5406
|
-
type: "object",
|
|
5407
|
-
title: "Input Schema",
|
|
5408
|
-
description: "JSON Schema describing the tool's input parameters",
|
|
5409
|
-
additionalProperties: true
|
|
5410
|
-
},
|
|
5411
|
-
outputSchema: {
|
|
5412
|
-
type: "object",
|
|
5413
|
-
title: "Output Schema",
|
|
5414
|
-
description: "JSON Schema describing what the tool returns",
|
|
5415
|
-
additionalProperties: true
|
|
5416
|
-
}
|
|
5417
|
-
},
|
|
5418
|
-
required: ["name", "description", "inputSchema"],
|
|
5419
|
-
additionalProperties: false
|
|
5420
|
-
};
|
|
5421
|
-
var modelSchema28 = TypeModel("model:ToolCallingTask");
|
|
5422
|
-
var ToolCallingInputSchema = {
|
|
5423
|
-
type: "object",
|
|
5424
|
-
properties: {
|
|
5425
|
-
model: modelSchema28,
|
|
5426
|
-
prompt: TypeSingleOrArray({
|
|
5427
|
-
type: "string",
|
|
5428
|
-
title: "Prompt",
|
|
5429
|
-
description: "The prompt to send to the model"
|
|
5430
|
-
}),
|
|
5431
|
-
systemPrompt: {
|
|
5432
|
-
type: "string",
|
|
5433
|
-
title: "System Prompt",
|
|
5434
|
-
description: "Optional system instructions for the model"
|
|
5435
|
-
},
|
|
5436
|
-
tools: {
|
|
5437
|
-
type: "array",
|
|
5438
|
-
format: "tasks",
|
|
5439
|
-
title: "Tools",
|
|
5440
|
-
description: "Tool definitions available for the model to call",
|
|
5441
|
-
items: {
|
|
5442
|
-
oneOf: [
|
|
5443
|
-
{ type: "string", format: "tasks", description: "Task type name" },
|
|
5444
|
-
ToolDefinitionSchema
|
|
5445
|
-
]
|
|
5446
|
-
}
|
|
5447
|
-
},
|
|
5448
|
-
toolChoice: {
|
|
5449
|
-
type: "string",
|
|
5450
|
-
title: "Tool Choice",
|
|
5451
|
-
description: 'Controls tool selection: "auto" (model decides), "none" (no tools), "required" (must call a tool), or a specific tool name',
|
|
5452
|
-
"x-ui-group": "Configuration"
|
|
5453
|
-
},
|
|
5454
|
-
maxTokens: {
|
|
5455
|
-
type: "number",
|
|
5456
|
-
title: "Max Tokens",
|
|
5457
|
-
description: "The maximum number of tokens to generate",
|
|
5458
|
-
minimum: 1,
|
|
5459
|
-
"x-ui-group": "Configuration"
|
|
5460
|
-
},
|
|
5461
|
-
temperature: {
|
|
5462
|
-
type: "number",
|
|
5463
|
-
title: "Temperature",
|
|
5464
|
-
description: "The temperature to use for sampling",
|
|
5465
|
-
minimum: 0,
|
|
5466
|
-
maximum: 2,
|
|
5467
|
-
"x-ui-group": "Configuration"
|
|
5468
|
-
}
|
|
5469
|
-
},
|
|
5470
|
-
required: ["model", "prompt", "tools"],
|
|
5471
|
-
additionalProperties: false
|
|
5472
|
-
};
|
|
5473
|
-
var ToolCallingOutputSchema = {
|
|
5474
|
-
type: "object",
|
|
5475
|
-
properties: {
|
|
5476
|
-
text: TypeSingleOrArray({
|
|
5477
|
-
type: "string",
|
|
5478
|
-
title: "Text",
|
|
5479
|
-
description: "Any text content generated by the model",
|
|
5480
|
-
"x-stream": "append"
|
|
5481
|
-
}),
|
|
5482
|
-
toolCalls: TypeSingleOrArray({
|
|
5483
|
-
type: "object",
|
|
5484
|
-
title: "Tool Calls",
|
|
5485
|
-
description: "Tool invocations requested by the model, keyed by call id",
|
|
5486
|
-
additionalProperties: true,
|
|
5487
|
-
"x-stream": "object"
|
|
5488
|
-
})
|
|
5489
|
-
},
|
|
5490
|
-
required: ["text", "toolCalls"],
|
|
5491
|
-
additionalProperties: false
|
|
5492
|
-
};
|
|
5493
|
-
|
|
5494
|
-
class ToolCallingTask extends StreamingAiTask {
|
|
5495
|
-
static type = "ToolCallingTask";
|
|
5496
|
-
static category = "AI Text Model";
|
|
5497
|
-
static title = "Tool Calling";
|
|
5498
|
-
static description = "Sends a prompt with tool definitions to a language model and returns text along with any tool calls the model requests";
|
|
5499
|
-
static inputSchema() {
|
|
5500
|
-
return ToolCallingInputSchema;
|
|
5501
|
-
}
|
|
5502
|
-
static outputSchema() {
|
|
5503
|
-
return ToolCallingOutputSchema;
|
|
5504
|
-
}
|
|
5505
|
-
}
|
|
5506
|
-
var toolCalling = (input, config) => {
|
|
5507
|
-
return new ToolCallingTask({}, config).run(input);
|
|
5508
|
-
};
|
|
5509
|
-
Workflow39.prototype.toolCalling = CreateWorkflow39(ToolCallingTask);
|
|
6045
|
+
Workflow40.prototype.textTranslation = CreateWorkflow40(TextTranslationTask);
|
|
5510
6046
|
|
|
5511
6047
|
// src/task/TopicSegmenterTask.ts
|
|
5512
6048
|
import {
|
|
5513
|
-
CreateWorkflow as
|
|
5514
|
-
Task as
|
|
5515
|
-
Workflow as
|
|
6049
|
+
CreateWorkflow as CreateWorkflow41,
|
|
6050
|
+
Task as Task15,
|
|
6051
|
+
Workflow as Workflow41
|
|
5516
6052
|
} from "@workglow/task-graph";
|
|
5517
6053
|
var SegmentationMethod = {
|
|
5518
6054
|
HEURISTIC: "heuristic",
|
|
@@ -5588,7 +6124,7 @@ var outputSchema14 = {
|
|
|
5588
6124
|
additionalProperties: false
|
|
5589
6125
|
};
|
|
5590
6126
|
|
|
5591
|
-
class TopicSegmenterTask extends
|
|
6127
|
+
class TopicSegmenterTask extends Task15 {
|
|
5592
6128
|
static type = "TopicSegmenterTask";
|
|
5593
6129
|
static category = "Document";
|
|
5594
6130
|
static title = "Topic Segmenter";
|
|
@@ -5793,15 +6329,15 @@ class TopicSegmenterTask extends Task14 {
|
|
|
5793
6329
|
var topicSegmenter = (input, config) => {
|
|
5794
6330
|
return new TopicSegmenterTask({}, config).run(input);
|
|
5795
6331
|
};
|
|
5796
|
-
|
|
6332
|
+
Workflow41.prototype.topicSegmenter = CreateWorkflow41(TopicSegmenterTask);
|
|
5797
6333
|
|
|
5798
6334
|
// src/task/UnloadModelTask.ts
|
|
5799
|
-
import { CreateWorkflow as
|
|
5800
|
-
var
|
|
6335
|
+
import { CreateWorkflow as CreateWorkflow42, Workflow as Workflow42 } from "@workglow/task-graph";
|
|
6336
|
+
var modelSchema30 = TypeModel("model");
|
|
5801
6337
|
var UnloadModelInputSchema = {
|
|
5802
6338
|
type: "object",
|
|
5803
6339
|
properties: {
|
|
5804
|
-
model:
|
|
6340
|
+
model: modelSchema30
|
|
5805
6341
|
},
|
|
5806
6342
|
required: ["model"],
|
|
5807
6343
|
additionalProperties: false
|
|
@@ -5809,7 +6345,7 @@ var UnloadModelInputSchema = {
|
|
|
5809
6345
|
var UnloadModelOutputSchema = {
|
|
5810
6346
|
type: "object",
|
|
5811
6347
|
properties: {
|
|
5812
|
-
model:
|
|
6348
|
+
model: modelSchema30
|
|
5813
6349
|
},
|
|
5814
6350
|
required: ["model"],
|
|
5815
6351
|
additionalProperties: false
|
|
@@ -5831,10 +6367,10 @@ class UnloadModelTask extends AiTask {
|
|
|
5831
6367
|
var unloadModel = (input, config) => {
|
|
5832
6368
|
return new UnloadModelTask({}, config).run(input);
|
|
5833
6369
|
};
|
|
5834
|
-
|
|
6370
|
+
Workflow42.prototype.unloadModel = CreateWorkflow42(UnloadModelTask);
|
|
5835
6371
|
|
|
5836
6372
|
// src/task/VectorQuantizeTask.ts
|
|
5837
|
-
import { CreateWorkflow as
|
|
6373
|
+
import { CreateWorkflow as CreateWorkflow43, Task as Task16, Workflow as Workflow43 } from "@workglow/task-graph";
|
|
5838
6374
|
import {
|
|
5839
6375
|
normalizeNumberArray,
|
|
5840
6376
|
TensorType,
|
|
@@ -5914,7 +6450,7 @@ var outputSchema15 = {
|
|
|
5914
6450
|
additionalProperties: false
|
|
5915
6451
|
};
|
|
5916
6452
|
|
|
5917
|
-
class VectorQuantizeTask extends
|
|
6453
|
+
class VectorQuantizeTask extends Task16 {
|
|
5918
6454
|
static type = "VectorQuantizeTask";
|
|
5919
6455
|
static category = "Vector";
|
|
5920
6456
|
static title = "Quantize";
|
|
@@ -6014,10 +6550,10 @@ class VectorQuantizeTask extends Task15 {
|
|
|
6014
6550
|
var vectorQuantize = (input, config) => {
|
|
6015
6551
|
return new VectorQuantizeTask({}, config).run(input);
|
|
6016
6552
|
};
|
|
6017
|
-
|
|
6553
|
+
Workflow43.prototype.vectorQuantize = CreateWorkflow43(VectorQuantizeTask);
|
|
6018
6554
|
|
|
6019
6555
|
// src/task/VectorSimilarityTask.ts
|
|
6020
|
-
import { CreateWorkflow as
|
|
6556
|
+
import { CreateWorkflow as CreateWorkflow44, GraphAsTask, Workflow as Workflow44 } from "@workglow/task-graph";
|
|
6021
6557
|
import {
|
|
6022
6558
|
cosineSimilarity,
|
|
6023
6559
|
hammingSimilarity,
|
|
@@ -6091,7 +6627,7 @@ var SimilarityOutputSchema = {
|
|
|
6091
6627
|
|
|
6092
6628
|
class VectorSimilarityTask extends GraphAsTask {
|
|
6093
6629
|
static type = "VectorSimilarityTask";
|
|
6094
|
-
static category = "
|
|
6630
|
+
static category = "Vector";
|
|
6095
6631
|
static title = "Vector Similarity";
|
|
6096
6632
|
static description = "Compares vectors using similarity functions and returns top-K ranked results";
|
|
6097
6633
|
static cacheable = true;
|
|
@@ -6123,11 +6659,208 @@ class VectorSimilarityTask extends GraphAsTask {
|
|
|
6123
6659
|
var similarity = (input, config) => {
|
|
6124
6660
|
return new VectorSimilarityTask({}, config).run(input);
|
|
6125
6661
|
};
|
|
6126
|
-
|
|
6662
|
+
Workflow44.prototype.similarity = CreateWorkflow44(VectorSimilarityTask);
|
|
6663
|
+
// src/task/MessageConversion.ts
|
|
6664
|
+
function getInputMessages(input) {
|
|
6665
|
+
const messages = input.messages;
|
|
6666
|
+
if (!messages || messages.length === 0)
|
|
6667
|
+
return;
|
|
6668
|
+
return messages;
|
|
6669
|
+
}
|
|
6670
|
+
function toOpenAIMessages(input) {
|
|
6671
|
+
const messages = [];
|
|
6672
|
+
if (input.systemPrompt) {
|
|
6673
|
+
messages.push({ role: "system", content: input.systemPrompt });
|
|
6674
|
+
}
|
|
6675
|
+
const inputMessages = getInputMessages(input);
|
|
6676
|
+
if (!inputMessages) {
|
|
6677
|
+
if (!Array.isArray(input.prompt)) {
|
|
6678
|
+
messages.push({ role: "user", content: input.prompt });
|
|
6679
|
+
} else if (input.prompt.every((item) => typeof item === "string")) {
|
|
6680
|
+
messages.push({ role: "user", content: input.prompt.join(`
|
|
6681
|
+
`) });
|
|
6682
|
+
} else {
|
|
6683
|
+
const parts = [];
|
|
6684
|
+
for (const item of input.prompt) {
|
|
6685
|
+
if (typeof item === "string") {
|
|
6686
|
+
parts.push({ type: "text", text: item });
|
|
6687
|
+
} else {
|
|
6688
|
+
const b = item;
|
|
6689
|
+
if (b.type === "text") {
|
|
6690
|
+
parts.push({ type: "text", text: b.text });
|
|
6691
|
+
} else if (b.type === "image") {
|
|
6692
|
+
parts.push({
|
|
6693
|
+
type: "image_url",
|
|
6694
|
+
image_url: { url: `data:${b.mimeType};base64,${b.data}` }
|
|
6695
|
+
});
|
|
6696
|
+
} else if (b.type === "audio") {
|
|
6697
|
+
const format = b.mimeType.replace(/^audio\//, "");
|
|
6698
|
+
parts.push({
|
|
6699
|
+
type: "input_audio",
|
|
6700
|
+
input_audio: { data: b.data, format }
|
|
6701
|
+
});
|
|
6702
|
+
}
|
|
6703
|
+
}
|
|
6704
|
+
}
|
|
6705
|
+
messages.push({ role: "user", content: parts });
|
|
6706
|
+
}
|
|
6707
|
+
return messages;
|
|
6708
|
+
}
|
|
6709
|
+
for (const msg of inputMessages) {
|
|
6710
|
+
if (msg.role === "user") {
|
|
6711
|
+
if (typeof msg.content === "string") {
|
|
6712
|
+
messages.push({ role: "user", content: msg.content });
|
|
6713
|
+
} else if (Array.isArray(msg.content) && msg.content.length > 0 && typeof msg.content[0]?.type === "string") {
|
|
6714
|
+
const parts = [];
|
|
6715
|
+
for (const block of msg.content) {
|
|
6716
|
+
const b = block;
|
|
6717
|
+
if (b.type === "text") {
|
|
6718
|
+
parts.push({ type: "text", text: b.text });
|
|
6719
|
+
} else if (b.type === "image") {
|
|
6720
|
+
parts.push({
|
|
6721
|
+
type: "image_url",
|
|
6722
|
+
image_url: { url: `data:${b.mimeType};base64,${b.data}` }
|
|
6723
|
+
});
|
|
6724
|
+
} else if (b.type === "audio") {
|
|
6725
|
+
const format = b.mimeType.replace(/^audio\//, "");
|
|
6726
|
+
parts.push({
|
|
6727
|
+
type: "input_audio",
|
|
6728
|
+
input_audio: { data: b.data, format }
|
|
6729
|
+
});
|
|
6730
|
+
}
|
|
6731
|
+
}
|
|
6732
|
+
messages.push({ role: "user", content: parts });
|
|
6733
|
+
} else {
|
|
6734
|
+
try {
|
|
6735
|
+
messages.push({ role: "user", content: JSON.stringify(msg.content) });
|
|
6736
|
+
} catch {
|
|
6737
|
+
messages.push({ role: "user", content: String(msg.content) });
|
|
6738
|
+
}
|
|
6739
|
+
}
|
|
6740
|
+
} else if (msg.role === "assistant") {
|
|
6741
|
+
if (typeof msg.content === "string") {
|
|
6742
|
+
messages.push({ role: "assistant", content: msg.content.length > 0 ? msg.content : null });
|
|
6743
|
+
} else if (Array.isArray(msg.content)) {
|
|
6744
|
+
const textParts = msg.content.filter((b) => b.type === "text").map((b) => b.text).join("");
|
|
6745
|
+
const toolCalls = msg.content.filter((b) => b.type === "tool_use").map((b) => ({
|
|
6746
|
+
id: b.id,
|
|
6747
|
+
type: "function",
|
|
6748
|
+
function: {
|
|
6749
|
+
name: b.name,
|
|
6750
|
+
arguments: JSON.stringify(b.input)
|
|
6751
|
+
}
|
|
6752
|
+
}));
|
|
6753
|
+
const entry = {
|
|
6754
|
+
role: "assistant",
|
|
6755
|
+
content: textParts.length > 0 ? textParts : null
|
|
6756
|
+
};
|
|
6757
|
+
if (toolCalls.length > 0) {
|
|
6758
|
+
entry.tool_calls = toolCalls;
|
|
6759
|
+
}
|
|
6760
|
+
messages.push(entry);
|
|
6761
|
+
}
|
|
6762
|
+
} else if (msg.role === "tool" && Array.isArray(msg.content)) {
|
|
6763
|
+
for (const block of msg.content) {
|
|
6764
|
+
const b = block;
|
|
6765
|
+
let content;
|
|
6766
|
+
if (typeof b.content === "string") {
|
|
6767
|
+
content = b.content;
|
|
6768
|
+
} else if (Array.isArray(b.content)) {
|
|
6769
|
+
const parts = [];
|
|
6770
|
+
for (const inner of b.content) {
|
|
6771
|
+
if (inner.type === "text") {
|
|
6772
|
+
parts.push({ type: "text", text: inner.text });
|
|
6773
|
+
} else if (inner.type === "image") {
|
|
6774
|
+
parts.push({
|
|
6775
|
+
type: "image_url",
|
|
6776
|
+
image_url: { url: `data:${inner.mimeType};base64,${inner.data}` }
|
|
6777
|
+
});
|
|
6778
|
+
}
|
|
6779
|
+
}
|
|
6780
|
+
content = parts;
|
|
6781
|
+
} else {
|
|
6782
|
+
content = "";
|
|
6783
|
+
}
|
|
6784
|
+
messages.push({
|
|
6785
|
+
role: "tool",
|
|
6786
|
+
content,
|
|
6787
|
+
tool_call_id: b.tool_use_id
|
|
6788
|
+
});
|
|
6789
|
+
}
|
|
6790
|
+
}
|
|
6791
|
+
}
|
|
6792
|
+
return messages;
|
|
6793
|
+
}
|
|
6794
|
+
function toTextFlatMessages(input) {
|
|
6795
|
+
const messages = [];
|
|
6796
|
+
if (input.systemPrompt) {
|
|
6797
|
+
messages.push({ role: "system", content: input.systemPrompt });
|
|
6798
|
+
}
|
|
6799
|
+
const inputMessages = getInputMessages(input);
|
|
6800
|
+
if (!inputMessages) {
|
|
6801
|
+
let promptContent;
|
|
6802
|
+
if (!Array.isArray(input.prompt)) {
|
|
6803
|
+
promptContent = input.prompt;
|
|
6804
|
+
} else {
|
|
6805
|
+
promptContent = input.prompt.map((item) => {
|
|
6806
|
+
if (typeof item === "string")
|
|
6807
|
+
return item;
|
|
6808
|
+
const b = item;
|
|
6809
|
+
return b.type === "text" ? b.text : "";
|
|
6810
|
+
}).filter((s) => s !== "").join(`
|
|
6811
|
+
`);
|
|
6812
|
+
}
|
|
6813
|
+
messages.push({ role: "user", content: promptContent });
|
|
6814
|
+
return messages;
|
|
6815
|
+
}
|
|
6816
|
+
for (const msg of inputMessages) {
|
|
6817
|
+
if (msg.role === "user") {
|
|
6818
|
+
let content = "";
|
|
6819
|
+
if (typeof msg.content === "string") {
|
|
6820
|
+
content = msg.content;
|
|
6821
|
+
} else if (Array.isArray(msg.content) && msg.content.length > 0 && typeof msg.content[0]?.type === "string") {
|
|
6822
|
+
content = msg.content.filter((b) => b.type === "text").map((b) => b.text).join("");
|
|
6823
|
+
} else if (msg.content != null) {
|
|
6824
|
+
try {
|
|
6825
|
+
content = JSON.stringify(msg.content);
|
|
6826
|
+
} catch {
|
|
6827
|
+
content = String(msg.content);
|
|
6828
|
+
}
|
|
6829
|
+
}
|
|
6830
|
+
messages.push({ role: "user", content });
|
|
6831
|
+
} else if (msg.role === "assistant") {
|
|
6832
|
+
if (typeof msg.content === "string") {
|
|
6833
|
+
if (msg.content) {
|
|
6834
|
+
messages.push({ role: "assistant", content: msg.content });
|
|
6835
|
+
}
|
|
6836
|
+
} else if (Array.isArray(msg.content)) {
|
|
6837
|
+
const text = msg.content.filter((b) => b.type === "text").map((b) => b.text).join("");
|
|
6838
|
+
if (text) {
|
|
6839
|
+
messages.push({ role: "assistant", content: text });
|
|
6840
|
+
}
|
|
6841
|
+
}
|
|
6842
|
+
} else if (msg.role === "tool" && Array.isArray(msg.content)) {
|
|
6843
|
+
for (const block of msg.content) {
|
|
6844
|
+
const b = block;
|
|
6845
|
+
let content;
|
|
6846
|
+
if (typeof b.content === "string") {
|
|
6847
|
+
content = b.content;
|
|
6848
|
+
} else if (Array.isArray(b.content)) {
|
|
6849
|
+
content = b.content.filter((inner) => inner.type === "text").map((inner) => inner.text).join("");
|
|
6850
|
+
} else {
|
|
6851
|
+
content = "";
|
|
6852
|
+
}
|
|
6853
|
+
messages.push({ role: "tool", content });
|
|
6854
|
+
}
|
|
6855
|
+
}
|
|
6856
|
+
}
|
|
6857
|
+
return messages;
|
|
6858
|
+
}
|
|
6127
6859
|
|
|
6128
6860
|
// src/task/index.ts
|
|
6129
6861
|
var registerAiTasks = () => {
|
|
6130
6862
|
const tasks = [
|
|
6863
|
+
AgentTask,
|
|
6131
6864
|
BackgroundRemovalTask,
|
|
6132
6865
|
ChunkToVectorTask,
|
|
6133
6866
|
CountTokensTask,
|
|
@@ -6178,9 +6911,14 @@ var registerAiTasks = () => {
|
|
|
6178
6911
|
export {
|
|
6179
6912
|
vectorStoreSearch,
|
|
6180
6913
|
vectorQuantize,
|
|
6914
|
+
userMessage,
|
|
6181
6915
|
unloadModel,
|
|
6182
6916
|
topicSegmenter,
|
|
6917
|
+
toolSourceDefinitions,
|
|
6918
|
+
toolMessage,
|
|
6183
6919
|
toolCalling,
|
|
6920
|
+
toTextFlatMessages,
|
|
6921
|
+
toOpenAIMessages,
|
|
6184
6922
|
textTranslation,
|
|
6185
6923
|
textSummary,
|
|
6186
6924
|
textRewriter,
|
|
@@ -6209,16 +6947,22 @@ export {
|
|
|
6209
6947
|
imageSegmentation,
|
|
6210
6948
|
imageEmbedding,
|
|
6211
6949
|
imageClassification,
|
|
6950
|
+
imageBlockFromDataUri,
|
|
6951
|
+
imageBlock,
|
|
6212
6952
|
hybridSearch,
|
|
6213
6953
|
hierarchyJoin,
|
|
6214
6954
|
hierarchicalChunker,
|
|
6955
|
+
hasToolCalls,
|
|
6215
6956
|
handLandmarker,
|
|
6216
6957
|
getGlobalModelRepository,
|
|
6217
6958
|
getAiProviderRegistry,
|
|
6218
6959
|
gestureRecognizer,
|
|
6960
|
+
findToolSource,
|
|
6219
6961
|
filterValidToolCalls,
|
|
6220
6962
|
faceLandmarker,
|
|
6221
6963
|
faceDetector,
|
|
6964
|
+
executeToolCalls,
|
|
6965
|
+
executeToolCall,
|
|
6222
6966
|
downloadModel,
|
|
6223
6967
|
documentEnricher,
|
|
6224
6968
|
countTokens,
|
|
@@ -6226,8 +6970,13 @@ export {
|
|
|
6226
6970
|
chunkVectorUpsert,
|
|
6227
6971
|
chunkToVector,
|
|
6228
6972
|
chunkRetrieval,
|
|
6973
|
+
buildToolSources,
|
|
6229
6974
|
buildToolDescription,
|
|
6230
6975
|
backgroundRemoval,
|
|
6976
|
+
audioBlockFromDataUri,
|
|
6977
|
+
audioBlock,
|
|
6978
|
+
assistantMessage,
|
|
6979
|
+
agent,
|
|
6231
6980
|
VectorSimilarityTask,
|
|
6232
6981
|
VectorQuantizeTask,
|
|
6233
6982
|
UnloadModelTask,
|
|
@@ -6344,7 +7093,10 @@ export {
|
|
|
6344
7093
|
AiTask,
|
|
6345
7094
|
AiProviderRegistry,
|
|
6346
7095
|
AiProvider,
|
|
6347
|
-
AiJob
|
|
7096
|
+
AiJob,
|
|
7097
|
+
AgentTask,
|
|
7098
|
+
AgentOutputSchema,
|
|
7099
|
+
AgentInputSchema
|
|
6348
7100
|
};
|
|
6349
7101
|
|
|
6350
|
-
//# debugId=
|
|
7102
|
+
//# debugId=470E906FF8218D7164756E2164756E21
|