@workglow/ai 0.0.98 → 0.0.100
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 +348 -161
- package/dist/browser.js.map +10 -9
- package/dist/bun.js +348 -161
- package/dist/bun.js.map +10 -9
- package/dist/node.js +348 -161
- package/dist/node.js.map +10 -9
- package/dist/provider/AiProvider.d.ts +14 -2
- package/dist/provider/AiProvider.d.ts.map +1 -1
- package/dist/provider/AiProviderRegistry.d.ts +23 -0
- package/dist/provider/AiProviderRegistry.d.ts.map +1 -1
- package/dist/task/ChunkRetrievalTask.d.ts +1 -1
- package/dist/task/ChunkVectorSearchTask.d.ts +1 -1
- package/dist/task/ChunkVectorUpsertTask.d.ts +1 -1
- package/dist/task/ContextBuilderTask.d.ts +79 -4
- package/dist/task/ContextBuilderTask.d.ts.map +1 -1
- package/dist/task/CountTokensTask.d.ts +113 -0
- package/dist/task/CountTokensTask.d.ts.map +1 -0
- package/dist/task/HierarchicalChunkerTask.d.ts +66 -3
- package/dist/task/HierarchicalChunkerTask.d.ts.map +1 -1
- package/dist/task/HierarchyJoinTask.d.ts +1 -1
- package/dist/task/RerankerTask.d.ts +1 -1
- package/dist/task/base/AiTask.d.ts +9 -1
- package/dist/task/base/AiTask.d.ts.map +1 -1
- package/dist/task/index.d.ts +3 -1
- package/dist/task/index.d.ts.map +1 -1
- package/package.json +11 -11
package/dist/browser.js
CHANGED
|
@@ -12,6 +12,7 @@ import { globalServiceRegistry, WORKER_MANAGER } from "@workglow/util";
|
|
|
12
12
|
class AiProviderRegistry {
|
|
13
13
|
runFnRegistry = new Map;
|
|
14
14
|
streamFnRegistry = new Map;
|
|
15
|
+
reactiveRunFnRegistry = new Map;
|
|
15
16
|
providers = new Map;
|
|
16
17
|
registerProvider(provider) {
|
|
17
18
|
this.providers.set(provider.name, provider);
|
|
@@ -56,6 +57,27 @@ class AiProviderRegistry {
|
|
|
56
57
|
const taskTypeMap = this.streamFnRegistry.get(taskType);
|
|
57
58
|
return taskTypeMap?.get(modelProvider);
|
|
58
59
|
}
|
|
60
|
+
registerAsWorkerReactiveRunFn(modelProvider, taskType) {
|
|
61
|
+
const reactiveFn = async (input, output, model) => {
|
|
62
|
+
const workerManager = globalServiceRegistry.get(WORKER_MANAGER);
|
|
63
|
+
return workerManager.callWorkerReactiveFunction(modelProvider, taskType, [
|
|
64
|
+
input,
|
|
65
|
+
output,
|
|
66
|
+
model
|
|
67
|
+
]);
|
|
68
|
+
};
|
|
69
|
+
this.registerReactiveRunFn(modelProvider, taskType, reactiveFn);
|
|
70
|
+
}
|
|
71
|
+
registerReactiveRunFn(modelProvider, taskType, reactiveRunFn) {
|
|
72
|
+
if (!this.reactiveRunFnRegistry.has(taskType)) {
|
|
73
|
+
this.reactiveRunFnRegistry.set(taskType, new Map);
|
|
74
|
+
}
|
|
75
|
+
this.reactiveRunFnRegistry.get(taskType).set(modelProvider, reactiveRunFn);
|
|
76
|
+
}
|
|
77
|
+
getReactiveRunFn(modelProvider, taskType) {
|
|
78
|
+
const taskTypeMap = this.reactiveRunFnRegistry.get(taskType);
|
|
79
|
+
return taskTypeMap?.get(modelProvider);
|
|
80
|
+
}
|
|
59
81
|
getDirectRunFn(modelProvider, taskType) {
|
|
60
82
|
const taskTypeMap = this.runFnRegistry.get(taskType);
|
|
61
83
|
const runFn = taskTypeMap?.get(modelProvider);
|
|
@@ -307,9 +329,11 @@ async function createDefaultQueue(providerName, concurrency) {
|
|
|
307
329
|
class AiProvider {
|
|
308
330
|
tasks;
|
|
309
331
|
streamTasks;
|
|
310
|
-
|
|
332
|
+
reactiveTasks;
|
|
333
|
+
constructor(tasks, streamTasks, reactiveTasks) {
|
|
311
334
|
this.tasks = tasks;
|
|
312
335
|
this.streamTasks = streamTasks;
|
|
336
|
+
this.reactiveTasks = reactiveTasks;
|
|
313
337
|
}
|
|
314
338
|
get supportedTaskTypes() {
|
|
315
339
|
return this.taskTypes;
|
|
@@ -320,6 +344,9 @@ class AiProvider {
|
|
|
320
344
|
getStreamFn(taskType) {
|
|
321
345
|
return this.streamTasks?.[taskType];
|
|
322
346
|
}
|
|
347
|
+
getReactiveRunFn(taskType) {
|
|
348
|
+
return this.reactiveTasks?.[taskType];
|
|
349
|
+
}
|
|
323
350
|
async register(options = { mode: "inline" }) {
|
|
324
351
|
await this.onInitialize(options);
|
|
325
352
|
if (options.mode === "worker") {
|
|
@@ -338,6 +365,7 @@ class AiProvider {
|
|
|
338
365
|
for (const taskType of this.taskTypes) {
|
|
339
366
|
registry.registerAsWorkerRunFn(this.name, taskType);
|
|
340
367
|
registry.registerAsWorkerStreamFn(this.name, taskType);
|
|
368
|
+
registry.registerAsWorkerReactiveRunFn(this.name, taskType);
|
|
341
369
|
}
|
|
342
370
|
} else {
|
|
343
371
|
for (const [taskType, fn] of Object.entries(this.tasks)) {
|
|
@@ -349,6 +377,11 @@ class AiProvider {
|
|
|
349
377
|
}
|
|
350
378
|
}
|
|
351
379
|
}
|
|
380
|
+
if (this.reactiveTasks) {
|
|
381
|
+
for (const [taskType, fn] of Object.entries(this.reactiveTasks)) {
|
|
382
|
+
registry.registerReactiveRunFn(this.name, taskType, fn);
|
|
383
|
+
}
|
|
384
|
+
}
|
|
352
385
|
registry.registerProvider(this);
|
|
353
386
|
if (options.queue?.autoCreate !== false) {
|
|
354
387
|
await this.createQueue(options.queue?.concurrency ?? 1);
|
|
@@ -366,6 +399,11 @@ class AiProvider {
|
|
|
366
399
|
workerServer.registerStreamFunction(taskType, fn);
|
|
367
400
|
}
|
|
368
401
|
}
|
|
402
|
+
if (this.reactiveTasks) {
|
|
403
|
+
for (const [taskType, fn] of Object.entries(this.reactiveTasks)) {
|
|
404
|
+
workerServer.registerReactiveFunction(taskType, fn);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
369
407
|
}
|
|
370
408
|
async onInitialize(_options) {}
|
|
371
409
|
async dispose() {}
|
|
@@ -584,6 +622,17 @@ class AiTask extends JobQueueTask {
|
|
|
584
622
|
const model = input.model;
|
|
585
623
|
return model?.provider;
|
|
586
624
|
}
|
|
625
|
+
async executeReactive(input, output, context) {
|
|
626
|
+
const model = input.model;
|
|
627
|
+
if (model && typeof model === "object" && model.provider) {
|
|
628
|
+
const taskType = this.constructor.runtype ?? this.constructor.type;
|
|
629
|
+
const reactiveFn = getAiProviderRegistry().getReactiveRunFn(model.provider, taskType);
|
|
630
|
+
if (reactiveFn) {
|
|
631
|
+
return reactiveFn(input, output, model);
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
return super.executeReactive(input, output, context);
|
|
635
|
+
}
|
|
587
636
|
async validateInput(input) {
|
|
588
637
|
const inputSchema = this.inputSchema();
|
|
589
638
|
if (typeof inputSchema === "boolean") {
|
|
@@ -1494,7 +1543,61 @@ var chunkVectorUpsert = (input, config) => {
|
|
|
1494
1543
|
Workflow7.prototype.chunkVectorUpsert = CreateWorkflow7(ChunkVectorUpsertTask);
|
|
1495
1544
|
|
|
1496
1545
|
// src/task/ContextBuilderTask.ts
|
|
1497
|
-
import {
|
|
1546
|
+
import { estimateTokens } from "@workglow/dataset";
|
|
1547
|
+
import {
|
|
1548
|
+
CreateWorkflow as CreateWorkflow9,
|
|
1549
|
+
Task as Task6,
|
|
1550
|
+
Workflow as Workflow9
|
|
1551
|
+
} from "@workglow/task-graph";
|
|
1552
|
+
|
|
1553
|
+
// src/task/CountTokensTask.ts
|
|
1554
|
+
import { CreateWorkflow as CreateWorkflow8, Workflow as Workflow8 } from "@workglow/task-graph";
|
|
1555
|
+
var modelSchema3 = TypeModel("model");
|
|
1556
|
+
var CountTokensInputSchema = {
|
|
1557
|
+
type: "object",
|
|
1558
|
+
properties: {
|
|
1559
|
+
text: {
|
|
1560
|
+
type: "string",
|
|
1561
|
+
title: "Text",
|
|
1562
|
+
description: "The text to count tokens for"
|
|
1563
|
+
},
|
|
1564
|
+
model: modelSchema3
|
|
1565
|
+
},
|
|
1566
|
+
required: ["text", "model"],
|
|
1567
|
+
additionalProperties: false
|
|
1568
|
+
};
|
|
1569
|
+
var CountTokensOutputSchema = {
|
|
1570
|
+
type: "object",
|
|
1571
|
+
properties: {
|
|
1572
|
+
count: {
|
|
1573
|
+
type: "number",
|
|
1574
|
+
title: "Token Count",
|
|
1575
|
+
description: "The number of tokens in the text"
|
|
1576
|
+
}
|
|
1577
|
+
},
|
|
1578
|
+
required: ["count"],
|
|
1579
|
+
additionalProperties: false
|
|
1580
|
+
};
|
|
1581
|
+
|
|
1582
|
+
class CountTokensTask extends AiTask {
|
|
1583
|
+
static type = "CountTokensTask";
|
|
1584
|
+
static category = "AI Text Model";
|
|
1585
|
+
static title = "Count Tokens";
|
|
1586
|
+
static description = "Counts the number of tokens in a text string using the model's tokenizer";
|
|
1587
|
+
static cacheable = true;
|
|
1588
|
+
static inputSchema() {
|
|
1589
|
+
return CountTokensInputSchema;
|
|
1590
|
+
}
|
|
1591
|
+
static outputSchema() {
|
|
1592
|
+
return CountTokensOutputSchema;
|
|
1593
|
+
}
|
|
1594
|
+
}
|
|
1595
|
+
var countTokens = async (input, config) => {
|
|
1596
|
+
return new CountTokensTask({}, config).run(input);
|
|
1597
|
+
};
|
|
1598
|
+
Workflow8.prototype.countTokens = CreateWorkflow8(CountTokensTask);
|
|
1599
|
+
|
|
1600
|
+
// src/task/ContextBuilderTask.ts
|
|
1498
1601
|
var ContextFormat = {
|
|
1499
1602
|
SIMPLE: "simple",
|
|
1500
1603
|
NUMBERED: "numbered",
|
|
@@ -1502,6 +1605,10 @@ var ContextFormat = {
|
|
|
1502
1605
|
MARKDOWN: "markdown",
|
|
1503
1606
|
JSON: "json"
|
|
1504
1607
|
};
|
|
1608
|
+
var modelSchema4 = TypeModel("model", {
|
|
1609
|
+
title: "Model",
|
|
1610
|
+
description: "Model to use for token counting (optional, falls back to estimation)"
|
|
1611
|
+
});
|
|
1505
1612
|
var inputSchema6 = {
|
|
1506
1613
|
type: "object",
|
|
1507
1614
|
properties: {
|
|
@@ -1541,6 +1648,13 @@ var inputSchema6 = {
|
|
|
1541
1648
|
minimum: 0,
|
|
1542
1649
|
default: 0
|
|
1543
1650
|
},
|
|
1651
|
+
maxTokens: {
|
|
1652
|
+
type: "number",
|
|
1653
|
+
title: "Max Tokens",
|
|
1654
|
+
description: "Maximum number of tokens in context (0 = unlimited). Takes precedence over maxLength when set.",
|
|
1655
|
+
minimum: 0,
|
|
1656
|
+
default: 0
|
|
1657
|
+
},
|
|
1544
1658
|
includeMetadata: {
|
|
1545
1659
|
type: "boolean",
|
|
1546
1660
|
title: "Include Metadata",
|
|
@@ -1554,7 +1668,8 @@ var inputSchema6 = {
|
|
|
1554
1668
|
default: `
|
|
1555
1669
|
|
|
1556
1670
|
`
|
|
1557
|
-
}
|
|
1671
|
+
},
|
|
1672
|
+
model: modelSchema4
|
|
1558
1673
|
},
|
|
1559
1674
|
required: ["chunks"],
|
|
1560
1675
|
additionalProperties: false
|
|
@@ -1576,9 +1691,14 @@ var outputSchema6 = {
|
|
|
1576
1691
|
type: "number",
|
|
1577
1692
|
title: "Total Length",
|
|
1578
1693
|
description: "Total length of context in characters"
|
|
1694
|
+
},
|
|
1695
|
+
totalTokens: {
|
|
1696
|
+
type: "number",
|
|
1697
|
+
title: "Total Tokens",
|
|
1698
|
+
description: "Estimated token count of the context"
|
|
1579
1699
|
}
|
|
1580
1700
|
},
|
|
1581
|
-
required: ["context", "chunksUsed", "totalLength"],
|
|
1701
|
+
required: ["context", "chunksUsed", "totalLength", "totalTokens"],
|
|
1582
1702
|
additionalProperties: false
|
|
1583
1703
|
};
|
|
1584
1704
|
|
|
@@ -1594,49 +1714,77 @@ class ContextBuilderTask extends Task6 {
|
|
|
1594
1714
|
static outputSchema() {
|
|
1595
1715
|
return outputSchema6;
|
|
1596
1716
|
}
|
|
1597
|
-
async executeReactive(input,
|
|
1717
|
+
async executeReactive(input, _output, context) {
|
|
1598
1718
|
const {
|
|
1599
1719
|
chunks,
|
|
1600
1720
|
metadata = [],
|
|
1601
1721
|
scores = [],
|
|
1602
1722
|
format = ContextFormat.SIMPLE,
|
|
1603
1723
|
maxLength = 0,
|
|
1724
|
+
maxTokens = 0,
|
|
1604
1725
|
includeMetadata = false,
|
|
1605
1726
|
separator = `
|
|
1606
1727
|
|
|
1607
1728
|
`
|
|
1608
1729
|
} = input;
|
|
1609
|
-
let
|
|
1730
|
+
let countFn = async (text) => estimateTokens(text);
|
|
1731
|
+
if (input.model) {
|
|
1732
|
+
const countTask = context.own(new CountTokensTask({ model: input.model }));
|
|
1733
|
+
countFn = async (text) => {
|
|
1734
|
+
try {
|
|
1735
|
+
const result = await countTask.run({ text });
|
|
1736
|
+
return result.count;
|
|
1737
|
+
} catch (_err) {
|
|
1738
|
+
return estimateTokens(text);
|
|
1739
|
+
}
|
|
1740
|
+
};
|
|
1741
|
+
}
|
|
1742
|
+
const useTokenBudget = maxTokens > 0;
|
|
1743
|
+
let ctx = "";
|
|
1610
1744
|
let chunksUsed = 0;
|
|
1611
1745
|
for (let i = 0;i < chunks.length; i++) {
|
|
1612
1746
|
const chunk = chunks[i];
|
|
1613
1747
|
const meta = metadata[i];
|
|
1614
1748
|
const score = scores[i];
|
|
1615
1749
|
let formattedChunk = this.formatChunk(chunk, meta, score, i, format, includeMetadata);
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1750
|
+
const prefix = chunksUsed > 0 ? separator : "";
|
|
1751
|
+
const candidate = ctx + prefix + formattedChunk;
|
|
1752
|
+
if (useTokenBudget) {
|
|
1753
|
+
if (await countFn(candidate) > maxTokens) {
|
|
1619
1754
|
if (chunksUsed === 0) {
|
|
1620
|
-
|
|
1621
|
-
|
|
1755
|
+
let truncated = formattedChunk;
|
|
1756
|
+
while (truncated.length > 10 && await countFn(truncated) > maxTokens) {
|
|
1757
|
+
truncated = truncated.substring(0, Math.floor(truncated.length * 0.9));
|
|
1758
|
+
}
|
|
1759
|
+
if (truncated.length > 10) {
|
|
1760
|
+
ctx = truncated.substring(0, truncated.length - 3) + "...";
|
|
1761
|
+
chunksUsed++;
|
|
1762
|
+
}
|
|
1763
|
+
}
|
|
1764
|
+
break;
|
|
1765
|
+
}
|
|
1766
|
+
} else if (maxLength > 0) {
|
|
1767
|
+
if (candidate.length > maxLength) {
|
|
1768
|
+
if (chunksUsed === 0) {
|
|
1769
|
+
const available = maxLength - ctx.length;
|
|
1770
|
+
if (available > 10) {
|
|
1622
1771
|
formattedChunk = formattedChunk.substring(0, available - 3) + "...";
|
|
1623
|
-
|
|
1772
|
+
ctx += formattedChunk;
|
|
1624
1773
|
chunksUsed++;
|
|
1625
1774
|
}
|
|
1626
1775
|
}
|
|
1627
1776
|
break;
|
|
1628
1777
|
}
|
|
1629
1778
|
}
|
|
1630
|
-
|
|
1631
|
-
context += separator;
|
|
1632
|
-
}
|
|
1633
|
-
context += formattedChunk;
|
|
1779
|
+
ctx = candidate;
|
|
1634
1780
|
chunksUsed++;
|
|
1635
1781
|
}
|
|
1782
|
+
const totalTokens = await countFn(ctx);
|
|
1636
1783
|
return {
|
|
1637
|
-
context,
|
|
1784
|
+
context: ctx,
|
|
1638
1785
|
chunksUsed,
|
|
1639
|
-
totalLength:
|
|
1786
|
+
totalLength: ctx.length,
|
|
1787
|
+
totalTokens
|
|
1640
1788
|
};
|
|
1641
1789
|
}
|
|
1642
1790
|
formatChunk(chunk, metadata, score, index, format, includeMetadata) {
|
|
@@ -1747,7 +1895,7 @@ class ContextBuilderTask extends Task6 {
|
|
|
1747
1895
|
var contextBuilder = (input, config) => {
|
|
1748
1896
|
return new ContextBuilderTask({}, config).run(input);
|
|
1749
1897
|
};
|
|
1750
|
-
|
|
1898
|
+
Workflow9.prototype.contextBuilder = CreateWorkflow9(ContextBuilderTask);
|
|
1751
1899
|
|
|
1752
1900
|
// src/task/DocumentEnricherTask.ts
|
|
1753
1901
|
import {
|
|
@@ -1755,14 +1903,14 @@ import {
|
|
|
1755
1903
|
hasChildren
|
|
1756
1904
|
} from "@workglow/dataset";
|
|
1757
1905
|
import {
|
|
1758
|
-
CreateWorkflow as
|
|
1906
|
+
CreateWorkflow as CreateWorkflow12,
|
|
1759
1907
|
Task as Task7,
|
|
1760
|
-
Workflow as
|
|
1908
|
+
Workflow as Workflow12
|
|
1761
1909
|
} from "@workglow/task-graph";
|
|
1762
1910
|
|
|
1763
1911
|
// src/task/TextNamedEntityRecognitionTask.ts
|
|
1764
|
-
import { CreateWorkflow as
|
|
1765
|
-
var
|
|
1912
|
+
import { CreateWorkflow as CreateWorkflow10, Workflow as Workflow10 } from "@workglow/task-graph";
|
|
1913
|
+
var modelSchema5 = TypeModel("model:TextNamedEntityRecognitionTask");
|
|
1766
1914
|
var TextNamedEntityRecognitionInputSchema = {
|
|
1767
1915
|
type: "object",
|
|
1768
1916
|
properties: {
|
|
@@ -1781,7 +1929,7 @@ var TextNamedEntityRecognitionInputSchema = {
|
|
|
1781
1929
|
"x-ui-group": "Configuration",
|
|
1782
1930
|
"x-ui-group-open": false
|
|
1783
1931
|
},
|
|
1784
|
-
model:
|
|
1932
|
+
model: modelSchema5
|
|
1785
1933
|
},
|
|
1786
1934
|
required: ["text", "model"],
|
|
1787
1935
|
additionalProperties: false
|
|
@@ -1836,10 +1984,10 @@ class TextNamedEntityRecognitionTask extends AiTask {
|
|
|
1836
1984
|
var textNamedEntityRecognition = (input, config) => {
|
|
1837
1985
|
return new TextNamedEntityRecognitionTask({}, config).run(input);
|
|
1838
1986
|
};
|
|
1839
|
-
|
|
1987
|
+
Workflow10.prototype.textNamedEntityRecognition = CreateWorkflow10(TextNamedEntityRecognitionTask);
|
|
1840
1988
|
|
|
1841
1989
|
// src/task/TextSummaryTask.ts
|
|
1842
|
-
import { CreateWorkflow as
|
|
1990
|
+
import { CreateWorkflow as CreateWorkflow11, Workflow as Workflow11 } from "@workglow/task-graph";
|
|
1843
1991
|
|
|
1844
1992
|
// src/task/base/StreamingAiTask.ts
|
|
1845
1993
|
import {
|
|
@@ -1871,7 +2019,7 @@ class StreamingAiTask extends AiTask {
|
|
|
1871
2019
|
}
|
|
1872
2020
|
|
|
1873
2021
|
// src/task/TextSummaryTask.ts
|
|
1874
|
-
var
|
|
2022
|
+
var modelSchema6 = TypeModel("model:TextSummaryTask");
|
|
1875
2023
|
var TextSummaryInputSchema = {
|
|
1876
2024
|
type: "object",
|
|
1877
2025
|
properties: {
|
|
@@ -1880,7 +2028,7 @@ var TextSummaryInputSchema = {
|
|
|
1880
2028
|
title: "Text",
|
|
1881
2029
|
description: "The text to summarize"
|
|
1882
2030
|
},
|
|
1883
|
-
model:
|
|
2031
|
+
model: modelSchema6
|
|
1884
2032
|
},
|
|
1885
2033
|
required: ["text", "model"],
|
|
1886
2034
|
additionalProperties: false
|
|
@@ -1914,7 +2062,7 @@ class TextSummaryTask extends StreamingAiTask {
|
|
|
1914
2062
|
var textSummary = async (input, config) => {
|
|
1915
2063
|
return new TextSummaryTask({}, config).run(input);
|
|
1916
2064
|
};
|
|
1917
|
-
|
|
2065
|
+
Workflow11.prototype.textSummary = CreateWorkflow11(TextSummaryTask);
|
|
1918
2066
|
|
|
1919
2067
|
// src/task/DocumentEnricherTask.ts
|
|
1920
2068
|
var inputSchema7 = {
|
|
@@ -2145,15 +2293,15 @@ class DocumentEnricherTask extends Task7 {
|
|
|
2145
2293
|
var documentEnricher = (input, config) => {
|
|
2146
2294
|
return new DocumentEnricherTask({}, config).run(input);
|
|
2147
2295
|
};
|
|
2148
|
-
|
|
2296
|
+
Workflow12.prototype.documentEnricher = CreateWorkflow12(DocumentEnricherTask);
|
|
2149
2297
|
|
|
2150
2298
|
// src/task/DownloadModelTask.ts
|
|
2151
|
-
import { CreateWorkflow as
|
|
2152
|
-
var
|
|
2299
|
+
import { CreateWorkflow as CreateWorkflow13, Workflow as Workflow13 } from "@workglow/task-graph";
|
|
2300
|
+
var modelSchema7 = TypeModel("model");
|
|
2153
2301
|
var DownloadModelInputSchema = {
|
|
2154
2302
|
type: "object",
|
|
2155
2303
|
properties: {
|
|
2156
|
-
model:
|
|
2304
|
+
model: modelSchema7
|
|
2157
2305
|
},
|
|
2158
2306
|
required: ["model"],
|
|
2159
2307
|
additionalProperties: false
|
|
@@ -2161,7 +2309,7 @@ var DownloadModelInputSchema = {
|
|
|
2161
2309
|
var DownloadModelOutputSchema = {
|
|
2162
2310
|
type: "object",
|
|
2163
2311
|
properties: {
|
|
2164
|
-
model:
|
|
2312
|
+
model: modelSchema7
|
|
2165
2313
|
},
|
|
2166
2314
|
required: ["model"],
|
|
2167
2315
|
additionalProperties: false
|
|
@@ -2204,11 +2352,11 @@ class DownloadModelTask extends AiTask {
|
|
|
2204
2352
|
var downloadModel = (input, config) => {
|
|
2205
2353
|
return new DownloadModelTask({}, config).run(input);
|
|
2206
2354
|
};
|
|
2207
|
-
|
|
2355
|
+
Workflow13.prototype.downloadModel = CreateWorkflow13(DownloadModelTask);
|
|
2208
2356
|
|
|
2209
2357
|
// src/task/FaceDetectorTask.ts
|
|
2210
|
-
import { CreateWorkflow as
|
|
2211
|
-
var
|
|
2358
|
+
import { CreateWorkflow as CreateWorkflow14, Workflow as Workflow14 } from "@workglow/task-graph";
|
|
2359
|
+
var modelSchema8 = TypeModel("model:FaceDetectorTask");
|
|
2212
2360
|
var TypeBoundingBox2 = {
|
|
2213
2361
|
type: "object",
|
|
2214
2362
|
properties: {
|
|
@@ -2281,7 +2429,7 @@ var FaceDetectorInputSchema = {
|
|
|
2281
2429
|
type: "object",
|
|
2282
2430
|
properties: {
|
|
2283
2431
|
image: TypeImageInput,
|
|
2284
|
-
model:
|
|
2432
|
+
model: modelSchema8,
|
|
2285
2433
|
minDetectionConfidence: {
|
|
2286
2434
|
type: "number",
|
|
2287
2435
|
minimum: 0,
|
|
@@ -2335,11 +2483,11 @@ class FaceDetectorTask extends AiVisionTask {
|
|
|
2335
2483
|
var faceDetector = (input, config) => {
|
|
2336
2484
|
return new FaceDetectorTask({}, config).run(input);
|
|
2337
2485
|
};
|
|
2338
|
-
|
|
2486
|
+
Workflow14.prototype.faceDetector = CreateWorkflow14(FaceDetectorTask);
|
|
2339
2487
|
|
|
2340
2488
|
// src/task/FaceLandmarkerTask.ts
|
|
2341
|
-
import { CreateWorkflow as
|
|
2342
|
-
var
|
|
2489
|
+
import { CreateWorkflow as CreateWorkflow15, Workflow as Workflow15 } from "@workglow/task-graph";
|
|
2490
|
+
var modelSchema9 = TypeModel("model:FaceLandmarkerTask");
|
|
2343
2491
|
var TypeLandmark = {
|
|
2344
2492
|
type: "object",
|
|
2345
2493
|
properties: {
|
|
@@ -2411,7 +2559,7 @@ var FaceLandmarkerInputSchema = {
|
|
|
2411
2559
|
type: "object",
|
|
2412
2560
|
properties: {
|
|
2413
2561
|
image: TypeImageInput,
|
|
2414
|
-
model:
|
|
2562
|
+
model: modelSchema9,
|
|
2415
2563
|
numFaces: {
|
|
2416
2564
|
type: "number",
|
|
2417
2565
|
minimum: 1,
|
|
@@ -2497,11 +2645,11 @@ class FaceLandmarkerTask extends AiVisionTask {
|
|
|
2497
2645
|
var faceLandmarker = (input, config) => {
|
|
2498
2646
|
return new FaceLandmarkerTask({}, config).run(input);
|
|
2499
2647
|
};
|
|
2500
|
-
|
|
2648
|
+
Workflow15.prototype.faceLandmarker = CreateWorkflow15(FaceLandmarkerTask);
|
|
2501
2649
|
|
|
2502
2650
|
// src/task/GestureRecognizerTask.ts
|
|
2503
|
-
import { CreateWorkflow as
|
|
2504
|
-
var
|
|
2651
|
+
import { CreateWorkflow as CreateWorkflow16, Workflow as Workflow16 } from "@workglow/task-graph";
|
|
2652
|
+
var modelSchema10 = TypeModel("model:GestureRecognizerTask");
|
|
2505
2653
|
var TypeLandmark2 = {
|
|
2506
2654
|
type: "object",
|
|
2507
2655
|
properties: {
|
|
@@ -2593,7 +2741,7 @@ var GestureRecognizerInputSchema = {
|
|
|
2593
2741
|
type: "object",
|
|
2594
2742
|
properties: {
|
|
2595
2743
|
image: TypeImageInput,
|
|
2596
|
-
model:
|
|
2744
|
+
model: modelSchema10,
|
|
2597
2745
|
numHands: {
|
|
2598
2746
|
type: "number",
|
|
2599
2747
|
minimum: 1,
|
|
@@ -2665,11 +2813,11 @@ class GestureRecognizerTask extends AiVisionTask {
|
|
|
2665
2813
|
var gestureRecognizer = (input, config) => {
|
|
2666
2814
|
return new GestureRecognizerTask({}, config).run(input);
|
|
2667
2815
|
};
|
|
2668
|
-
|
|
2816
|
+
Workflow16.prototype.gestureRecognizer = CreateWorkflow16(GestureRecognizerTask);
|
|
2669
2817
|
|
|
2670
2818
|
// src/task/HandLandmarkerTask.ts
|
|
2671
|
-
import { CreateWorkflow as
|
|
2672
|
-
var
|
|
2819
|
+
import { CreateWorkflow as CreateWorkflow17, Workflow as Workflow17 } from "@workglow/task-graph";
|
|
2820
|
+
var modelSchema11 = TypeModel("model:HandLandmarkerTask");
|
|
2673
2821
|
var TypeLandmark3 = {
|
|
2674
2822
|
type: "object",
|
|
2675
2823
|
properties: {
|
|
@@ -2738,7 +2886,7 @@ var HandLandmarkerInputSchema = {
|
|
|
2738
2886
|
type: "object",
|
|
2739
2887
|
properties: {
|
|
2740
2888
|
image: TypeImageInput,
|
|
2741
|
-
model:
|
|
2889
|
+
model: modelSchema11,
|
|
2742
2890
|
numHands: {
|
|
2743
2891
|
type: "number",
|
|
2744
2892
|
minimum: 1,
|
|
@@ -2810,21 +2958,25 @@ class HandLandmarkerTask extends AiVisionTask {
|
|
|
2810
2958
|
var handLandmarker = (input, config) => {
|
|
2811
2959
|
return new HandLandmarkerTask({}, config).run(input);
|
|
2812
2960
|
};
|
|
2813
|
-
|
|
2961
|
+
Workflow17.prototype.handLandmarker = CreateWorkflow17(HandLandmarkerTask);
|
|
2814
2962
|
|
|
2815
2963
|
// src/task/HierarchicalChunkerTask.ts
|
|
2816
2964
|
import {
|
|
2817
2965
|
ChunkNodeSchema as ChunkNodeSchema2,
|
|
2818
|
-
estimateTokens,
|
|
2966
|
+
estimateTokens as estimateTokens2,
|
|
2819
2967
|
getChildren as getChildren2,
|
|
2820
2968
|
hasChildren as hasChildren2
|
|
2821
2969
|
} from "@workglow/dataset";
|
|
2822
2970
|
import {
|
|
2823
|
-
CreateWorkflow as
|
|
2971
|
+
CreateWorkflow as CreateWorkflow18,
|
|
2824
2972
|
Task as Task8,
|
|
2825
|
-
Workflow as
|
|
2973
|
+
Workflow as Workflow18
|
|
2826
2974
|
} from "@workglow/task-graph";
|
|
2827
2975
|
import { uuid4 } from "@workglow/util";
|
|
2976
|
+
var modelSchema12 = TypeModel("model", {
|
|
2977
|
+
title: "Model",
|
|
2978
|
+
description: "Model to use for token counting"
|
|
2979
|
+
});
|
|
2828
2980
|
var inputSchema8 = {
|
|
2829
2981
|
type: "object",
|
|
2830
2982
|
properties: {
|
|
@@ -2864,9 +3016,10 @@ var inputSchema8 = {
|
|
|
2864
3016
|
title: "Chunking Strategy",
|
|
2865
3017
|
description: "Strategy for chunking",
|
|
2866
3018
|
default: "hierarchical"
|
|
2867
|
-
}
|
|
3019
|
+
},
|
|
3020
|
+
model: modelSchema12
|
|
2868
3021
|
},
|
|
2869
|
-
required: [],
|
|
3022
|
+
required: ["doc_id", "documentTree"],
|
|
2870
3023
|
additionalProperties: false
|
|
2871
3024
|
};
|
|
2872
3025
|
var outputSchema8 = {
|
|
@@ -2932,11 +3085,23 @@ class HierarchicalChunkerTask extends Task8 {
|
|
|
2932
3085
|
overlapTokens: overlap,
|
|
2933
3086
|
reservedTokens
|
|
2934
3087
|
};
|
|
3088
|
+
let countFn = async (text) => estimateTokens2(text);
|
|
3089
|
+
if (input.model) {
|
|
3090
|
+
const countTask = context.own(new CountTokensTask({ model: input.model }));
|
|
3091
|
+
countFn = async (text) => {
|
|
3092
|
+
try {
|
|
3093
|
+
const result = await countTask.run({ text });
|
|
3094
|
+
return result.count;
|
|
3095
|
+
} catch (_err) {
|
|
3096
|
+
return estimateTokens2(text);
|
|
3097
|
+
}
|
|
3098
|
+
};
|
|
3099
|
+
}
|
|
2935
3100
|
const chunks = [];
|
|
2936
3101
|
if (strategy === "hierarchical") {
|
|
2937
|
-
await this.chunkHierarchically(root, [], doc_id, tokenBudget, chunks);
|
|
3102
|
+
await this.chunkHierarchically(root, [], doc_id, tokenBudget, chunks, countFn);
|
|
2938
3103
|
} else {
|
|
2939
|
-
await this.chunkFlat(root, doc_id, tokenBudget, chunks);
|
|
3104
|
+
await this.chunkFlat(root, doc_id, tokenBudget, chunks, countFn);
|
|
2940
3105
|
}
|
|
2941
3106
|
return {
|
|
2942
3107
|
doc_id,
|
|
@@ -2945,24 +3110,30 @@ class HierarchicalChunkerTask extends Task8 {
|
|
|
2945
3110
|
count: chunks.length
|
|
2946
3111
|
};
|
|
2947
3112
|
}
|
|
2948
|
-
async chunkHierarchically(node, nodePath, doc_id, tokenBudget, chunks) {
|
|
3113
|
+
async chunkHierarchically(node, nodePath, doc_id, tokenBudget, chunks, countFn) {
|
|
2949
3114
|
const currentPath = [...nodePath, node.nodeId];
|
|
2950
3115
|
if (!hasChildren2(node)) {
|
|
2951
|
-
await this.chunkText(node.text, currentPath, doc_id, tokenBudget, chunks, node.nodeId);
|
|
3116
|
+
await this.chunkText(node.text, currentPath, doc_id, tokenBudget, chunks, node.nodeId, countFn);
|
|
2952
3117
|
return;
|
|
2953
3118
|
}
|
|
2954
3119
|
const children = getChildren2(node);
|
|
2955
3120
|
for (const child of children) {
|
|
2956
|
-
await this.chunkHierarchically(child, currentPath, doc_id, tokenBudget, chunks);
|
|
3121
|
+
await this.chunkHierarchically(child, currentPath, doc_id, tokenBudget, chunks, countFn);
|
|
2957
3122
|
}
|
|
2958
3123
|
}
|
|
2959
|
-
async chunkText(text, nodePath, doc_id, tokenBudget, chunks, leafNodeId) {
|
|
2960
|
-
const
|
|
2961
|
-
const
|
|
2962
|
-
if (
|
|
2963
|
-
|
|
3124
|
+
async chunkText(text, nodePath, doc_id, tokenBudget, chunks, leafNodeId, countFn) {
|
|
3125
|
+
const maxTokens = tokenBudget.maxTokensPerChunk - tokenBudget.reservedTokens;
|
|
3126
|
+
const overlapTokens = tokenBudget.overlapTokens;
|
|
3127
|
+
if (maxTokens <= 0) {
|
|
3128
|
+
throw new Error(`Invalid token budget: reservedTokens (${tokenBudget.reservedTokens}) must be less than maxTokensPerChunk (${tokenBudget.maxTokensPerChunk})`);
|
|
3129
|
+
}
|
|
3130
|
+
if (overlapTokens >= maxTokens) {
|
|
3131
|
+
throw new Error(`Invalid token budget: overlapTokens (${overlapTokens}) must be less than effective maxTokens (${maxTokens})`);
|
|
3132
|
+
}
|
|
3133
|
+
const count = await countFn(text);
|
|
3134
|
+
if (count <= maxTokens) {
|
|
2964
3135
|
chunks.push({
|
|
2965
|
-
chunkId,
|
|
3136
|
+
chunkId: uuid4(),
|
|
2966
3137
|
doc_id,
|
|
2967
3138
|
text,
|
|
2968
3139
|
nodePath,
|
|
@@ -2970,29 +3141,40 @@ class HierarchicalChunkerTask extends Task8 {
|
|
|
2970
3141
|
});
|
|
2971
3142
|
return;
|
|
2972
3143
|
}
|
|
2973
|
-
|
|
3144
|
+
const findCharBoundary = async (startChar, targetTokens) => {
|
|
3145
|
+
let lo = startChar;
|
|
3146
|
+
let hi = Math.min(startChar + targetTokens * 6, text.length);
|
|
3147
|
+
while (lo < hi) {
|
|
3148
|
+
const mid = Math.ceil((lo + hi) / 2);
|
|
3149
|
+
const count2 = await countFn(text.substring(startChar, mid));
|
|
3150
|
+
if (count2 <= targetTokens) {
|
|
3151
|
+
lo = mid;
|
|
3152
|
+
} else {
|
|
3153
|
+
hi = mid - 1;
|
|
3154
|
+
}
|
|
3155
|
+
}
|
|
3156
|
+
return lo;
|
|
3157
|
+
};
|
|
2974
3158
|
let startOffset = 0;
|
|
2975
3159
|
while (startOffset < text.length) {
|
|
2976
|
-
const
|
|
2977
|
-
const
|
|
2978
|
-
const chunkId = uuid4();
|
|
3160
|
+
const boundary = await findCharBoundary(startOffset, maxTokens);
|
|
3161
|
+
const endOffset = Math.max(Math.min(boundary, text.length), startOffset + 1);
|
|
2979
3162
|
chunks.push({
|
|
2980
|
-
chunkId,
|
|
3163
|
+
chunkId: uuid4(),
|
|
2981
3164
|
doc_id,
|
|
2982
|
-
text:
|
|
3165
|
+
text: text.substring(startOffset, endOffset),
|
|
2983
3166
|
nodePath,
|
|
2984
3167
|
depth: nodePath.length
|
|
2985
3168
|
});
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
}
|
|
3169
|
+
if (endOffset >= text.length)
|
|
3170
|
+
break;
|
|
3171
|
+
const nextStart = await findCharBoundary(startOffset, maxTokens - overlapTokens);
|
|
3172
|
+
startOffset = nextStart > startOffset ? nextStart : endOffset;
|
|
2991
3173
|
}
|
|
2992
3174
|
}
|
|
2993
|
-
async chunkFlat(root, doc_id, tokenBudget, chunks) {
|
|
3175
|
+
async chunkFlat(root, doc_id, tokenBudget, chunks, countFn) {
|
|
2994
3176
|
const allText = this.collectAllText(root);
|
|
2995
|
-
await this.chunkText(allText, [root.nodeId], doc_id, tokenBudget, chunks, root.nodeId);
|
|
3177
|
+
await this.chunkText(allText, [root.nodeId], doc_id, tokenBudget, chunks, root.nodeId, countFn);
|
|
2996
3178
|
}
|
|
2997
3179
|
collectAllText(node) {
|
|
2998
3180
|
const texts = [];
|
|
@@ -3014,7 +3196,7 @@ class HierarchicalChunkerTask extends Task8 {
|
|
|
3014
3196
|
var hierarchicalChunker = (input, config) => {
|
|
3015
3197
|
return new HierarchicalChunkerTask({}, config).run(input);
|
|
3016
3198
|
};
|
|
3017
|
-
|
|
3199
|
+
Workflow18.prototype.hierarchicalChunker = CreateWorkflow18(HierarchicalChunkerTask);
|
|
3018
3200
|
|
|
3019
3201
|
// src/task/HierarchyJoinTask.ts
|
|
3020
3202
|
import {
|
|
@@ -3023,9 +3205,9 @@ import {
|
|
|
3023
3205
|
TypeDocumentDataset
|
|
3024
3206
|
} from "@workglow/dataset";
|
|
3025
3207
|
import {
|
|
3026
|
-
CreateWorkflow as
|
|
3208
|
+
CreateWorkflow as CreateWorkflow19,
|
|
3027
3209
|
Task as Task9,
|
|
3028
|
-
Workflow as
|
|
3210
|
+
Workflow as Workflow19
|
|
3029
3211
|
} from "@workglow/task-graph";
|
|
3030
3212
|
var inputSchema9 = {
|
|
3031
3213
|
type: "object",
|
|
@@ -3195,16 +3377,16 @@ class HierarchyJoinTask extends Task9 {
|
|
|
3195
3377
|
var hierarchyJoin = (input, config) => {
|
|
3196
3378
|
return new HierarchyJoinTask({}, config).run(input);
|
|
3197
3379
|
};
|
|
3198
|
-
|
|
3380
|
+
Workflow19.prototype.hierarchyJoin = CreateWorkflow19(HierarchyJoinTask);
|
|
3199
3381
|
|
|
3200
3382
|
// src/task/ImageClassificationTask.ts
|
|
3201
|
-
import { CreateWorkflow as
|
|
3202
|
-
var
|
|
3383
|
+
import { CreateWorkflow as CreateWorkflow20, Workflow as Workflow20 } from "@workglow/task-graph";
|
|
3384
|
+
var modelSchema13 = TypeModel("model:ImageClassificationTask");
|
|
3203
3385
|
var ImageClassificationInputSchema = {
|
|
3204
3386
|
type: "object",
|
|
3205
3387
|
properties: {
|
|
3206
3388
|
image: TypeImageInput,
|
|
3207
|
-
model:
|
|
3389
|
+
model: modelSchema13,
|
|
3208
3390
|
categories: {
|
|
3209
3391
|
type: "array",
|
|
3210
3392
|
items: {
|
|
@@ -3258,14 +3440,14 @@ class ImageClassificationTask extends AiVisionTask {
|
|
|
3258
3440
|
var imageClassification = (input, config) => {
|
|
3259
3441
|
return new ImageClassificationTask({}, config).run(input);
|
|
3260
3442
|
};
|
|
3261
|
-
|
|
3443
|
+
Workflow20.prototype.imageClassification = CreateWorkflow20(ImageClassificationTask);
|
|
3262
3444
|
|
|
3263
3445
|
// src/task/ImageEmbeddingTask.ts
|
|
3264
|
-
import { CreateWorkflow as
|
|
3446
|
+
import { CreateWorkflow as CreateWorkflow21, Workflow as Workflow21 } from "@workglow/task-graph";
|
|
3265
3447
|
import {
|
|
3266
3448
|
TypedArraySchema as TypedArraySchema7
|
|
3267
3449
|
} from "@workglow/util";
|
|
3268
|
-
var
|
|
3450
|
+
var modelSchema14 = TypeModel("model:ImageEmbeddingTask");
|
|
3269
3451
|
var embeddingSchema = TypedArraySchema7({
|
|
3270
3452
|
title: "Embedding",
|
|
3271
3453
|
description: "The image embedding vector"
|
|
@@ -3274,7 +3456,7 @@ var ImageEmbeddingInputSchema = {
|
|
|
3274
3456
|
type: "object",
|
|
3275
3457
|
properties: {
|
|
3276
3458
|
image: TypeImageInput,
|
|
3277
|
-
model:
|
|
3459
|
+
model: modelSchema14
|
|
3278
3460
|
},
|
|
3279
3461
|
required: ["image", "model"],
|
|
3280
3462
|
additionalProperties: false
|
|
@@ -3303,16 +3485,16 @@ class ImageEmbeddingTask extends AiVisionTask {
|
|
|
3303
3485
|
var imageEmbedding = (input, config) => {
|
|
3304
3486
|
return new ImageEmbeddingTask({}, config).run(input);
|
|
3305
3487
|
};
|
|
3306
|
-
|
|
3488
|
+
Workflow21.prototype.imageEmbedding = CreateWorkflow21(ImageEmbeddingTask);
|
|
3307
3489
|
|
|
3308
3490
|
// src/task/ImageSegmentationTask.ts
|
|
3309
|
-
import { CreateWorkflow as
|
|
3310
|
-
var
|
|
3491
|
+
import { CreateWorkflow as CreateWorkflow22, Workflow as Workflow22 } from "@workglow/task-graph";
|
|
3492
|
+
var modelSchema15 = TypeModel("model:ImageSegmentationTask");
|
|
3311
3493
|
var ImageSegmentationInputSchema = {
|
|
3312
3494
|
type: "object",
|
|
3313
3495
|
properties: {
|
|
3314
3496
|
image: TypeImageInput,
|
|
3315
|
-
model:
|
|
3497
|
+
model: modelSchema15,
|
|
3316
3498
|
threshold: {
|
|
3317
3499
|
type: "number",
|
|
3318
3500
|
title: "Threshold",
|
|
@@ -3391,11 +3573,11 @@ class ImageSegmentationTask extends AiVisionTask {
|
|
|
3391
3573
|
var imageSegmentation = (input, config) => {
|
|
3392
3574
|
return new ImageSegmentationTask({}, config).run(input);
|
|
3393
3575
|
};
|
|
3394
|
-
|
|
3576
|
+
Workflow22.prototype.imageSegmentation = CreateWorkflow22(ImageSegmentationTask);
|
|
3395
3577
|
|
|
3396
3578
|
// src/task/ImageToTextTask.ts
|
|
3397
|
-
import { CreateWorkflow as
|
|
3398
|
-
var
|
|
3579
|
+
import { CreateWorkflow as CreateWorkflow23, Workflow as Workflow23 } from "@workglow/task-graph";
|
|
3580
|
+
var modelSchema16 = TypeModel("model:ImageToTextTask");
|
|
3399
3581
|
var generatedTextSchema = {
|
|
3400
3582
|
type: "string",
|
|
3401
3583
|
title: "Text",
|
|
@@ -3405,7 +3587,7 @@ var ImageToTextInputSchema = {
|
|
|
3405
3587
|
type: "object",
|
|
3406
3588
|
properties: {
|
|
3407
3589
|
image: TypeImageInput,
|
|
3408
|
-
model:
|
|
3590
|
+
model: modelSchema16,
|
|
3409
3591
|
maxTokens: {
|
|
3410
3592
|
type: "number",
|
|
3411
3593
|
title: "Max Tokens",
|
|
@@ -3446,11 +3628,11 @@ class ImageToTextTask extends AiVisionTask {
|
|
|
3446
3628
|
var imageToText = (input, config) => {
|
|
3447
3629
|
return new ImageToTextTask({}, config).run(input);
|
|
3448
3630
|
};
|
|
3449
|
-
|
|
3631
|
+
Workflow23.prototype.imageToText = CreateWorkflow23(ImageToTextTask);
|
|
3450
3632
|
|
|
3451
3633
|
// src/task/ObjectDetectionTask.ts
|
|
3452
|
-
import { CreateWorkflow as
|
|
3453
|
-
var
|
|
3634
|
+
import { CreateWorkflow as CreateWorkflow24, Workflow as Workflow24 } from "@workglow/task-graph";
|
|
3635
|
+
var modelSchema17 = TypeModel("model:ObjectDetectionTask");
|
|
3454
3636
|
var detectionSchema = {
|
|
3455
3637
|
type: "object",
|
|
3456
3638
|
properties: {
|
|
@@ -3475,7 +3657,7 @@ var ObjectDetectionInputSchema = {
|
|
|
3475
3657
|
type: "object",
|
|
3476
3658
|
properties: {
|
|
3477
3659
|
image: TypeImageInput,
|
|
3478
|
-
model:
|
|
3660
|
+
model: modelSchema17,
|
|
3479
3661
|
labels: {
|
|
3480
3662
|
type: "array",
|
|
3481
3663
|
items: {
|
|
@@ -3529,11 +3711,11 @@ class ObjectDetectionTask extends AiVisionTask {
|
|
|
3529
3711
|
var objectDetection = (input, config) => {
|
|
3530
3712
|
return new ObjectDetectionTask({}, config).run(input);
|
|
3531
3713
|
};
|
|
3532
|
-
|
|
3714
|
+
Workflow24.prototype.objectDetection = CreateWorkflow24(ObjectDetectionTask);
|
|
3533
3715
|
|
|
3534
3716
|
// src/task/PoseLandmarkerTask.ts
|
|
3535
|
-
import { CreateWorkflow as
|
|
3536
|
-
var
|
|
3717
|
+
import { CreateWorkflow as CreateWorkflow25, Workflow as Workflow25 } from "@workglow/task-graph";
|
|
3718
|
+
var modelSchema18 = TypeModel("model:PoseLandmarkerTask");
|
|
3537
3719
|
var TypePoseLandmark = {
|
|
3538
3720
|
type: "object",
|
|
3539
3721
|
properties: {
|
|
@@ -3612,7 +3794,7 @@ var PoseLandmarkerInputSchema = {
|
|
|
3612
3794
|
type: "object",
|
|
3613
3795
|
properties: {
|
|
3614
3796
|
image: TypeImageInput,
|
|
3615
|
-
model:
|
|
3797
|
+
model: modelSchema18,
|
|
3616
3798
|
numPoses: {
|
|
3617
3799
|
type: "number",
|
|
3618
3800
|
minimum: 1,
|
|
@@ -3691,13 +3873,13 @@ class PoseLandmarkerTask extends AiVisionTask {
|
|
|
3691
3873
|
var poseLandmarker = (input, config) => {
|
|
3692
3874
|
return new PoseLandmarkerTask({}, config).run(input);
|
|
3693
3875
|
};
|
|
3694
|
-
|
|
3876
|
+
Workflow25.prototype.poseLandmarker = CreateWorkflow25(PoseLandmarkerTask);
|
|
3695
3877
|
|
|
3696
3878
|
// src/task/QueryExpanderTask.ts
|
|
3697
3879
|
import {
|
|
3698
|
-
CreateWorkflow as
|
|
3880
|
+
CreateWorkflow as CreateWorkflow26,
|
|
3699
3881
|
Task as Task10,
|
|
3700
|
-
Workflow as
|
|
3882
|
+
Workflow as Workflow26
|
|
3701
3883
|
} from "@workglow/task-graph";
|
|
3702
3884
|
var QueryExpansionMethod = {
|
|
3703
3885
|
MULTI_QUERY: "multi-query",
|
|
@@ -3908,18 +4090,18 @@ class QueryExpanderTask extends Task10 {
|
|
|
3908
4090
|
var queryExpander = (input, config) => {
|
|
3909
4091
|
return new QueryExpanderTask({}, config).run(input);
|
|
3910
4092
|
};
|
|
3911
|
-
|
|
4093
|
+
Workflow26.prototype.queryExpander = CreateWorkflow26(QueryExpanderTask);
|
|
3912
4094
|
|
|
3913
4095
|
// src/task/RerankerTask.ts
|
|
3914
4096
|
import {
|
|
3915
|
-
CreateWorkflow as
|
|
4097
|
+
CreateWorkflow as CreateWorkflow28,
|
|
3916
4098
|
Task as Task11,
|
|
3917
|
-
Workflow as
|
|
4099
|
+
Workflow as Workflow28
|
|
3918
4100
|
} from "@workglow/task-graph";
|
|
3919
4101
|
|
|
3920
4102
|
// src/task/TextClassificationTask.ts
|
|
3921
|
-
import { CreateWorkflow as
|
|
3922
|
-
var
|
|
4103
|
+
import { CreateWorkflow as CreateWorkflow27, Workflow as Workflow27 } from "@workglow/task-graph";
|
|
4104
|
+
var modelSchema19 = TypeModel("model:TextClassificationTask");
|
|
3923
4105
|
var TextClassificationInputSchema = {
|
|
3924
4106
|
type: "object",
|
|
3925
4107
|
properties: {
|
|
@@ -3946,7 +4128,7 @@ var TextClassificationInputSchema = {
|
|
|
3946
4128
|
description: "The maximum number of categories to return",
|
|
3947
4129
|
"x-ui-group": "Configuration"
|
|
3948
4130
|
},
|
|
3949
|
-
model:
|
|
4131
|
+
model: modelSchema19
|
|
3950
4132
|
},
|
|
3951
4133
|
required: ["text", "model"],
|
|
3952
4134
|
additionalProperties: false
|
|
@@ -3996,7 +4178,7 @@ class TextClassificationTask extends AiTask {
|
|
|
3996
4178
|
var textClassification = (input, config) => {
|
|
3997
4179
|
return new TextClassificationTask({}, config).run(input);
|
|
3998
4180
|
};
|
|
3999
|
-
|
|
4181
|
+
Workflow27.prototype.textClassification = CreateWorkflow27(TextClassificationTask);
|
|
4000
4182
|
|
|
4001
4183
|
// src/task/RerankerTask.ts
|
|
4002
4184
|
var inputSchema11 = {
|
|
@@ -4220,14 +4402,14 @@ class RerankerTask extends Task11 {
|
|
|
4220
4402
|
var reranker = (input, config) => {
|
|
4221
4403
|
return new RerankerTask({}, config).run(input);
|
|
4222
4404
|
};
|
|
4223
|
-
|
|
4405
|
+
Workflow28.prototype.reranker = CreateWorkflow28(RerankerTask);
|
|
4224
4406
|
|
|
4225
4407
|
// src/task/StructuralParserTask.ts
|
|
4226
4408
|
import { StructuralParser } from "@workglow/dataset";
|
|
4227
4409
|
import {
|
|
4228
|
-
CreateWorkflow as
|
|
4410
|
+
CreateWorkflow as CreateWorkflow29,
|
|
4229
4411
|
Task as Task12,
|
|
4230
|
-
Workflow as
|
|
4412
|
+
Workflow as Workflow29
|
|
4231
4413
|
} from "@workglow/task-graph";
|
|
4232
4414
|
import { uuid4 as uuid42 } from "@workglow/util";
|
|
4233
4415
|
var inputSchema12 = {
|
|
@@ -4329,13 +4511,13 @@ class StructuralParserTask extends Task12 {
|
|
|
4329
4511
|
var structuralParser = (input, config) => {
|
|
4330
4512
|
return new StructuralParserTask({}, config).run(input);
|
|
4331
4513
|
};
|
|
4332
|
-
|
|
4514
|
+
Workflow29.prototype.structuralParser = CreateWorkflow29(StructuralParserTask);
|
|
4333
4515
|
|
|
4334
4516
|
// src/task/TextChunkerTask.ts
|
|
4335
4517
|
import {
|
|
4336
|
-
CreateWorkflow as
|
|
4518
|
+
CreateWorkflow as CreateWorkflow30,
|
|
4337
4519
|
Task as Task13,
|
|
4338
|
-
Workflow as
|
|
4520
|
+
Workflow as Workflow30
|
|
4339
4521
|
} from "@workglow/task-graph";
|
|
4340
4522
|
var ChunkingStrategy = {
|
|
4341
4523
|
FIXED: "fixed",
|
|
@@ -4585,11 +4767,11 @@ class TextChunkerTask extends Task13 {
|
|
|
4585
4767
|
var textChunker = (input, config) => {
|
|
4586
4768
|
return new TextChunkerTask({}, config).run(input);
|
|
4587
4769
|
};
|
|
4588
|
-
|
|
4770
|
+
Workflow30.prototype.textChunker = CreateWorkflow30(TextChunkerTask);
|
|
4589
4771
|
|
|
4590
4772
|
// src/task/TextFillMaskTask.ts
|
|
4591
|
-
import { CreateWorkflow as
|
|
4592
|
-
var
|
|
4773
|
+
import { CreateWorkflow as CreateWorkflow31, Workflow as Workflow31 } from "@workglow/task-graph";
|
|
4774
|
+
var modelSchema20 = TypeModel("model:TextFillMaskTask");
|
|
4593
4775
|
var TextFillMaskInputSchema = {
|
|
4594
4776
|
type: "object",
|
|
4595
4777
|
properties: {
|
|
@@ -4598,7 +4780,7 @@ var TextFillMaskInputSchema = {
|
|
|
4598
4780
|
title: "Text",
|
|
4599
4781
|
description: "The text with a mask token to fill"
|
|
4600
4782
|
},
|
|
4601
|
-
model:
|
|
4783
|
+
model: modelSchema20
|
|
4602
4784
|
},
|
|
4603
4785
|
required: ["text", "model"],
|
|
4604
4786
|
additionalProperties: false
|
|
@@ -4653,21 +4835,21 @@ class TextFillMaskTask extends AiTask {
|
|
|
4653
4835
|
var textFillMask = (input, config) => {
|
|
4654
4836
|
return new TextFillMaskTask({}, config).run(input);
|
|
4655
4837
|
};
|
|
4656
|
-
|
|
4838
|
+
Workflow31.prototype.textFillMask = CreateWorkflow31(TextFillMaskTask);
|
|
4657
4839
|
|
|
4658
4840
|
// src/task/TextGenerationTask.ts
|
|
4659
|
-
import { CreateWorkflow as
|
|
4841
|
+
import { CreateWorkflow as CreateWorkflow32, Workflow as Workflow32 } from "@workglow/task-graph";
|
|
4660
4842
|
var generatedTextSchema2 = {
|
|
4661
4843
|
type: "string",
|
|
4662
4844
|
title: "Text",
|
|
4663
4845
|
description: "The generated text",
|
|
4664
4846
|
"x-stream": "append"
|
|
4665
4847
|
};
|
|
4666
|
-
var
|
|
4848
|
+
var modelSchema21 = TypeModel("model:TextGenerationTask");
|
|
4667
4849
|
var TextGenerationInputSchema = {
|
|
4668
4850
|
type: "object",
|
|
4669
4851
|
properties: {
|
|
4670
|
-
model:
|
|
4852
|
+
model: modelSchema21,
|
|
4671
4853
|
prompt: {
|
|
4672
4854
|
type: "string",
|
|
4673
4855
|
title: "Prompt",
|
|
@@ -4741,11 +4923,11 @@ class TextGenerationTask extends StreamingAiTask {
|
|
|
4741
4923
|
var textGeneration = (input, config) => {
|
|
4742
4924
|
return new TextGenerationTask({}, config).run(input);
|
|
4743
4925
|
};
|
|
4744
|
-
|
|
4926
|
+
Workflow32.prototype.textGeneration = CreateWorkflow32(TextGenerationTask);
|
|
4745
4927
|
|
|
4746
4928
|
// src/task/TextLanguageDetectionTask.ts
|
|
4747
|
-
import { CreateWorkflow as
|
|
4748
|
-
var
|
|
4929
|
+
import { CreateWorkflow as CreateWorkflow33, Workflow as Workflow33 } from "@workglow/task-graph";
|
|
4930
|
+
var modelSchema22 = TypeModel("model:TextLanguageDetectionTask");
|
|
4749
4931
|
var TextLanguageDetectionInputSchema = {
|
|
4750
4932
|
type: "object",
|
|
4751
4933
|
properties: {
|
|
@@ -4762,7 +4944,7 @@ var TextLanguageDetectionInputSchema = {
|
|
|
4762
4944
|
title: "Max Languages",
|
|
4763
4945
|
description: "The maximum number of languages to return"
|
|
4764
4946
|
},
|
|
4765
|
-
model:
|
|
4947
|
+
model: modelSchema22
|
|
4766
4948
|
},
|
|
4767
4949
|
required: ["text", "model"],
|
|
4768
4950
|
additionalProperties: false
|
|
@@ -4812,10 +4994,10 @@ class TextLanguageDetectionTask extends AiTask {
|
|
|
4812
4994
|
var textLanguageDetection = (input, config) => {
|
|
4813
4995
|
return new TextLanguageDetectionTask({}, config).run(input);
|
|
4814
4996
|
};
|
|
4815
|
-
|
|
4997
|
+
Workflow33.prototype.textLanguageDetection = CreateWorkflow33(TextLanguageDetectionTask);
|
|
4816
4998
|
|
|
4817
4999
|
// src/task/TextQuestionAnswerTask.ts
|
|
4818
|
-
import { CreateWorkflow as
|
|
5000
|
+
import { CreateWorkflow as CreateWorkflow34, Workflow as Workflow34 } from "@workglow/task-graph";
|
|
4819
5001
|
var contextSchema = {
|
|
4820
5002
|
type: "string",
|
|
4821
5003
|
title: "Context",
|
|
@@ -4832,13 +5014,13 @@ var textSchema = {
|
|
|
4832
5014
|
description: "The generated text",
|
|
4833
5015
|
"x-stream": "append"
|
|
4834
5016
|
};
|
|
4835
|
-
var
|
|
5017
|
+
var modelSchema23 = TypeModel("model:TextQuestionAnswerTask");
|
|
4836
5018
|
var TextQuestionAnswerInputSchema = {
|
|
4837
5019
|
type: "object",
|
|
4838
5020
|
properties: {
|
|
4839
5021
|
context: contextSchema,
|
|
4840
5022
|
question: questionSchema,
|
|
4841
|
-
model:
|
|
5023
|
+
model: modelSchema23
|
|
4842
5024
|
},
|
|
4843
5025
|
required: ["context", "question", "model"],
|
|
4844
5026
|
additionalProperties: false
|
|
@@ -4867,11 +5049,11 @@ class TextQuestionAnswerTask extends StreamingAiTask {
|
|
|
4867
5049
|
var textQuestionAnswer = (input, config) => {
|
|
4868
5050
|
return new TextQuestionAnswerTask({}, config).run(input);
|
|
4869
5051
|
};
|
|
4870
|
-
|
|
5052
|
+
Workflow34.prototype.textQuestionAnswer = CreateWorkflow34(TextQuestionAnswerTask);
|
|
4871
5053
|
|
|
4872
5054
|
// src/task/TextRewriterTask.ts
|
|
4873
|
-
import { CreateWorkflow as
|
|
4874
|
-
var
|
|
5055
|
+
import { CreateWorkflow as CreateWorkflow35, Workflow as Workflow35 } from "@workglow/task-graph";
|
|
5056
|
+
var modelSchema24 = TypeModel("model:TextRewriterTask");
|
|
4875
5057
|
var TextRewriterInputSchema = {
|
|
4876
5058
|
type: "object",
|
|
4877
5059
|
properties: {
|
|
@@ -4885,7 +5067,7 @@ var TextRewriterInputSchema = {
|
|
|
4885
5067
|
title: "Prompt",
|
|
4886
5068
|
description: "The prompt to direct the rewriting"
|
|
4887
5069
|
},
|
|
4888
|
-
model:
|
|
5070
|
+
model: modelSchema24
|
|
4889
5071
|
},
|
|
4890
5072
|
required: ["text", "prompt", "model"],
|
|
4891
5073
|
additionalProperties: false
|
|
@@ -4919,11 +5101,11 @@ class TextRewriterTask extends StreamingAiTask {
|
|
|
4919
5101
|
var textRewriter = (input, config) => {
|
|
4920
5102
|
return new TextRewriterTask({}, config).run(input);
|
|
4921
5103
|
};
|
|
4922
|
-
|
|
5104
|
+
Workflow35.prototype.textRewriter = CreateWorkflow35(TextRewriterTask);
|
|
4923
5105
|
|
|
4924
5106
|
// src/task/TextTranslationTask.ts
|
|
4925
|
-
import { CreateWorkflow as
|
|
4926
|
-
var
|
|
5107
|
+
import { CreateWorkflow as CreateWorkflow36, Workflow as Workflow36 } from "@workglow/task-graph";
|
|
5108
|
+
var modelSchema25 = TypeModel("model:TextTranslationTask");
|
|
4927
5109
|
var translationTextSchema = {
|
|
4928
5110
|
type: "string",
|
|
4929
5111
|
title: "Text",
|
|
@@ -4950,7 +5132,7 @@ var TextTranslationInputSchema = {
|
|
|
4950
5132
|
minLength: 2,
|
|
4951
5133
|
maxLength: 2
|
|
4952
5134
|
}),
|
|
4953
|
-
model:
|
|
5135
|
+
model: modelSchema25
|
|
4954
5136
|
},
|
|
4955
5137
|
required: ["text", "source_lang", "target_lang", "model"],
|
|
4956
5138
|
additionalProperties: false
|
|
@@ -4985,13 +5167,13 @@ class TextTranslationTask extends StreamingAiTask {
|
|
|
4985
5167
|
var textTranslation = (input, config) => {
|
|
4986
5168
|
return new TextTranslationTask({}, config).run(input);
|
|
4987
5169
|
};
|
|
4988
|
-
|
|
5170
|
+
Workflow36.prototype.textTranslation = CreateWorkflow36(TextTranslationTask);
|
|
4989
5171
|
|
|
4990
5172
|
// src/task/TopicSegmenterTask.ts
|
|
4991
5173
|
import {
|
|
4992
|
-
CreateWorkflow as
|
|
5174
|
+
CreateWorkflow as CreateWorkflow37,
|
|
4993
5175
|
Task as Task14,
|
|
4994
|
-
Workflow as
|
|
5176
|
+
Workflow as Workflow37
|
|
4995
5177
|
} from "@workglow/task-graph";
|
|
4996
5178
|
var SegmentationMethod = {
|
|
4997
5179
|
HEURISTIC: "heuristic",
|
|
@@ -5272,15 +5454,15 @@ class TopicSegmenterTask extends Task14 {
|
|
|
5272
5454
|
var topicSegmenter = (input, config) => {
|
|
5273
5455
|
return new TopicSegmenterTask({}, config).run(input);
|
|
5274
5456
|
};
|
|
5275
|
-
|
|
5457
|
+
Workflow37.prototype.topicSegmenter = CreateWorkflow37(TopicSegmenterTask);
|
|
5276
5458
|
|
|
5277
5459
|
// src/task/UnloadModelTask.ts
|
|
5278
|
-
import { CreateWorkflow as
|
|
5279
|
-
var
|
|
5460
|
+
import { CreateWorkflow as CreateWorkflow38, Workflow as Workflow38 } from "@workglow/task-graph";
|
|
5461
|
+
var modelSchema26 = TypeModel("model");
|
|
5280
5462
|
var UnloadModelInputSchema = {
|
|
5281
5463
|
type: "object",
|
|
5282
5464
|
properties: {
|
|
5283
|
-
model:
|
|
5465
|
+
model: modelSchema26
|
|
5284
5466
|
},
|
|
5285
5467
|
required: ["model"],
|
|
5286
5468
|
additionalProperties: false
|
|
@@ -5288,7 +5470,7 @@ var UnloadModelInputSchema = {
|
|
|
5288
5470
|
var UnloadModelOutputSchema = {
|
|
5289
5471
|
type: "object",
|
|
5290
5472
|
properties: {
|
|
5291
|
-
model:
|
|
5473
|
+
model: modelSchema26
|
|
5292
5474
|
},
|
|
5293
5475
|
required: ["model"],
|
|
5294
5476
|
additionalProperties: false
|
|
@@ -5310,10 +5492,10 @@ class UnloadModelTask extends AiTask {
|
|
|
5310
5492
|
var unloadModel = (input, config) => {
|
|
5311
5493
|
return new UnloadModelTask({}, config).run(input);
|
|
5312
5494
|
};
|
|
5313
|
-
|
|
5495
|
+
Workflow38.prototype.unloadModel = CreateWorkflow38(UnloadModelTask);
|
|
5314
5496
|
|
|
5315
5497
|
// src/task/VectorQuantizeTask.ts
|
|
5316
|
-
import { CreateWorkflow as
|
|
5498
|
+
import { CreateWorkflow as CreateWorkflow39, Task as Task15, Workflow as Workflow39 } from "@workglow/task-graph";
|
|
5317
5499
|
import {
|
|
5318
5500
|
normalizeNumberArray,
|
|
5319
5501
|
TensorType,
|
|
@@ -5493,10 +5675,10 @@ class VectorQuantizeTask extends Task15 {
|
|
|
5493
5675
|
var vectorQuantize = (input, config) => {
|
|
5494
5676
|
return new VectorQuantizeTask({}, config).run(input);
|
|
5495
5677
|
};
|
|
5496
|
-
|
|
5678
|
+
Workflow39.prototype.vectorQuantize = CreateWorkflow39(VectorQuantizeTask);
|
|
5497
5679
|
|
|
5498
5680
|
// src/task/VectorSimilarityTask.ts
|
|
5499
|
-
import { CreateWorkflow as
|
|
5681
|
+
import { CreateWorkflow as CreateWorkflow40, GraphAsTask, Workflow as Workflow40 } from "@workglow/task-graph";
|
|
5500
5682
|
import {
|
|
5501
5683
|
cosineSimilarity,
|
|
5502
5684
|
hammingSimilarity,
|
|
@@ -5602,13 +5784,14 @@ class VectorSimilarityTask extends GraphAsTask {
|
|
|
5602
5784
|
var similarity = (input, config) => {
|
|
5603
5785
|
return new VectorSimilarityTask({}, config).run(input);
|
|
5604
5786
|
};
|
|
5605
|
-
|
|
5787
|
+
Workflow40.prototype.similarity = CreateWorkflow40(VectorSimilarityTask);
|
|
5606
5788
|
|
|
5607
5789
|
// src/task/index.ts
|
|
5608
5790
|
var registerAiTasks = () => {
|
|
5609
5791
|
const tasks = [
|
|
5610
5792
|
BackgroundRemovalTask,
|
|
5611
5793
|
ChunkToVectorTask,
|
|
5794
|
+
CountTokensTask,
|
|
5612
5795
|
ContextBuilderTask,
|
|
5613
5796
|
DocumentEnricherTask,
|
|
5614
5797
|
ChunkRetrievalTask,
|
|
@@ -5690,6 +5873,7 @@ export {
|
|
|
5690
5873
|
faceDetector,
|
|
5691
5874
|
downloadModel,
|
|
5692
5875
|
documentEnricher,
|
|
5876
|
+
countTokens,
|
|
5693
5877
|
contextBuilder,
|
|
5694
5878
|
chunkVectorUpsert,
|
|
5695
5879
|
chunkToVector,
|
|
@@ -5786,6 +5970,9 @@ export {
|
|
|
5786
5970
|
FaceDetectorInputSchema,
|
|
5787
5971
|
DownloadModelTask,
|
|
5788
5972
|
DocumentEnricherTask,
|
|
5973
|
+
CountTokensTask,
|
|
5974
|
+
CountTokensOutputSchema,
|
|
5975
|
+
CountTokensInputSchema,
|
|
5789
5976
|
ContextFormat,
|
|
5790
5977
|
ContextBuilderTask,
|
|
5791
5978
|
ChunkingStrategy,
|
|
@@ -5803,4 +5990,4 @@ export {
|
|
|
5803
5990
|
AiJob
|
|
5804
5991
|
};
|
|
5805
5992
|
|
|
5806
|
-
//# debugId=
|
|
5993
|
+
//# debugId=27B14E49C5DECD7164756E2164756E21
|