@workglow/ai 0.2.32 → 0.2.34
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 +849 -275
- package/dist/browser.js.map +9 -6
- package/dist/bun.js +849 -275
- package/dist/bun.js.map +9 -6
- package/dist/node.js +849 -275
- package/dist/node.js.map +9 -6
- package/dist/provider-utils/CloudProviderClient.d.ts +3 -9
- package/dist/provider-utils/CloudProviderClient.d.ts.map +1 -1
- package/dist/provider-utils.js +1 -10
- package/dist/provider-utils.js.map +3 -3
- package/dist/task/AiChatTask.d.ts +9 -2
- package/dist/task/AiChatTask.d.ts.map +1 -1
- package/dist/task/AiChatWithKbTask.d.ts +710 -0
- package/dist/task/AiChatWithKbTask.d.ts.map +1 -0
- package/dist/task/HierarchicalChunkerTask.d.ts.map +1 -1
- package/dist/task/KbSearchTask.d.ts +79 -0
- package/dist/task/KbSearchTask.d.ts.map +1 -0
- package/dist/task/base/responseFormat.d.ts +23 -0
- package/dist/task/base/responseFormat.d.ts.map +1 -0
- package/dist/task/index.d.ts +6 -1
- package/dist/task/index.d.ts.map +1 -1
- package/package.json +12 -12
package/dist/browser.js
CHANGED
|
@@ -1013,6 +1013,28 @@ var TypeCategory = {
|
|
|
1013
1013
|
description: "Classification category with label and score"
|
|
1014
1014
|
};
|
|
1015
1015
|
|
|
1016
|
+
// src/task/base/responseFormat.ts
|
|
1017
|
+
function buildResponseFormatAddendum(format) {
|
|
1018
|
+
if (format === "markdown") {
|
|
1019
|
+
return [
|
|
1020
|
+
"Format your reply as GitHub-flavored Markdown:",
|
|
1021
|
+
"- Use headings, bullet lists, numbered lists, tables, and fenced code blocks where they help readability.",
|
|
1022
|
+
"- Use **bold** and *italic* sparingly for emphasis.",
|
|
1023
|
+
"- Keep paragraphs short."
|
|
1024
|
+
].join(`
|
|
1025
|
+
`);
|
|
1026
|
+
}
|
|
1027
|
+
return "";
|
|
1028
|
+
}
|
|
1029
|
+
var KB_INLINE_CITATION_DIRECTIVE = [
|
|
1030
|
+
"When you reference information from the context above, cite it inline as a",
|
|
1031
|
+
"Markdown link: write the natural anchor text in brackets followed by the",
|
|
1032
|
+
"URL in parentheses, e.g. `[the dashboard](https://workglow.com/help/dashboard)`.",
|
|
1033
|
+
"Do not use numeric `[1]`-style citations. If a context entry has no URL,",
|
|
1034
|
+
"describe it in prose without a link."
|
|
1035
|
+
].join(`
|
|
1036
|
+
`);
|
|
1037
|
+
|
|
1016
1038
|
// src/task/base/StreamingAiTask.ts
|
|
1017
1039
|
import { getStreamingPorts, TaskConfigurationError as TaskConfigurationError3 } from "@workglow/task-graph";
|
|
1018
1040
|
|
|
@@ -1429,6 +1451,14 @@ var AiChatInputSchema = {
|
|
|
1429
1451
|
minimum: 1,
|
|
1430
1452
|
default: 100,
|
|
1431
1453
|
"x-ui-group": "Configuration"
|
|
1454
|
+
},
|
|
1455
|
+
responseFormat: {
|
|
1456
|
+
type: "string",
|
|
1457
|
+
enum: ["text", "markdown"],
|
|
1458
|
+
default: "text",
|
|
1459
|
+
title: "Response format",
|
|
1460
|
+
description: "How the model is instructed to format replies. 'text' = plain text. " + "'markdown' = GitHub-flavored Markdown.",
|
|
1461
|
+
"x-ui-group": "Configuration"
|
|
1432
1462
|
}
|
|
1433
1463
|
},
|
|
1434
1464
|
required: ["model", "prompt"],
|
|
@@ -1440,7 +1470,7 @@ var AiChatOutputSchema = {
|
|
|
1440
1470
|
text: {
|
|
1441
1471
|
type: "string",
|
|
1442
1472
|
title: "Text",
|
|
1443
|
-
description: "
|
|
1473
|
+
description: "Full streamed transcript across all assistant turns",
|
|
1444
1474
|
"x-stream": "append"
|
|
1445
1475
|
},
|
|
1446
1476
|
messages: {
|
|
@@ -1503,8 +1533,15 @@ class AiChatTask extends StreamingAiTask {
|
|
|
1503
1533
|
}
|
|
1504
1534
|
const connector = resolveHumanConnector(context);
|
|
1505
1535
|
const history = [];
|
|
1506
|
-
|
|
1507
|
-
|
|
1536
|
+
const addendum = buildResponseFormatAddendum(input.responseFormat);
|
|
1537
|
+
const composedSystemPrompt = [input.systemPrompt ?? "", addendum].filter((s) => s.length > 0).join(`
|
|
1538
|
+
|
|
1539
|
+
`);
|
|
1540
|
+
if (composedSystemPrompt.length > 0) {
|
|
1541
|
+
history.push({
|
|
1542
|
+
role: "system",
|
|
1543
|
+
content: [{ type: "text", text: composedSystemPrompt }]
|
|
1544
|
+
});
|
|
1508
1545
|
}
|
|
1509
1546
|
const firstUserBlocks = typeof input.prompt === "string" ? [{ type: "text", text: input.prompt }] : input.prompt;
|
|
1510
1547
|
history.push({ role: "user", content: firstUserBlocks });
|
|
@@ -1518,13 +1555,12 @@ class AiChatTask extends StreamingAiTask {
|
|
|
1518
1555
|
await getAiProviderRegistry().disposeSession(model.provider, sessionId);
|
|
1519
1556
|
});
|
|
1520
1557
|
}
|
|
1558
|
+
let completedTurns = 0;
|
|
1521
1559
|
yield {
|
|
1522
1560
|
type: "object-delta",
|
|
1523
1561
|
port: "messages",
|
|
1524
1562
|
objectDelta: [...history]
|
|
1525
1563
|
};
|
|
1526
|
-
let iterations = 0;
|
|
1527
|
-
let lastAssistantText = "";
|
|
1528
1564
|
for (let turn = 0;turn < maxIterations; turn++) {
|
|
1529
1565
|
const perTurnInput = { ...input, messages: [...history] };
|
|
1530
1566
|
const turnJobInput = await this.getJobInput(perTurnInput);
|
|
@@ -1536,17 +1572,487 @@ class AiChatTask extends StreamingAiTask {
|
|
|
1536
1572
|
...event,
|
|
1537
1573
|
port: event.port ?? "text"
|
|
1538
1574
|
};
|
|
1539
|
-
} else if (event.type === "finish") {} else {
|
|
1540
|
-
yield event;
|
|
1575
|
+
} else if (event.type === "finish") {} else {
|
|
1576
|
+
yield event;
|
|
1577
|
+
}
|
|
1578
|
+
}
|
|
1579
|
+
const assistantMsg = {
|
|
1580
|
+
role: "assistant",
|
|
1581
|
+
content: [{ type: "text", text: assistantText }]
|
|
1582
|
+
};
|
|
1583
|
+
history.push(assistantMsg);
|
|
1584
|
+
completedTurns = turn + 1;
|
|
1585
|
+
yield {
|
|
1586
|
+
type: "object-delta",
|
|
1587
|
+
port: "messages",
|
|
1588
|
+
objectDelta: [assistantMsg]
|
|
1589
|
+
};
|
|
1590
|
+
const request = {
|
|
1591
|
+
requestId: crypto.randomUUID(),
|
|
1592
|
+
targetHumanId: "default",
|
|
1593
|
+
kind: "elicit",
|
|
1594
|
+
message: "",
|
|
1595
|
+
contentSchema: chatConnectorContentSchema,
|
|
1596
|
+
contentData: undefined,
|
|
1597
|
+
expectsResponse: true,
|
|
1598
|
+
mode: "multi-turn",
|
|
1599
|
+
metadata: { iteration: turn, taskId: this.id }
|
|
1600
|
+
};
|
|
1601
|
+
const response = await connector.send(request, context.signal);
|
|
1602
|
+
if (response.action === "cancel" || response.action === "decline")
|
|
1603
|
+
break;
|
|
1604
|
+
const raw = response.content?.content;
|
|
1605
|
+
let userContent;
|
|
1606
|
+
if (typeof raw === "string") {
|
|
1607
|
+
const text = raw.trim();
|
|
1608
|
+
userContent = text.length > 0 ? [{ type: "text", text: raw }] : [];
|
|
1609
|
+
} else if (Array.isArray(raw)) {
|
|
1610
|
+
userContent = raw;
|
|
1611
|
+
} else {
|
|
1612
|
+
userContent = [];
|
|
1613
|
+
}
|
|
1614
|
+
if (userContent.length === 0)
|
|
1615
|
+
break;
|
|
1616
|
+
const userMsg = { role: "user", content: userContent };
|
|
1617
|
+
history.push(userMsg);
|
|
1618
|
+
yield {
|
|
1619
|
+
type: "object-delta",
|
|
1620
|
+
port: "messages",
|
|
1621
|
+
objectDelta: [userMsg]
|
|
1622
|
+
};
|
|
1623
|
+
}
|
|
1624
|
+
yield {
|
|
1625
|
+
type: "finish",
|
|
1626
|
+
data: { iterations: completedTurns }
|
|
1627
|
+
};
|
|
1628
|
+
}
|
|
1629
|
+
}
|
|
1630
|
+
|
|
1631
|
+
// src/task/AiChatWithKbTask.ts
|
|
1632
|
+
import { getKnowledgeBase, slugifyHeading } from "@workglow/knowledge-base";
|
|
1633
|
+
import { TaskConfigSchema as TaskConfigSchema3 } from "@workglow/task-graph";
|
|
1634
|
+
import { resolveHumanConnector as resolveHumanConnector2 } from "@workglow/util";
|
|
1635
|
+
|
|
1636
|
+
// src/task/KbSearchTask.ts
|
|
1637
|
+
import { TypeKnowledgeBase } from "@workglow/knowledge-base";
|
|
1638
|
+
import { CreateWorkflow, Task as Task2, Workflow } from "@workglow/task-graph";
|
|
1639
|
+
var inputSchema = {
|
|
1640
|
+
type: "object",
|
|
1641
|
+
properties: {
|
|
1642
|
+
knowledgeBase: TypeKnowledgeBase({
|
|
1643
|
+
title: "Knowledge Base",
|
|
1644
|
+
description: "The knowledge base instance to search in"
|
|
1645
|
+
}),
|
|
1646
|
+
query: {
|
|
1647
|
+
type: "string",
|
|
1648
|
+
title: "Query",
|
|
1649
|
+
description: "Search query (the KB's onSearch handles embedding internally)"
|
|
1650
|
+
},
|
|
1651
|
+
topK: {
|
|
1652
|
+
type: "number",
|
|
1653
|
+
title: "Top K",
|
|
1654
|
+
description: "Number of top results to return",
|
|
1655
|
+
minimum: 1,
|
|
1656
|
+
default: 5
|
|
1657
|
+
},
|
|
1658
|
+
filter: {
|
|
1659
|
+
type: "object",
|
|
1660
|
+
title: "Metadata Filter",
|
|
1661
|
+
description: "Filter results by metadata fields"
|
|
1662
|
+
}
|
|
1663
|
+
},
|
|
1664
|
+
required: ["knowledgeBase", "query"],
|
|
1665
|
+
additionalProperties: false
|
|
1666
|
+
};
|
|
1667
|
+
var outputSchema = {
|
|
1668
|
+
type: "object",
|
|
1669
|
+
properties: {
|
|
1670
|
+
results: {
|
|
1671
|
+
type: "array",
|
|
1672
|
+
items: {
|
|
1673
|
+
type: "object",
|
|
1674
|
+
title: "Chunk Search Result",
|
|
1675
|
+
description: "A single chunk match with score and metadata"
|
|
1676
|
+
},
|
|
1677
|
+
title: "Results",
|
|
1678
|
+
description: "Matching chunks in score-desc order"
|
|
1679
|
+
},
|
|
1680
|
+
count: {
|
|
1681
|
+
type: "number",
|
|
1682
|
+
title: "Count",
|
|
1683
|
+
description: "Number of results returned"
|
|
1684
|
+
}
|
|
1685
|
+
},
|
|
1686
|
+
required: ["results", "count"],
|
|
1687
|
+
additionalProperties: false
|
|
1688
|
+
};
|
|
1689
|
+
|
|
1690
|
+
class KbSearchTask extends Task2 {
|
|
1691
|
+
static type = "KbSearchTask";
|
|
1692
|
+
static category = "RAG";
|
|
1693
|
+
static title = "KB Search";
|
|
1694
|
+
static description = "Search a knowledge base for chunks matching a text query. Wraps the KB's `search` method (which embeds and retrieves via the KB's onSearch callback).";
|
|
1695
|
+
static cacheable = true;
|
|
1696
|
+
static inputSchema() {
|
|
1697
|
+
return inputSchema;
|
|
1698
|
+
}
|
|
1699
|
+
static outputSchema() {
|
|
1700
|
+
return outputSchema;
|
|
1701
|
+
}
|
|
1702
|
+
async execute(input, _context) {
|
|
1703
|
+
const { knowledgeBase, query, topK = 5, filter } = input;
|
|
1704
|
+
const kb = knowledgeBase;
|
|
1705
|
+
const results = await kb.search(query, { topK, filter });
|
|
1706
|
+
return { results, count: results.length };
|
|
1707
|
+
}
|
|
1708
|
+
}
|
|
1709
|
+
var kbSearch = (input, config) => {
|
|
1710
|
+
return new KbSearchTask(config).run(input);
|
|
1711
|
+
};
|
|
1712
|
+
Workflow.prototype.kbSearch = CreateWorkflow(KbSearchTask);
|
|
1713
|
+
|
|
1714
|
+
// src/task/AiChatWithKbTask.ts
|
|
1715
|
+
var modelSchema2 = TypeModel("model:AiChatWithKbTask");
|
|
1716
|
+
var chatChunkReferenceSchema = {
|
|
1717
|
+
type: "object",
|
|
1718
|
+
properties: {
|
|
1719
|
+
kbId: { type: "string" },
|
|
1720
|
+
kbLabel: { type: "string" },
|
|
1721
|
+
title: { type: "string" },
|
|
1722
|
+
url: { type: "string" },
|
|
1723
|
+
snippet: { type: "string" },
|
|
1724
|
+
score: { type: "number" },
|
|
1725
|
+
index: { type: "number" }
|
|
1726
|
+
},
|
|
1727
|
+
required: ["kbId", "kbLabel", "title", "snippet", "score", "index"]
|
|
1728
|
+
};
|
|
1729
|
+
var chatConnectorContentSchema2 = {
|
|
1730
|
+
type: "object",
|
|
1731
|
+
properties: {
|
|
1732
|
+
content: {
|
|
1733
|
+
type: "string",
|
|
1734
|
+
title: "Message",
|
|
1735
|
+
description: "Your reply (leave blank to end the conversation)"
|
|
1736
|
+
}
|
|
1737
|
+
},
|
|
1738
|
+
additionalProperties: false
|
|
1739
|
+
};
|
|
1740
|
+
var AiChatWithKbInputSchema = {
|
|
1741
|
+
type: "object",
|
|
1742
|
+
properties: {
|
|
1743
|
+
model: modelSchema2,
|
|
1744
|
+
prompt: {
|
|
1745
|
+
oneOf: [
|
|
1746
|
+
{ type: "string", title: "Prompt", description: "The initial user message" },
|
|
1747
|
+
{
|
|
1748
|
+
type: "array",
|
|
1749
|
+
title: "Prompt",
|
|
1750
|
+
description: "The initial user message as structured content blocks",
|
|
1751
|
+
items: ContentBlockSchema
|
|
1752
|
+
}
|
|
1753
|
+
],
|
|
1754
|
+
title: "Prompt",
|
|
1755
|
+
description: "The first user message to start the conversation"
|
|
1756
|
+
},
|
|
1757
|
+
messages: {
|
|
1758
|
+
type: "array",
|
|
1759
|
+
title: "Messages",
|
|
1760
|
+
description: "Conversation history (managed internally by the chat loop; not a user-facing input)",
|
|
1761
|
+
items: ChatMessageSchema,
|
|
1762
|
+
"x-ui-hidden": true
|
|
1763
|
+
},
|
|
1764
|
+
systemPrompt: {
|
|
1765
|
+
type: "string",
|
|
1766
|
+
title: "System Prompt",
|
|
1767
|
+
description: "Optional system instructions for the model"
|
|
1768
|
+
},
|
|
1769
|
+
maxTokens: {
|
|
1770
|
+
type: "number",
|
|
1771
|
+
title: "Max Tokens",
|
|
1772
|
+
description: "Per-turn token limit",
|
|
1773
|
+
minimum: 1,
|
|
1774
|
+
"x-ui-group": "Configuration"
|
|
1775
|
+
},
|
|
1776
|
+
temperature: {
|
|
1777
|
+
type: "number",
|
|
1778
|
+
title: "Temperature",
|
|
1779
|
+
description: "Sampling temperature",
|
|
1780
|
+
minimum: 0,
|
|
1781
|
+
maximum: 2,
|
|
1782
|
+
"x-ui-group": "Configuration"
|
|
1783
|
+
},
|
|
1784
|
+
maxIterations: {
|
|
1785
|
+
type: "number",
|
|
1786
|
+
title: "Max Iterations",
|
|
1787
|
+
description: "Safety cap on conversation turns",
|
|
1788
|
+
minimum: 1,
|
|
1789
|
+
default: 100,
|
|
1790
|
+
"x-ui-group": "Configuration"
|
|
1791
|
+
},
|
|
1792
|
+
knowledgeBaseIds: {
|
|
1793
|
+
type: "array",
|
|
1794
|
+
title: "Knowledge Base IDs",
|
|
1795
|
+
description: "Knowledge bases to retrieve from on each turn",
|
|
1796
|
+
items: { type: "string" }
|
|
1797
|
+
},
|
|
1798
|
+
topKPerKb: {
|
|
1799
|
+
type: "number",
|
|
1800
|
+
title: "Top K per KB",
|
|
1801
|
+
description: "Top results per KB before threshold filtering",
|
|
1802
|
+
minimum: 1,
|
|
1803
|
+
default: 4,
|
|
1804
|
+
"x-ui-group": "Configuration"
|
|
1805
|
+
},
|
|
1806
|
+
minScore: {
|
|
1807
|
+
type: "number",
|
|
1808
|
+
title: "Min score",
|
|
1809
|
+
description: "Score floor for a chunk to count as a useful match",
|
|
1810
|
+
minimum: 0,
|
|
1811
|
+
maximum: 1,
|
|
1812
|
+
default: 0.3,
|
|
1813
|
+
"x-ui-group": "Configuration"
|
|
1814
|
+
},
|
|
1815
|
+
maxReferences: {
|
|
1816
|
+
type: "number",
|
|
1817
|
+
title: "Max references",
|
|
1818
|
+
description: "Cap on the chunk references emitted per turn",
|
|
1819
|
+
minimum: 1,
|
|
1820
|
+
default: 6,
|
|
1821
|
+
"x-ui-group": "Configuration"
|
|
1822
|
+
},
|
|
1823
|
+
noMatchReply: {
|
|
1824
|
+
type: "string",
|
|
1825
|
+
title: "No-match reply",
|
|
1826
|
+
description: "When set and zero chunks match: emit this verbatim and skip the provider",
|
|
1827
|
+
"x-ui-group": "Configuration"
|
|
1828
|
+
},
|
|
1829
|
+
noMatchReferences: {
|
|
1830
|
+
type: "array",
|
|
1831
|
+
title: "No-match references",
|
|
1832
|
+
description: "When set and zero chunks match: emit these verbatim on the references port",
|
|
1833
|
+
items: chatChunkReferenceSchema,
|
|
1834
|
+
"x-ui-group": "Configuration"
|
|
1835
|
+
},
|
|
1836
|
+
responseFormat: {
|
|
1837
|
+
type: "string",
|
|
1838
|
+
enum: ["text", "markdown"],
|
|
1839
|
+
default: "text",
|
|
1840
|
+
title: "Response format",
|
|
1841
|
+
description: "How the model is instructed to format replies. 'text' = plain text. " + "'markdown' = GitHub-flavored Markdown; citations are emitted as inline " + "[anchor](url) links instead of [N] numbers.",
|
|
1842
|
+
"x-ui-group": "Configuration"
|
|
1843
|
+
}
|
|
1844
|
+
},
|
|
1845
|
+
required: ["model", "prompt", "knowledgeBaseIds"],
|
|
1846
|
+
additionalProperties: false
|
|
1847
|
+
};
|
|
1848
|
+
var AiChatWithKbOutputSchema = {
|
|
1849
|
+
type: "object",
|
|
1850
|
+
properties: {
|
|
1851
|
+
text: {
|
|
1852
|
+
type: "string",
|
|
1853
|
+
title: "Text",
|
|
1854
|
+
description: "Full streamed transcript across all assistant turns",
|
|
1855
|
+
"x-stream": "append"
|
|
1856
|
+
},
|
|
1857
|
+
messages: {
|
|
1858
|
+
type: "array",
|
|
1859
|
+
title: "Messages",
|
|
1860
|
+
description: "Full conversation history",
|
|
1861
|
+
items: ChatMessageSchema,
|
|
1862
|
+
"x-stream": "object"
|
|
1863
|
+
},
|
|
1864
|
+
iterations: {
|
|
1865
|
+
type: "number",
|
|
1866
|
+
title: "Iterations",
|
|
1867
|
+
description: "Number of completed turns"
|
|
1868
|
+
},
|
|
1869
|
+
references: {
|
|
1870
|
+
type: "array",
|
|
1871
|
+
title: "References",
|
|
1872
|
+
description: "Per-chunk citation references emitted each turn (one entry per surviving chunk; not deduped)",
|
|
1873
|
+
items: chatChunkReferenceSchema,
|
|
1874
|
+
"x-stream": "object"
|
|
1875
|
+
}
|
|
1876
|
+
},
|
|
1877
|
+
required: ["text", "messages", "iterations", "references"],
|
|
1878
|
+
additionalProperties: false
|
|
1879
|
+
};
|
|
1880
|
+
|
|
1881
|
+
class AiChatWithKbTask extends StreamingAiTask {
|
|
1882
|
+
static type = "AiChatWithKbTask";
|
|
1883
|
+
static streamingPhaseLabel = "Replying";
|
|
1884
|
+
static category = "AI Chat";
|
|
1885
|
+
static title = "AI Chat (Knowledge Base)";
|
|
1886
|
+
static description = "Multi-turn chat grounded in one or more knowledge bases. Retrieves on every user turn, injects numbered context, and emits structured per-chunk citation references.";
|
|
1887
|
+
static cacheable = false;
|
|
1888
|
+
static configSchema() {
|
|
1889
|
+
return {
|
|
1890
|
+
type: "object",
|
|
1891
|
+
properties: {
|
|
1892
|
+
...TaskConfigSchema3["properties"]
|
|
1893
|
+
},
|
|
1894
|
+
additionalProperties: false
|
|
1895
|
+
};
|
|
1896
|
+
}
|
|
1897
|
+
static inputSchema() {
|
|
1898
|
+
return AiChatWithKbInputSchema;
|
|
1899
|
+
}
|
|
1900
|
+
static outputSchema() {
|
|
1901
|
+
return AiChatWithKbOutputSchema;
|
|
1902
|
+
}
|
|
1903
|
+
_sessionId;
|
|
1904
|
+
async getJobInput(input) {
|
|
1905
|
+
const model = input.model;
|
|
1906
|
+
if (!this._sessionId) {
|
|
1907
|
+
this._sessionId = getAiProviderRegistry().createSession(model.provider, model);
|
|
1908
|
+
}
|
|
1909
|
+
return {
|
|
1910
|
+
taskType: "AiChatWithKbTask",
|
|
1911
|
+
aiProvider: model.provider,
|
|
1912
|
+
taskInput: input,
|
|
1913
|
+
sessionId: this._sessionId
|
|
1914
|
+
};
|
|
1915
|
+
}
|
|
1916
|
+
async* executeStream(input, context) {
|
|
1917
|
+
this._sessionId = undefined;
|
|
1918
|
+
const model = input.model;
|
|
1919
|
+
if (!model || typeof model !== "object") {
|
|
1920
|
+
throw new Error("AiChatWithKbTask: model was not resolved to ModelConfig");
|
|
1921
|
+
}
|
|
1922
|
+
const connector = resolveHumanConnector2(context);
|
|
1923
|
+
const history = [];
|
|
1924
|
+
if (input.systemPrompt) {
|
|
1925
|
+
history.push({ role: "system", content: [{ type: "text", text: input.systemPrompt }] });
|
|
1926
|
+
}
|
|
1927
|
+
const firstUserBlocks = typeof input.prompt === "string" ? [{ type: "text", text: input.prompt }] : input.prompt;
|
|
1928
|
+
history.push({ role: "user", content: firstUserBlocks });
|
|
1929
|
+
const workingInput = { ...input, messages: history };
|
|
1930
|
+
await this.getJobInput(workingInput);
|
|
1931
|
+
const maxIterations = input.maxIterations ?? 100;
|
|
1932
|
+
if (context.resourceScope && this._sessionId) {
|
|
1933
|
+
const sessionId = this._sessionId;
|
|
1934
|
+
context.resourceScope.register(`ai:session:${sessionId}`, async () => {
|
|
1935
|
+
await getAiProviderRegistry().disposeSession(model.provider, sessionId);
|
|
1936
|
+
});
|
|
1937
|
+
}
|
|
1938
|
+
yield {
|
|
1939
|
+
type: "object-delta",
|
|
1940
|
+
port: "messages",
|
|
1941
|
+
objectDelta: [...history]
|
|
1942
|
+
};
|
|
1943
|
+
const topK = input.topKPerKb ?? 4;
|
|
1944
|
+
const minScore = input.minScore ?? 0.3;
|
|
1945
|
+
const maxRefs = input.maxReferences ?? 6;
|
|
1946
|
+
let completedTurns = 0;
|
|
1947
|
+
let lastNonEmptyRefs = [];
|
|
1948
|
+
for (let turn = 0;turn < maxIterations; turn++) {
|
|
1949
|
+
const lastUserText = extractLastUserText(history);
|
|
1950
|
+
let perKbResults = [];
|
|
1951
|
+
if (lastUserText.length > 0) {
|
|
1952
|
+
perKbResults = await Promise.all((input.knowledgeBaseIds ?? []).map(async (kbId) => {
|
|
1953
|
+
const kb = getKnowledgeBase(kbId);
|
|
1954
|
+
if (!kb) {
|
|
1955
|
+
console.warn(`[AiChatWithKbTask] knowledge base "${kbId}" not registered`);
|
|
1956
|
+
return { kbId, kbLabel: kbId, kb: undefined, results: [] };
|
|
1957
|
+
}
|
|
1958
|
+
const search = context.own(new KbSearchTask);
|
|
1959
|
+
const out = await search.run({
|
|
1960
|
+
knowledgeBase: kb,
|
|
1961
|
+
query: lastUserText,
|
|
1962
|
+
topK
|
|
1963
|
+
});
|
|
1964
|
+
return {
|
|
1965
|
+
kbId,
|
|
1966
|
+
kbLabel: kb.title || kbId,
|
|
1967
|
+
kb,
|
|
1968
|
+
results: out.results
|
|
1969
|
+
};
|
|
1970
|
+
}));
|
|
1971
|
+
}
|
|
1972
|
+
const allChunks = perKbResults.flatMap(({ kbId, kbLabel, kb, results }) => results.filter((r) => r.score >= minScore).map((r) => ({ kbId, kbLabel, kb, r }))).sort((a, b) => b.r.score - a.r.score).slice(0, maxRefs);
|
|
1973
|
+
const docUrlKey = (kbId, docId) => `${kbId}:${docId}`;
|
|
1974
|
+
const docUrls = new Map;
|
|
1975
|
+
const docFetches = [];
|
|
1976
|
+
for (const { kbId, kb, r } of allChunks) {
|
|
1977
|
+
if (!kb)
|
|
1978
|
+
continue;
|
|
1979
|
+
const key = docUrlKey(kbId, r.doc_id);
|
|
1980
|
+
if (docUrls.has(key))
|
|
1981
|
+
continue;
|
|
1982
|
+
docUrls.set(key, undefined);
|
|
1983
|
+
docFetches.push(kb.getDocument(r.doc_id).then((doc) => {
|
|
1984
|
+
const md = doc?.metadata ?? {};
|
|
1985
|
+
const url = typeof md.url === "string" ? md.url : undefined;
|
|
1986
|
+
docUrls.set(key, url);
|
|
1987
|
+
}).catch(() => {}));
|
|
1988
|
+
}
|
|
1989
|
+
await Promise.all(docFetches);
|
|
1990
|
+
const refs = allChunks.map((entry, i) => buildChunkReference({
|
|
1991
|
+
index: i + 1,
|
|
1992
|
+
kbId: entry.kbId,
|
|
1993
|
+
kbLabel: entry.kbLabel,
|
|
1994
|
+
result: entry.r,
|
|
1995
|
+
url: docUrls.get(docUrlKey(entry.kbId, entry.r.doc_id))
|
|
1996
|
+
}));
|
|
1997
|
+
const effectiveRefs = refs.length > 0 ? refs : lastNonEmptyRefs;
|
|
1998
|
+
if (refs.length > 0) {
|
|
1999
|
+
lastNonEmptyRefs = refs;
|
|
2000
|
+
}
|
|
2001
|
+
const emitted = effectiveRefs.length > 0 ? [...effectiveRefs] : input.noMatchReferences ?? [];
|
|
2002
|
+
yield {
|
|
2003
|
+
type: "object-delta",
|
|
2004
|
+
port: "references",
|
|
2005
|
+
objectDelta: emitted
|
|
2006
|
+
};
|
|
2007
|
+
let assistantText = "";
|
|
2008
|
+
if (effectiveRefs.length === 0 && input.noMatchReply) {
|
|
2009
|
+
yield {
|
|
2010
|
+
type: "text-delta",
|
|
2011
|
+
port: "text",
|
|
2012
|
+
textDelta: input.noMatchReply
|
|
2013
|
+
};
|
|
2014
|
+
assistantText = input.noMatchReply;
|
|
2015
|
+
} else {
|
|
2016
|
+
const addendum = buildResponseFormatAddendum(input.responseFormat);
|
|
2017
|
+
const directive = input.responseFormat === "markdown" ? KB_INLINE_CITATION_DIRECTIVE : "";
|
|
2018
|
+
const userSystemPrompt = input.systemPrompt ?? "";
|
|
2019
|
+
const turnSystemPrompt = [
|
|
2020
|
+
userSystemPrompt,
|
|
2021
|
+
addendum,
|
|
2022
|
+
directive,
|
|
2023
|
+
"--- Context ---",
|
|
2024
|
+
formatChunksForPrompt(effectiveRefs, input.responseFormat)
|
|
2025
|
+
].filter((s) => s.length > 0).join(`
|
|
2026
|
+
|
|
2027
|
+
`);
|
|
2028
|
+
const perTurnInput = {
|
|
2029
|
+
...input,
|
|
2030
|
+
messages: [
|
|
2031
|
+
{ role: "system", content: [{ type: "text", text: turnSystemPrompt }] },
|
|
2032
|
+
...history.filter((m) => m.role !== "system")
|
|
2033
|
+
],
|
|
2034
|
+
systemPrompt: turnSystemPrompt
|
|
2035
|
+
};
|
|
2036
|
+
const turnJobInput = await this.getJobInput(perTurnInput);
|
|
2037
|
+
const strategy = getAiProviderRegistry().getStrategy(model);
|
|
2038
|
+
for await (const event of strategy.executeStream(turnJobInput, context, this.runConfig.runnerId)) {
|
|
2039
|
+
if (event.type === "text-delta") {
|
|
2040
|
+
assistantText += event.textDelta;
|
|
2041
|
+
yield {
|
|
2042
|
+
...event,
|
|
2043
|
+
port: event.port ?? "text"
|
|
2044
|
+
};
|
|
2045
|
+
} else if (event.type === "finish") {} else {
|
|
2046
|
+
yield event;
|
|
2047
|
+
}
|
|
1541
2048
|
}
|
|
1542
2049
|
}
|
|
1543
|
-
iterations++;
|
|
1544
|
-
lastAssistantText = assistantText;
|
|
1545
2050
|
const assistantMsg = {
|
|
1546
2051
|
role: "assistant",
|
|
1547
2052
|
content: [{ type: "text", text: assistantText }]
|
|
1548
2053
|
};
|
|
1549
2054
|
history.push(assistantMsg);
|
|
2055
|
+
completedTurns = turn + 1;
|
|
1550
2056
|
yield {
|
|
1551
2057
|
type: "object-delta",
|
|
1552
2058
|
port: "messages",
|
|
@@ -1557,7 +2063,7 @@ class AiChatTask extends StreamingAiTask {
|
|
|
1557
2063
|
targetHumanId: "default",
|
|
1558
2064
|
kind: "elicit",
|
|
1559
2065
|
message: "",
|
|
1560
|
-
contentSchema:
|
|
2066
|
+
contentSchema: chatConnectorContentSchema2,
|
|
1561
2067
|
contentData: undefined,
|
|
1562
2068
|
expectsResponse: true,
|
|
1563
2069
|
mode: "multi-turn",
|
|
@@ -1588,26 +2094,68 @@ class AiChatTask extends StreamingAiTask {
|
|
|
1588
2094
|
}
|
|
1589
2095
|
yield {
|
|
1590
2096
|
type: "finish",
|
|
1591
|
-
data: {
|
|
1592
|
-
text: lastAssistantText,
|
|
1593
|
-
messages: [...history],
|
|
1594
|
-
iterations
|
|
1595
|
-
}
|
|
2097
|
+
data: { iterations: completedTurns }
|
|
1596
2098
|
};
|
|
1597
2099
|
}
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
2100
|
+
}
|
|
2101
|
+
function extractLastUserText(messages) {
|
|
2102
|
+
for (let i = messages.length - 1;i >= 0; i--) {
|
|
2103
|
+
const m = messages[i];
|
|
2104
|
+
if (!m || m.role !== "user")
|
|
2105
|
+
continue;
|
|
2106
|
+
const text = m.content.map((b) => b.type === "text" ? b.text : "").join(" ").trim();
|
|
2107
|
+
if (text.length > 0)
|
|
2108
|
+
return text;
|
|
2109
|
+
}
|
|
2110
|
+
return "";
|
|
2111
|
+
}
|
|
2112
|
+
function buildChunkReference(args) {
|
|
2113
|
+
const md = args.result.metadata ?? {};
|
|
2114
|
+
const title = md.doc_title ?? md.title ?? args.result.doc_id ?? "Untitled";
|
|
2115
|
+
const baseUrl = args.url ?? md.url ?? undefined;
|
|
2116
|
+
const url = withSectionAnchor(baseUrl, md.sectionTitles);
|
|
2117
|
+
const text = md.text ?? "";
|
|
2118
|
+
const snippet = text.length > 150 ? text.slice(0, 150).trim() + "…" : text;
|
|
2119
|
+
return {
|
|
2120
|
+
index: args.index,
|
|
2121
|
+
kbId: args.kbId,
|
|
2122
|
+
kbLabel: args.kbLabel,
|
|
2123
|
+
title,
|
|
2124
|
+
url,
|
|
2125
|
+
snippet,
|
|
2126
|
+
score: args.result.score
|
|
2127
|
+
};
|
|
2128
|
+
}
|
|
2129
|
+
function withSectionAnchor(url, sectionTitles) {
|
|
2130
|
+
if (!url)
|
|
2131
|
+
return url;
|
|
2132
|
+
if (url.includes("#"))
|
|
2133
|
+
return url;
|
|
2134
|
+
if (!sectionTitles || sectionTitles.length === 0)
|
|
2135
|
+
return url;
|
|
2136
|
+
const deepest = sectionTitles[sectionTitles.length - 1];
|
|
2137
|
+
if (typeof deepest !== "string")
|
|
2138
|
+
return url;
|
|
2139
|
+
const slug = slugifyHeading(deepest);
|
|
2140
|
+
if (slug.length === 0)
|
|
2141
|
+
return url;
|
|
2142
|
+
return `${url}#${slug}`;
|
|
2143
|
+
}
|
|
2144
|
+
function formatChunksForPrompt(refs, responseFormat) {
|
|
2145
|
+
return refs.map((r) => {
|
|
2146
|
+
const head = `[${r.index}] [${r.kbLabel}] (${r.title})`;
|
|
2147
|
+
if (responseFormat === "markdown" && r.url) {
|
|
2148
|
+
return `${head} <${r.url}>
|
|
2149
|
+
${r.snippet}`;
|
|
1604
2150
|
}
|
|
1605
|
-
return
|
|
1606
|
-
}
|
|
2151
|
+
return `${head} ${r.snippet}`;
|
|
2152
|
+
}).join(`
|
|
2153
|
+
|
|
2154
|
+
`);
|
|
1607
2155
|
}
|
|
1608
2156
|
|
|
1609
2157
|
// src/task/BackgroundRemovalTask.ts
|
|
1610
|
-
import { CreateWorkflow, Workflow } from "@workglow/task-graph";
|
|
2158
|
+
import { CreateWorkflow as CreateWorkflow2, Workflow as Workflow2 } from "@workglow/task-graph";
|
|
1611
2159
|
import { ImageValueSchema } from "@workglow/util/media";
|
|
1612
2160
|
|
|
1613
2161
|
// src/task/base/AiVisionTask.ts
|
|
@@ -1616,12 +2164,12 @@ class AiVisionTask extends AiTask {
|
|
|
1616
2164
|
}
|
|
1617
2165
|
|
|
1618
2166
|
// src/task/BackgroundRemovalTask.ts
|
|
1619
|
-
var
|
|
2167
|
+
var modelSchema3 = TypeModel("model:BackgroundRemovalTask");
|
|
1620
2168
|
var BackgroundRemovalInputSchema = {
|
|
1621
2169
|
type: "object",
|
|
1622
2170
|
properties: {
|
|
1623
2171
|
image: TypeImageInput,
|
|
1624
|
-
model:
|
|
2172
|
+
model: modelSchema3
|
|
1625
2173
|
},
|
|
1626
2174
|
required: ["image", "model"],
|
|
1627
2175
|
additionalProperties: false
|
|
@@ -1653,22 +2201,22 @@ class BackgroundRemovalTask extends AiVisionTask {
|
|
|
1653
2201
|
var backgroundRemoval = (input, config) => {
|
|
1654
2202
|
return new BackgroundRemovalTask(config).run(input);
|
|
1655
2203
|
};
|
|
1656
|
-
|
|
2204
|
+
Workflow2.prototype.backgroundRemoval = CreateWorkflow2(BackgroundRemovalTask);
|
|
1657
2205
|
|
|
1658
2206
|
// src/task/ChunkRetrievalTask.ts
|
|
1659
|
-
import { TypeKnowledgeBase } from "@workglow/knowledge-base";
|
|
1660
|
-
import { CreateWorkflow as
|
|
2207
|
+
import { TypeKnowledgeBase as TypeKnowledgeBase2 } from "@workglow/knowledge-base";
|
|
2208
|
+
import { CreateWorkflow as CreateWorkflow4, Task as Task3, Workflow as Workflow4 } from "@workglow/task-graph";
|
|
1661
2209
|
import {
|
|
1662
2210
|
isTypedArray,
|
|
1663
2211
|
TypedArraySchema as TypedArraySchema2
|
|
1664
2212
|
} from "@workglow/util/schema";
|
|
1665
2213
|
|
|
1666
2214
|
// src/task/TextEmbeddingTask.ts
|
|
1667
|
-
import { CreateWorkflow as
|
|
2215
|
+
import { CreateWorkflow as CreateWorkflow3, Workflow as Workflow3 } from "@workglow/task-graph";
|
|
1668
2216
|
import {
|
|
1669
2217
|
TypedArraySchema
|
|
1670
2218
|
} from "@workglow/util/schema";
|
|
1671
|
-
var
|
|
2219
|
+
var modelSchema4 = TypeModel("model:TextEmbeddingTask");
|
|
1672
2220
|
var TextEmbeddingInputSchema = {
|
|
1673
2221
|
type: "object",
|
|
1674
2222
|
properties: {
|
|
@@ -1677,7 +2225,7 @@ var TextEmbeddingInputSchema = {
|
|
|
1677
2225
|
title: "Text",
|
|
1678
2226
|
description: "The text to embed"
|
|
1679
2227
|
}),
|
|
1680
|
-
model:
|
|
2228
|
+
model: modelSchema4
|
|
1681
2229
|
},
|
|
1682
2230
|
required: ["text", "model"],
|
|
1683
2231
|
additionalProperties: false
|
|
@@ -1709,13 +2257,13 @@ class TextEmbeddingTask extends AiTask {
|
|
|
1709
2257
|
var textEmbedding = async (input, config) => {
|
|
1710
2258
|
return new TextEmbeddingTask(config).run(input);
|
|
1711
2259
|
};
|
|
1712
|
-
|
|
2260
|
+
Workflow3.prototype.textEmbedding = CreateWorkflow3(TextEmbeddingTask);
|
|
1713
2261
|
|
|
1714
2262
|
// src/task/ChunkRetrievalTask.ts
|
|
1715
|
-
var
|
|
2263
|
+
var inputSchema2 = {
|
|
1716
2264
|
type: "object",
|
|
1717
2265
|
properties: {
|
|
1718
|
-
knowledgeBase:
|
|
2266
|
+
knowledgeBase: TypeKnowledgeBase2({
|
|
1719
2267
|
title: "Knowledge Base",
|
|
1720
2268
|
description: "The knowledge base instance to search in"
|
|
1721
2269
|
}),
|
|
@@ -1788,7 +2336,7 @@ var inputSchema = {
|
|
|
1788
2336
|
else: {},
|
|
1789
2337
|
additionalProperties: false
|
|
1790
2338
|
};
|
|
1791
|
-
var
|
|
2339
|
+
var outputSchema2 = {
|
|
1792
2340
|
type: "object",
|
|
1793
2341
|
properties: {
|
|
1794
2342
|
chunks: {
|
|
@@ -1849,17 +2397,17 @@ var outputSchema = {
|
|
|
1849
2397
|
additionalProperties: false
|
|
1850
2398
|
};
|
|
1851
2399
|
|
|
1852
|
-
class ChunkRetrievalTask extends
|
|
2400
|
+
class ChunkRetrievalTask extends Task3 {
|
|
1853
2401
|
static type = "ChunkRetrievalTask";
|
|
1854
2402
|
static category = "RAG";
|
|
1855
2403
|
static title = "Chunk Retrieval";
|
|
1856
2404
|
static description = "End-to-end retrieval: embed query (if string) and search the knowledge base. Supports similarity and hybrid methods.";
|
|
1857
2405
|
static cacheable = true;
|
|
1858
2406
|
static inputSchema() {
|
|
1859
|
-
return
|
|
2407
|
+
return inputSchema2;
|
|
1860
2408
|
}
|
|
1861
2409
|
static outputSchema() {
|
|
1862
|
-
return
|
|
2410
|
+
return outputSchema2;
|
|
1863
2411
|
}
|
|
1864
2412
|
async execute(input, context) {
|
|
1865
2413
|
const {
|
|
@@ -1930,18 +2478,18 @@ class ChunkRetrievalTask extends Task2 {
|
|
|
1930
2478
|
var chunkRetrieval = (input, config) => {
|
|
1931
2479
|
return new ChunkRetrievalTask(config).run(input);
|
|
1932
2480
|
};
|
|
1933
|
-
|
|
2481
|
+
Workflow4.prototype.chunkRetrieval = CreateWorkflow4(ChunkRetrievalTask);
|
|
1934
2482
|
|
|
1935
2483
|
// src/task/ChunkVectorUpsertTask.ts
|
|
1936
|
-
import { ChunkRecordArraySchema, TypeKnowledgeBase as
|
|
1937
|
-
import { CreateWorkflow as
|
|
2484
|
+
import { ChunkRecordArraySchema, TypeKnowledgeBase as TypeKnowledgeBase3 } from "@workglow/knowledge-base";
|
|
2485
|
+
import { CreateWorkflow as CreateWorkflow5, Task as Task4, Workflow as Workflow5 } from "@workglow/task-graph";
|
|
1938
2486
|
import {
|
|
1939
2487
|
TypedArraySchema as TypedArraySchema3
|
|
1940
2488
|
} from "@workglow/util/schema";
|
|
1941
|
-
var
|
|
2489
|
+
var inputSchema3 = {
|
|
1942
2490
|
type: "object",
|
|
1943
2491
|
properties: {
|
|
1944
|
-
knowledgeBase:
|
|
2492
|
+
knowledgeBase: TypeKnowledgeBase3({
|
|
1945
2493
|
title: "Knowledge Base",
|
|
1946
2494
|
description: "The knowledge base instance to store vectors in"
|
|
1947
2495
|
}),
|
|
@@ -1959,7 +2507,7 @@ var inputSchema2 = {
|
|
|
1959
2507
|
required: ["knowledgeBase", "chunks", "vector"],
|
|
1960
2508
|
additionalProperties: false
|
|
1961
2509
|
};
|
|
1962
|
-
var
|
|
2510
|
+
var outputSchema3 = {
|
|
1963
2511
|
type: "object",
|
|
1964
2512
|
properties: {
|
|
1965
2513
|
count: {
|
|
@@ -1983,17 +2531,17 @@ var outputSchema2 = {
|
|
|
1983
2531
|
additionalProperties: false
|
|
1984
2532
|
};
|
|
1985
2533
|
|
|
1986
|
-
class ChunkVectorUpsertTask extends
|
|
2534
|
+
class ChunkVectorUpsertTask extends Task4 {
|
|
1987
2535
|
static type = "ChunkVectorUpsertTask";
|
|
1988
2536
|
static category = "Document";
|
|
1989
2537
|
static title = "Add to Vector Store";
|
|
1990
2538
|
static description = "Store chunks + their embeddings in a knowledge base (1:1 aligned)";
|
|
1991
2539
|
static cacheable = false;
|
|
1992
2540
|
static inputSchema() {
|
|
1993
|
-
return
|
|
2541
|
+
return inputSchema3;
|
|
1994
2542
|
}
|
|
1995
2543
|
static outputSchema() {
|
|
1996
|
-
return
|
|
2544
|
+
return outputSchema3;
|
|
1997
2545
|
}
|
|
1998
2546
|
async execute(input, context) {
|
|
1999
2547
|
const { knowledgeBase, chunks, vector, doc_title } = input;
|
|
@@ -2038,19 +2586,19 @@ class ChunkVectorUpsertTask extends Task3 {
|
|
|
2038
2586
|
var chunkVectorUpsert = (input, config) => {
|
|
2039
2587
|
return new ChunkVectorUpsertTask(config).run(input);
|
|
2040
2588
|
};
|
|
2041
|
-
|
|
2589
|
+
Workflow5.prototype.chunkVectorUpsert = CreateWorkflow5(ChunkVectorUpsertTask);
|
|
2042
2590
|
|
|
2043
2591
|
// src/task/ContextBuilderTask.ts
|
|
2044
2592
|
import { estimateTokens } from "@workglow/knowledge-base";
|
|
2045
2593
|
import {
|
|
2046
|
-
CreateWorkflow as
|
|
2047
|
-
Task as
|
|
2048
|
-
Workflow as
|
|
2594
|
+
CreateWorkflow as CreateWorkflow7,
|
|
2595
|
+
Task as Task5,
|
|
2596
|
+
Workflow as Workflow7
|
|
2049
2597
|
} from "@workglow/task-graph";
|
|
2050
2598
|
|
|
2051
2599
|
// src/task/CountTokensTask.ts
|
|
2052
|
-
import { CreateWorkflow as
|
|
2053
|
-
var
|
|
2600
|
+
import { CreateWorkflow as CreateWorkflow6, Workflow as Workflow6 } from "@workglow/task-graph";
|
|
2601
|
+
var modelSchema5 = TypeModel("model");
|
|
2054
2602
|
var CountTokensInputSchema = {
|
|
2055
2603
|
type: "object",
|
|
2056
2604
|
properties: {
|
|
@@ -2059,7 +2607,7 @@ var CountTokensInputSchema = {
|
|
|
2059
2607
|
title: "Text",
|
|
2060
2608
|
description: "The text to count tokens for"
|
|
2061
2609
|
},
|
|
2062
|
-
model:
|
|
2610
|
+
model: modelSchema5
|
|
2063
2611
|
},
|
|
2064
2612
|
required: ["text", "model"],
|
|
2065
2613
|
additionalProperties: false
|
|
@@ -2093,7 +2641,7 @@ class CountTokensTask extends AiTask {
|
|
|
2093
2641
|
var countTokens = async (input, config) => {
|
|
2094
2642
|
return new CountTokensTask(config).run(input);
|
|
2095
2643
|
};
|
|
2096
|
-
|
|
2644
|
+
Workflow6.prototype.countTokens = CreateWorkflow6(CountTokensTask);
|
|
2097
2645
|
|
|
2098
2646
|
// src/task/ContextBuilderTask.ts
|
|
2099
2647
|
var ContextFormat = {
|
|
@@ -2103,11 +2651,11 @@ var ContextFormat = {
|
|
|
2103
2651
|
MARKDOWN: "markdown",
|
|
2104
2652
|
JSON: "json"
|
|
2105
2653
|
};
|
|
2106
|
-
var
|
|
2654
|
+
var modelSchema6 = TypeModel("model", {
|
|
2107
2655
|
title: "Model",
|
|
2108
2656
|
description: "Model to use for token counting (optional, falls back to estimation)"
|
|
2109
2657
|
});
|
|
2110
|
-
var
|
|
2658
|
+
var inputSchema4 = {
|
|
2111
2659
|
type: "object",
|
|
2112
2660
|
properties: {
|
|
2113
2661
|
chunks: {
|
|
@@ -2167,12 +2715,12 @@ var inputSchema3 = {
|
|
|
2167
2715
|
|
|
2168
2716
|
`
|
|
2169
2717
|
},
|
|
2170
|
-
model:
|
|
2718
|
+
model: modelSchema6
|
|
2171
2719
|
},
|
|
2172
2720
|
required: ["chunks"],
|
|
2173
2721
|
additionalProperties: false
|
|
2174
2722
|
};
|
|
2175
|
-
var
|
|
2723
|
+
var outputSchema4 = {
|
|
2176
2724
|
type: "object",
|
|
2177
2725
|
properties: {
|
|
2178
2726
|
context: {
|
|
@@ -2200,17 +2748,17 @@ var outputSchema3 = {
|
|
|
2200
2748
|
additionalProperties: false
|
|
2201
2749
|
};
|
|
2202
2750
|
|
|
2203
|
-
class ContextBuilderTask extends
|
|
2751
|
+
class ContextBuilderTask extends Task5 {
|
|
2204
2752
|
static type = "ContextBuilderTask";
|
|
2205
2753
|
static category = "RAG";
|
|
2206
2754
|
static title = "Context Builder";
|
|
2207
2755
|
static description = "Format retrieved chunks into context for LLM prompts";
|
|
2208
2756
|
static cacheable = true;
|
|
2209
2757
|
static inputSchema() {
|
|
2210
|
-
return
|
|
2758
|
+
return inputSchema4;
|
|
2211
2759
|
}
|
|
2212
2760
|
static outputSchema() {
|
|
2213
|
-
return
|
|
2761
|
+
return outputSchema4;
|
|
2214
2762
|
}
|
|
2215
2763
|
async execute(input, context) {
|
|
2216
2764
|
return this.executePreview(input, context);
|
|
@@ -2396,15 +2944,15 @@ class ContextBuilderTask extends Task4 {
|
|
|
2396
2944
|
var contextBuilder = (input, config) => {
|
|
2397
2945
|
return new ContextBuilderTask(config).run(input);
|
|
2398
2946
|
};
|
|
2399
|
-
|
|
2947
|
+
Workflow7.prototype.contextBuilder = CreateWorkflow7(ContextBuilderTask);
|
|
2400
2948
|
|
|
2401
2949
|
// src/task/DocumentEnricherTask.ts
|
|
2402
2950
|
import { getChildren, hasChildren } from "@workglow/knowledge-base";
|
|
2403
|
-
import { CreateWorkflow as
|
|
2951
|
+
import { CreateWorkflow as CreateWorkflow10, Task as Task6, Workflow as Workflow10 } from "@workglow/task-graph";
|
|
2404
2952
|
|
|
2405
2953
|
// src/task/TextNamedEntityRecognitionTask.ts
|
|
2406
|
-
import { CreateWorkflow as
|
|
2407
|
-
var
|
|
2954
|
+
import { CreateWorkflow as CreateWorkflow8, Workflow as Workflow8 } from "@workglow/task-graph";
|
|
2955
|
+
var modelSchema7 = TypeModel("model:TextNamedEntityRecognitionTask");
|
|
2408
2956
|
var TextNamedEntityRecognitionInputSchema = {
|
|
2409
2957
|
type: "object",
|
|
2410
2958
|
properties: {
|
|
@@ -2423,7 +2971,7 @@ var TextNamedEntityRecognitionInputSchema = {
|
|
|
2423
2971
|
"x-ui-group": "Configuration",
|
|
2424
2972
|
"x-ui-group-open": false
|
|
2425
2973
|
},
|
|
2426
|
-
model:
|
|
2974
|
+
model: modelSchema7
|
|
2427
2975
|
},
|
|
2428
2976
|
required: ["text", "model"],
|
|
2429
2977
|
additionalProperties: false
|
|
@@ -2478,11 +3026,11 @@ class TextNamedEntityRecognitionTask extends AiTask {
|
|
|
2478
3026
|
var textNamedEntityRecognition = (input, config) => {
|
|
2479
3027
|
return new TextNamedEntityRecognitionTask(config).run(input);
|
|
2480
3028
|
};
|
|
2481
|
-
|
|
3029
|
+
Workflow8.prototype.textNamedEntityRecognition = CreateWorkflow8(TextNamedEntityRecognitionTask);
|
|
2482
3030
|
|
|
2483
3031
|
// src/task/TextSummaryTask.ts
|
|
2484
|
-
import { CreateWorkflow as
|
|
2485
|
-
var
|
|
3032
|
+
import { CreateWorkflow as CreateWorkflow9, Workflow as Workflow9 } from "@workglow/task-graph";
|
|
3033
|
+
var modelSchema8 = TypeModel("model:TextSummaryTask");
|
|
2486
3034
|
var TextSummaryInputSchema = {
|
|
2487
3035
|
type: "object",
|
|
2488
3036
|
properties: {
|
|
@@ -2491,7 +3039,7 @@ var TextSummaryInputSchema = {
|
|
|
2491
3039
|
title: "Text",
|
|
2492
3040
|
description: "The text to summarize"
|
|
2493
3041
|
},
|
|
2494
|
-
model:
|
|
3042
|
+
model: modelSchema8
|
|
2495
3043
|
},
|
|
2496
3044
|
required: ["text", "model"],
|
|
2497
3045
|
additionalProperties: false
|
|
@@ -2526,10 +3074,10 @@ class TextSummaryTask extends StreamingAiTask {
|
|
|
2526
3074
|
var textSummary = async (input, config) => {
|
|
2527
3075
|
return new TextSummaryTask(config).run(input);
|
|
2528
3076
|
};
|
|
2529
|
-
|
|
3077
|
+
Workflow9.prototype.textSummary = CreateWorkflow9(TextSummaryTask);
|
|
2530
3078
|
|
|
2531
3079
|
// src/task/DocumentEnricherTask.ts
|
|
2532
|
-
var
|
|
3080
|
+
var inputSchema5 = {
|
|
2533
3081
|
type: "object",
|
|
2534
3082
|
properties: {
|
|
2535
3083
|
doc_id: {
|
|
@@ -2573,7 +3121,7 @@ var inputSchema4 = {
|
|
|
2573
3121
|
required: [],
|
|
2574
3122
|
additionalProperties: false
|
|
2575
3123
|
};
|
|
2576
|
-
var
|
|
3124
|
+
var outputSchema5 = {
|
|
2577
3125
|
type: "object",
|
|
2578
3126
|
properties: {
|
|
2579
3127
|
doc_id: {
|
|
@@ -2600,17 +3148,17 @@ var outputSchema4 = {
|
|
|
2600
3148
|
additionalProperties: false
|
|
2601
3149
|
};
|
|
2602
3150
|
|
|
2603
|
-
class DocumentEnricherTask extends
|
|
3151
|
+
class DocumentEnricherTask extends Task6 {
|
|
2604
3152
|
static type = "DocumentEnricherTask";
|
|
2605
3153
|
static category = "Document";
|
|
2606
3154
|
static title = "Document Enricher";
|
|
2607
3155
|
static description = "Enrich document nodes with summaries and entities";
|
|
2608
3156
|
static cacheable = true;
|
|
2609
3157
|
static inputSchema() {
|
|
2610
|
-
return
|
|
3158
|
+
return inputSchema5;
|
|
2611
3159
|
}
|
|
2612
3160
|
static outputSchema() {
|
|
2613
|
-
return
|
|
3161
|
+
return outputSchema5;
|
|
2614
3162
|
}
|
|
2615
3163
|
async execute(input, context) {
|
|
2616
3164
|
const {
|
|
@@ -2759,19 +3307,19 @@ class DocumentEnricherTask extends Task5 {
|
|
|
2759
3307
|
var documentEnricher = (input, config) => {
|
|
2760
3308
|
return new DocumentEnricherTask(config).run(input);
|
|
2761
3309
|
};
|
|
2762
|
-
|
|
3310
|
+
Workflow10.prototype.documentEnricher = CreateWorkflow10(DocumentEnricherTask);
|
|
2763
3311
|
|
|
2764
3312
|
// src/task/DocumentUpsertTask.ts
|
|
2765
3313
|
import {
|
|
2766
3314
|
Document,
|
|
2767
3315
|
DocumentMetadataSchema,
|
|
2768
|
-
TypeKnowledgeBase as
|
|
3316
|
+
TypeKnowledgeBase as TypeKnowledgeBase4
|
|
2769
3317
|
} from "@workglow/knowledge-base";
|
|
2770
|
-
import { CreateWorkflow as
|
|
2771
|
-
var
|
|
3318
|
+
import { CreateWorkflow as CreateWorkflow11, Task as Task7, Workflow as Workflow11 } from "@workglow/task-graph";
|
|
3319
|
+
var inputSchema6 = {
|
|
2772
3320
|
type: "object",
|
|
2773
3321
|
properties: {
|
|
2774
|
-
knowledgeBase:
|
|
3322
|
+
knowledgeBase: TypeKnowledgeBase4({
|
|
2775
3323
|
title: "Knowledge Base",
|
|
2776
3324
|
description: "The knowledge base instance to store the document in"
|
|
2777
3325
|
}),
|
|
@@ -2799,7 +3347,7 @@ var inputSchema5 = {
|
|
|
2799
3347
|
required: ["knowledgeBase", "doc_id", "documentTree"],
|
|
2800
3348
|
additionalProperties: false
|
|
2801
3349
|
};
|
|
2802
|
-
var
|
|
3350
|
+
var outputSchema6 = {
|
|
2803
3351
|
type: "object",
|
|
2804
3352
|
properties: {
|
|
2805
3353
|
doc_id: {
|
|
@@ -2812,17 +3360,17 @@ var outputSchema5 = {
|
|
|
2812
3360
|
additionalProperties: false
|
|
2813
3361
|
};
|
|
2814
3362
|
|
|
2815
|
-
class DocumentUpsertTask extends
|
|
3363
|
+
class DocumentUpsertTask extends Task7 {
|
|
2816
3364
|
static type = "DocumentUpsertTask";
|
|
2817
3365
|
static category = "Document";
|
|
2818
3366
|
static title = "Add Document";
|
|
2819
3367
|
static description = "Persist a parsed document tree to a knowledge base";
|
|
2820
3368
|
static cacheable = false;
|
|
2821
3369
|
static inputSchema() {
|
|
2822
|
-
return
|
|
3370
|
+
return inputSchema6;
|
|
2823
3371
|
}
|
|
2824
3372
|
static outputSchema() {
|
|
2825
|
-
return
|
|
3373
|
+
return outputSchema6;
|
|
2826
3374
|
}
|
|
2827
3375
|
async execute(input, context) {
|
|
2828
3376
|
const { knowledgeBase, doc_id, documentTree, title, metadata } = input;
|
|
@@ -2845,15 +3393,15 @@ class DocumentUpsertTask extends Task6 {
|
|
|
2845
3393
|
var documentUpsert = (input, config) => {
|
|
2846
3394
|
return new DocumentUpsertTask(config).run(input);
|
|
2847
3395
|
};
|
|
2848
|
-
|
|
3396
|
+
Workflow11.prototype.documentUpsert = CreateWorkflow11(DocumentUpsertTask);
|
|
2849
3397
|
|
|
2850
3398
|
// src/task/DownloadModelTask.ts
|
|
2851
|
-
import { CreateWorkflow as
|
|
2852
|
-
var
|
|
3399
|
+
import { CreateWorkflow as CreateWorkflow12, Workflow as Workflow12 } from "@workglow/task-graph";
|
|
3400
|
+
var modelSchema9 = TypeModel("model");
|
|
2853
3401
|
var DownloadModelInputSchema = {
|
|
2854
3402
|
type: "object",
|
|
2855
3403
|
properties: {
|
|
2856
|
-
model:
|
|
3404
|
+
model: modelSchema9
|
|
2857
3405
|
},
|
|
2858
3406
|
required: ["model"],
|
|
2859
3407
|
additionalProperties: false
|
|
@@ -2861,7 +3409,7 @@ var DownloadModelInputSchema = {
|
|
|
2861
3409
|
var DownloadModelOutputSchema = {
|
|
2862
3410
|
type: "object",
|
|
2863
3411
|
properties: {
|
|
2864
|
-
model:
|
|
3412
|
+
model: modelSchema9
|
|
2865
3413
|
},
|
|
2866
3414
|
required: ["model"],
|
|
2867
3415
|
additionalProperties: false
|
|
@@ -2915,10 +3463,10 @@ class DownloadModelTask extends AiTask {
|
|
|
2915
3463
|
var downloadModel = (input, config) => {
|
|
2916
3464
|
return new DownloadModelTask(config).run(input);
|
|
2917
3465
|
};
|
|
2918
|
-
|
|
3466
|
+
Workflow12.prototype.downloadModel = CreateWorkflow12(DownloadModelTask);
|
|
2919
3467
|
|
|
2920
3468
|
// src/task/generation/ImageEditTask.ts
|
|
2921
|
-
import { CreateWorkflow as
|
|
3469
|
+
import { CreateWorkflow as CreateWorkflow13, Workflow as Workflow13 } from "@workglow/task-graph";
|
|
2922
3470
|
import { ImageValueSchema as ImageValueSchema3 } from "@workglow/util/media";
|
|
2923
3471
|
|
|
2924
3472
|
// src/task/base/AiImageOutputTask.ts
|
|
@@ -3050,11 +3598,11 @@ var AiImageOutputSchema = {
|
|
|
3050
3598
|
};
|
|
3051
3599
|
|
|
3052
3600
|
// src/task/generation/ImageEditTask.ts
|
|
3053
|
-
var
|
|
3601
|
+
var modelSchema10 = TypeModel("model:ImageEditTask");
|
|
3054
3602
|
var ImageEditInputSchema = {
|
|
3055
3603
|
type: "object",
|
|
3056
3604
|
properties: {
|
|
3057
|
-
model:
|
|
3605
|
+
model: modelSchema10,
|
|
3058
3606
|
prompt: {
|
|
3059
3607
|
type: "string",
|
|
3060
3608
|
title: "Prompt",
|
|
@@ -3102,11 +3650,11 @@ class ImageEditTask extends AiImageOutputTask {
|
|
|
3102
3650
|
}
|
|
3103
3651
|
}
|
|
3104
3652
|
var imageEdit = (input, config) => new ImageEditTask(config).run(input);
|
|
3105
|
-
|
|
3653
|
+
Workflow13.prototype.imageEdit = CreateWorkflow13(ImageEditTask);
|
|
3106
3654
|
|
|
3107
3655
|
// src/task/FaceDetectorTask.ts
|
|
3108
|
-
import { CreateWorkflow as
|
|
3109
|
-
var
|
|
3656
|
+
import { CreateWorkflow as CreateWorkflow14, Workflow as Workflow14 } from "@workglow/task-graph";
|
|
3657
|
+
var modelSchema11 = TypeModel("model:FaceDetectorTask");
|
|
3110
3658
|
var TypeBoundingBox2 = {
|
|
3111
3659
|
type: "object",
|
|
3112
3660
|
properties: {
|
|
@@ -3179,7 +3727,7 @@ var FaceDetectorInputSchema = {
|
|
|
3179
3727
|
type: "object",
|
|
3180
3728
|
properties: {
|
|
3181
3729
|
image: TypeImageInput,
|
|
3182
|
-
model:
|
|
3730
|
+
model: modelSchema11,
|
|
3183
3731
|
minDetectionConfidence: {
|
|
3184
3732
|
type: "number",
|
|
3185
3733
|
minimum: 0,
|
|
@@ -3233,11 +3781,11 @@ class FaceDetectorTask extends AiVisionTask {
|
|
|
3233
3781
|
var faceDetector = (input, config) => {
|
|
3234
3782
|
return new FaceDetectorTask(config).run(input);
|
|
3235
3783
|
};
|
|
3236
|
-
|
|
3784
|
+
Workflow14.prototype.faceDetector = CreateWorkflow14(FaceDetectorTask);
|
|
3237
3785
|
|
|
3238
3786
|
// src/task/FaceLandmarkerTask.ts
|
|
3239
|
-
import { CreateWorkflow as
|
|
3240
|
-
var
|
|
3787
|
+
import { CreateWorkflow as CreateWorkflow15, Workflow as Workflow15 } from "@workglow/task-graph";
|
|
3788
|
+
var modelSchema12 = TypeModel("model:FaceLandmarkerTask");
|
|
3241
3789
|
var TypeBlendshape = {
|
|
3242
3790
|
type: "object",
|
|
3243
3791
|
properties: {
|
|
@@ -3288,7 +3836,7 @@ var FaceLandmarkerInputSchema = {
|
|
|
3288
3836
|
type: "object",
|
|
3289
3837
|
properties: {
|
|
3290
3838
|
image: TypeImageInput,
|
|
3291
|
-
model:
|
|
3839
|
+
model: modelSchema12,
|
|
3292
3840
|
numFaces: {
|
|
3293
3841
|
type: "number",
|
|
3294
3842
|
minimum: 1,
|
|
@@ -3374,15 +3922,15 @@ class FaceLandmarkerTask extends AiVisionTask {
|
|
|
3374
3922
|
var faceLandmarker = (input, config) => {
|
|
3375
3923
|
return new FaceLandmarkerTask(config).run(input);
|
|
3376
3924
|
};
|
|
3377
|
-
|
|
3925
|
+
Workflow15.prototype.faceLandmarker = CreateWorkflow15(FaceLandmarkerTask);
|
|
3378
3926
|
|
|
3379
3927
|
// src/task/generation/ImageGenerateTask.ts
|
|
3380
|
-
import { CreateWorkflow as
|
|
3381
|
-
var
|
|
3928
|
+
import { CreateWorkflow as CreateWorkflow16, Workflow as Workflow16 } from "@workglow/task-graph";
|
|
3929
|
+
var modelSchema13 = TypeModel("model:ImageGenerateTask");
|
|
3382
3930
|
var ImageGenerateInputSchema = {
|
|
3383
3931
|
type: "object",
|
|
3384
3932
|
properties: {
|
|
3385
|
-
model:
|
|
3933
|
+
model: modelSchema13,
|
|
3386
3934
|
prompt: {
|
|
3387
3935
|
type: "string",
|
|
3388
3936
|
title: "Prompt",
|
|
@@ -3416,11 +3964,11 @@ class ImageGenerateTask extends AiImageOutputTask {
|
|
|
3416
3964
|
}
|
|
3417
3965
|
}
|
|
3418
3966
|
var imageGenerate = (input, config) => new ImageGenerateTask(config).run(input);
|
|
3419
|
-
|
|
3967
|
+
Workflow16.prototype.imageGenerate = CreateWorkflow16(ImageGenerateTask);
|
|
3420
3968
|
|
|
3421
3969
|
// src/task/GestureRecognizerTask.ts
|
|
3422
|
-
import { CreateWorkflow as
|
|
3423
|
-
var
|
|
3970
|
+
import { CreateWorkflow as CreateWorkflow17, Workflow as Workflow17 } from "@workglow/task-graph";
|
|
3971
|
+
var modelSchema14 = TypeModel("model:GestureRecognizerTask");
|
|
3424
3972
|
var TypeGesture = {
|
|
3425
3973
|
type: "object",
|
|
3426
3974
|
properties: {
|
|
@@ -3492,7 +4040,7 @@ var GestureRecognizerInputSchema = {
|
|
|
3492
4040
|
type: "object",
|
|
3493
4041
|
properties: {
|
|
3494
4042
|
image: TypeImageInput,
|
|
3495
|
-
model:
|
|
4043
|
+
model: modelSchema14,
|
|
3496
4044
|
numHands: {
|
|
3497
4045
|
type: "number",
|
|
3498
4046
|
minimum: 1,
|
|
@@ -3564,11 +4112,11 @@ class GestureRecognizerTask extends AiVisionTask {
|
|
|
3564
4112
|
var gestureRecognizer = (input, config) => {
|
|
3565
4113
|
return new GestureRecognizerTask(config).run(input);
|
|
3566
4114
|
};
|
|
3567
|
-
|
|
4115
|
+
Workflow17.prototype.gestureRecognizer = CreateWorkflow17(GestureRecognizerTask);
|
|
3568
4116
|
|
|
3569
4117
|
// src/task/HandLandmarkerTask.ts
|
|
3570
|
-
import { CreateWorkflow as
|
|
3571
|
-
var
|
|
4118
|
+
import { CreateWorkflow as CreateWorkflow18, Workflow as Workflow18 } from "@workglow/task-graph";
|
|
4119
|
+
var modelSchema15 = TypeModel("model:HandLandmarkerTask");
|
|
3572
4120
|
var TypeHandedness2 = {
|
|
3573
4121
|
type: "object",
|
|
3574
4122
|
properties: {
|
|
@@ -3617,7 +4165,7 @@ var HandLandmarkerInputSchema = {
|
|
|
3617
4165
|
type: "object",
|
|
3618
4166
|
properties: {
|
|
3619
4167
|
image: TypeImageInput,
|
|
3620
|
-
model:
|
|
4168
|
+
model: modelSchema15,
|
|
3621
4169
|
numHands: {
|
|
3622
4170
|
type: "number",
|
|
3623
4171
|
minimum: 1,
|
|
@@ -3689,22 +4237,23 @@ class HandLandmarkerTask extends AiVisionTask {
|
|
|
3689
4237
|
var handLandmarker = (input, config) => {
|
|
3690
4238
|
return new HandLandmarkerTask(config).run(input);
|
|
3691
4239
|
};
|
|
3692
|
-
|
|
4240
|
+
Workflow18.prototype.handLandmarker = CreateWorkflow18(HandLandmarkerTask);
|
|
3693
4241
|
|
|
3694
4242
|
// src/task/HierarchicalChunkerTask.ts
|
|
3695
4243
|
import {
|
|
3696
4244
|
ChunkRecordSchema,
|
|
3697
4245
|
estimateTokens as estimateTokens2,
|
|
3698
4246
|
getChildren as getChildren2,
|
|
3699
|
-
hasChildren as hasChildren2
|
|
4247
|
+
hasChildren as hasChildren2,
|
|
4248
|
+
NodeKind
|
|
3700
4249
|
} from "@workglow/knowledge-base";
|
|
3701
|
-
import { CreateWorkflow as
|
|
4250
|
+
import { CreateWorkflow as CreateWorkflow19, Task as Task8, Workflow as Workflow19 } from "@workglow/task-graph";
|
|
3702
4251
|
import { uuid4 } from "@workglow/util";
|
|
3703
|
-
var
|
|
4252
|
+
var modelSchema16 = TypeModel("model", {
|
|
3704
4253
|
title: "Model",
|
|
3705
4254
|
description: "Model to use for token counting"
|
|
3706
4255
|
});
|
|
3707
|
-
var
|
|
4256
|
+
var inputSchema7 = {
|
|
3708
4257
|
type: "object",
|
|
3709
4258
|
properties: {
|
|
3710
4259
|
doc_id: {
|
|
@@ -3746,12 +4295,12 @@ var inputSchema6 = {
|
|
|
3746
4295
|
description: "Strategy for chunking",
|
|
3747
4296
|
default: "hierarchical"
|
|
3748
4297
|
},
|
|
3749
|
-
model:
|
|
4298
|
+
model: modelSchema16
|
|
3750
4299
|
},
|
|
3751
4300
|
required: ["doc_id", "documentTree"],
|
|
3752
4301
|
additionalProperties: false
|
|
3753
4302
|
};
|
|
3754
|
-
var
|
|
4303
|
+
var outputSchema7 = {
|
|
3755
4304
|
type: "object",
|
|
3756
4305
|
properties: {
|
|
3757
4306
|
doc_id: {
|
|
@@ -3781,17 +4330,17 @@ var outputSchema6 = {
|
|
|
3781
4330
|
additionalProperties: false
|
|
3782
4331
|
};
|
|
3783
4332
|
|
|
3784
|
-
class HierarchicalChunkerTask extends
|
|
4333
|
+
class HierarchicalChunkerTask extends Task8 {
|
|
3785
4334
|
static type = "HierarchicalChunkerTask";
|
|
3786
4335
|
static category = "Document";
|
|
3787
4336
|
static title = "Hierarchical Chunker";
|
|
3788
4337
|
static description = "Chunk documents hierarchically respecting token budgets";
|
|
3789
4338
|
static cacheable = true;
|
|
3790
4339
|
static inputSchema() {
|
|
3791
|
-
return
|
|
4340
|
+
return inputSchema7;
|
|
3792
4341
|
}
|
|
3793
4342
|
static outputSchema() {
|
|
3794
|
-
return
|
|
4343
|
+
return outputSchema7;
|
|
3795
4344
|
}
|
|
3796
4345
|
async execute(input, context) {
|
|
3797
4346
|
const {
|
|
@@ -3828,7 +4377,7 @@ class HierarchicalChunkerTask extends Task7 {
|
|
|
3828
4377
|
}
|
|
3829
4378
|
const chunks = [];
|
|
3830
4379
|
if (strategy === "hierarchical") {
|
|
3831
|
-
await this.chunkHierarchically(root, [], doc_id, tokenBudget, chunks, countFn);
|
|
4380
|
+
await this.chunkHierarchically(root, [], [], doc_id, tokenBudget, chunks, countFn);
|
|
3832
4381
|
} else {
|
|
3833
4382
|
await this.chunkFlat(root, doc_id, tokenBudget, chunks, countFn);
|
|
3834
4383
|
}
|
|
@@ -3839,23 +4388,35 @@ class HierarchicalChunkerTask extends Task7 {
|
|
|
3839
4388
|
count: chunks.length
|
|
3840
4389
|
};
|
|
3841
4390
|
}
|
|
3842
|
-
async chunkHierarchically(node, nodePath, doc_id, tokenBudget, chunks, countFn) {
|
|
4391
|
+
async chunkHierarchically(node, nodePath, headingPath, doc_id, tokenBudget, chunks, countFn) {
|
|
3843
4392
|
const currentPath = [...nodePath, node.nodeId];
|
|
4393
|
+
const currentHeadings = node.kind === NodeKind.SECTION && typeof node.title === "string" && node.title.trim().length > 0 ? [...headingPath, node.title.trim()] : headingPath;
|
|
3844
4394
|
if (!hasChildren2(node)) {
|
|
3845
|
-
await this.chunkText(node.text, currentPath, doc_id, tokenBudget, chunks, node.nodeId, countFn);
|
|
4395
|
+
await this.chunkText(node.text, currentPath, currentHeadings, doc_id, tokenBudget, chunks, node.nodeId, countFn);
|
|
3846
4396
|
return;
|
|
3847
4397
|
}
|
|
3848
4398
|
const children = getChildren2(node);
|
|
3849
4399
|
for (const child of children) {
|
|
3850
|
-
await this.chunkHierarchically(child, currentPath, doc_id, tokenBudget, chunks, countFn);
|
|
4400
|
+
await this.chunkHierarchically(child, currentPath, currentHeadings, doc_id, tokenBudget, chunks, countFn);
|
|
3851
4401
|
}
|
|
3852
4402
|
}
|
|
3853
|
-
async chunkText(text, nodePath, doc_id, tokenBudget, chunks, leafNodeId, countFn) {
|
|
3854
|
-
|
|
4403
|
+
async chunkText(text, nodePath, headingPath, doc_id, tokenBudget, chunks, leafNodeId, countFn) {
|
|
4404
|
+
if (text.trim().length === 0)
|
|
4405
|
+
return;
|
|
4406
|
+
const budgetAfterReserved = tokenBudget.maxTokensPerChunk - tokenBudget.reservedTokens;
|
|
3855
4407
|
const overlapTokens = tokenBudget.overlapTokens;
|
|
3856
|
-
if (
|
|
4408
|
+
if (budgetAfterReserved <= 0) {
|
|
3857
4409
|
throw new Error(`Invalid token budget: reservedTokens (${tokenBudget.reservedTokens}) must be less than maxTokensPerChunk (${tokenBudget.maxTokensPerChunk})`);
|
|
3858
4410
|
}
|
|
4411
|
+
const breadcrumb = headingPath.join(" > ");
|
|
4412
|
+
const candidatePrefix = breadcrumb ? `${breadcrumb}
|
|
4413
|
+
|
|
4414
|
+
` : "";
|
|
4415
|
+
const prefixTokens = candidatePrefix ? await countFn(candidatePrefix) : 0;
|
|
4416
|
+
const usePrefix = prefixTokens > 0 && prefixTokens < budgetAfterReserved;
|
|
4417
|
+
const prefix = usePrefix ? candidatePrefix : "";
|
|
4418
|
+
const effectivePrefixTokens = usePrefix ? prefixTokens : 0;
|
|
4419
|
+
const maxTokens = budgetAfterReserved - effectivePrefixTokens;
|
|
3859
4420
|
if (overlapTokens >= maxTokens) {
|
|
3860
4421
|
throw new Error(`Invalid token budget: overlapTokens (${overlapTokens}) must be less than effective maxTokens (${maxTokens})`);
|
|
3861
4422
|
}
|
|
@@ -3864,9 +4425,11 @@ class HierarchicalChunkerTask extends Task7 {
|
|
|
3864
4425
|
chunks.push({
|
|
3865
4426
|
chunkId: uuid4(),
|
|
3866
4427
|
doc_id,
|
|
3867
|
-
text,
|
|
4428
|
+
text: prefix + text,
|
|
3868
4429
|
nodePath,
|
|
3869
|
-
depth: nodePath.length
|
|
4430
|
+
depth: nodePath.length,
|
|
4431
|
+
leafNodeId,
|
|
4432
|
+
sectionTitles: [...headingPath]
|
|
3870
4433
|
});
|
|
3871
4434
|
return;
|
|
3872
4435
|
}
|
|
@@ -3891,9 +4454,11 @@ class HierarchicalChunkerTask extends Task7 {
|
|
|
3891
4454
|
chunks.push({
|
|
3892
4455
|
chunkId: uuid4(),
|
|
3893
4456
|
doc_id,
|
|
3894
|
-
text: text.substring(startOffset, endOffset),
|
|
4457
|
+
text: prefix + text.substring(startOffset, endOffset),
|
|
3895
4458
|
nodePath,
|
|
3896
|
-
depth: nodePath.length
|
|
4459
|
+
depth: nodePath.length,
|
|
4460
|
+
leafNodeId,
|
|
4461
|
+
sectionTitles: [...headingPath]
|
|
3897
4462
|
});
|
|
3898
4463
|
if (endOffset >= text.length)
|
|
3899
4464
|
break;
|
|
@@ -3903,7 +4468,7 @@ class HierarchicalChunkerTask extends Task7 {
|
|
|
3903
4468
|
}
|
|
3904
4469
|
async chunkFlat(root, doc_id, tokenBudget, chunks, countFn) {
|
|
3905
4470
|
const allText = this.collectAllText(root);
|
|
3906
|
-
await this.chunkText(allText, [root.nodeId], doc_id, tokenBudget, chunks, root.nodeId, countFn);
|
|
4471
|
+
await this.chunkText(allText, [root.nodeId], [], doc_id, tokenBudget, chunks, root.nodeId, countFn);
|
|
3907
4472
|
}
|
|
3908
4473
|
collectAllText(node) {
|
|
3909
4474
|
const texts = [];
|
|
@@ -3925,15 +4490,15 @@ class HierarchicalChunkerTask extends Task7 {
|
|
|
3925
4490
|
var hierarchicalChunker = (input, config) => {
|
|
3926
4491
|
return new HierarchicalChunkerTask(config).run(input);
|
|
3927
4492
|
};
|
|
3928
|
-
|
|
4493
|
+
Workflow19.prototype.hierarchicalChunker = CreateWorkflow19(HierarchicalChunkerTask);
|
|
3929
4494
|
|
|
3930
4495
|
// src/task/HierarchyJoinTask.ts
|
|
3931
|
-
import { ChunkRecordArraySchema as ChunkRecordArraySchema2, TypeKnowledgeBase as
|
|
3932
|
-
import { CreateWorkflow as
|
|
3933
|
-
var
|
|
4496
|
+
import { ChunkRecordArraySchema as ChunkRecordArraySchema2, TypeKnowledgeBase as TypeKnowledgeBase5 } from "@workglow/knowledge-base";
|
|
4497
|
+
import { CreateWorkflow as CreateWorkflow20, Task as Task9, Workflow as Workflow20 } from "@workglow/task-graph";
|
|
4498
|
+
var inputSchema8 = {
|
|
3934
4499
|
type: "object",
|
|
3935
4500
|
properties: {
|
|
3936
|
-
knowledgeBase:
|
|
4501
|
+
knowledgeBase: TypeKnowledgeBase5({
|
|
3937
4502
|
title: "Knowledge Base",
|
|
3938
4503
|
description: "The knowledge base to query for hierarchy"
|
|
3939
4504
|
}),
|
|
@@ -3972,7 +4537,7 @@ var inputSchema7 = {
|
|
|
3972
4537
|
required: ["knowledgeBase", "metadata"],
|
|
3973
4538
|
additionalProperties: false
|
|
3974
4539
|
};
|
|
3975
|
-
var
|
|
4540
|
+
var outputSchema8 = {
|
|
3976
4541
|
type: "object",
|
|
3977
4542
|
properties: {
|
|
3978
4543
|
metadata: ChunkRecordArraySchema2,
|
|
@@ -4004,17 +4569,17 @@ var outputSchema7 = {
|
|
|
4004
4569
|
additionalProperties: false
|
|
4005
4570
|
};
|
|
4006
4571
|
|
|
4007
|
-
class HierarchyJoinTask extends
|
|
4572
|
+
class HierarchyJoinTask extends Task9 {
|
|
4008
4573
|
static type = "HierarchyJoinTask";
|
|
4009
4574
|
static category = "RAG";
|
|
4010
4575
|
static title = "Hierarchy Join";
|
|
4011
4576
|
static description = "Enrich retrieval metadata with document hierarchy context";
|
|
4012
4577
|
static cacheable = false;
|
|
4013
4578
|
static inputSchema() {
|
|
4014
|
-
return
|
|
4579
|
+
return inputSchema8;
|
|
4015
4580
|
}
|
|
4016
4581
|
static outputSchema() {
|
|
4017
|
-
return
|
|
4582
|
+
return outputSchema8;
|
|
4018
4583
|
}
|
|
4019
4584
|
async execute(input, context) {
|
|
4020
4585
|
const {
|
|
@@ -4100,15 +4665,15 @@ class HierarchyJoinTask extends Task8 {
|
|
|
4100
4665
|
var hierarchyJoin = (input, config) => {
|
|
4101
4666
|
return new HierarchyJoinTask(config).run(input);
|
|
4102
4667
|
};
|
|
4103
|
-
|
|
4668
|
+
Workflow20.prototype.hierarchyJoin = CreateWorkflow20(HierarchyJoinTask);
|
|
4104
4669
|
|
|
4105
4670
|
// src/task/KbToDocumentsTask.ts
|
|
4106
|
-
import { TypeKnowledgeBase as
|
|
4107
|
-
import { CreateWorkflow as
|
|
4108
|
-
var
|
|
4671
|
+
import { TypeKnowledgeBase as TypeKnowledgeBase6 } from "@workglow/knowledge-base";
|
|
4672
|
+
import { CreateWorkflow as CreateWorkflow21, Task as Task10, Workflow as Workflow21 } from "@workglow/task-graph";
|
|
4673
|
+
var inputSchema9 = {
|
|
4109
4674
|
type: "object",
|
|
4110
4675
|
properties: {
|
|
4111
|
-
knowledgeBase:
|
|
4676
|
+
knowledgeBase: TypeKnowledgeBase6({
|
|
4112
4677
|
title: "Knowledge Base",
|
|
4113
4678
|
description: "The knowledge base instance to list documents from"
|
|
4114
4679
|
}),
|
|
@@ -4122,7 +4687,7 @@ var inputSchema8 = {
|
|
|
4122
4687
|
required: ["knowledgeBase"],
|
|
4123
4688
|
additionalProperties: false
|
|
4124
4689
|
};
|
|
4125
|
-
var
|
|
4690
|
+
var outputSchema9 = {
|
|
4126
4691
|
type: "object",
|
|
4127
4692
|
properties: {
|
|
4128
4693
|
doc_id: {
|
|
@@ -4148,17 +4713,17 @@ var outputSchema8 = {
|
|
|
4148
4713
|
additionalProperties: false
|
|
4149
4714
|
};
|
|
4150
4715
|
|
|
4151
|
-
class KbToDocumentsTask extends
|
|
4716
|
+
class KbToDocumentsTask extends Task10 {
|
|
4152
4717
|
static type = "KbToDocumentsTask";
|
|
4153
4718
|
static category = "Document";
|
|
4154
4719
|
static title = "Knowledge Base to Documents";
|
|
4155
4720
|
static description = "List documents from a knowledge base, optionally filtering to only those that need embedding";
|
|
4156
4721
|
static cacheable = false;
|
|
4157
4722
|
static inputSchema() {
|
|
4158
|
-
return
|
|
4723
|
+
return inputSchema9;
|
|
4159
4724
|
}
|
|
4160
4725
|
static outputSchema() {
|
|
4161
|
-
return
|
|
4726
|
+
return outputSchema9;
|
|
4162
4727
|
}
|
|
4163
4728
|
async execute(input, context) {
|
|
4164
4729
|
const { knowledgeBase, onlyStale = true } = input;
|
|
@@ -4189,16 +4754,16 @@ class KbToDocumentsTask extends Task9 {
|
|
|
4189
4754
|
var kbToDocuments = (input, config) => {
|
|
4190
4755
|
return new KbToDocumentsTask(config).run(input);
|
|
4191
4756
|
};
|
|
4192
|
-
|
|
4757
|
+
Workflow21.prototype.kbToDocuments = CreateWorkflow21(KbToDocumentsTask);
|
|
4193
4758
|
|
|
4194
4759
|
// src/task/ImageClassificationTask.ts
|
|
4195
|
-
import { CreateWorkflow as
|
|
4196
|
-
var
|
|
4760
|
+
import { CreateWorkflow as CreateWorkflow22, Workflow as Workflow22 } from "@workglow/task-graph";
|
|
4761
|
+
var modelSchema17 = TypeModel("model:ImageClassificationTask");
|
|
4197
4762
|
var ImageClassificationInputSchema = {
|
|
4198
4763
|
type: "object",
|
|
4199
4764
|
properties: {
|
|
4200
4765
|
image: TypeImageInput,
|
|
4201
|
-
model:
|
|
4766
|
+
model: modelSchema17,
|
|
4202
4767
|
categories: {
|
|
4203
4768
|
type: "array",
|
|
4204
4769
|
items: {
|
|
@@ -4252,19 +4817,19 @@ class ImageClassificationTask extends AiVisionTask {
|
|
|
4252
4817
|
var imageClassification = (input, config) => {
|
|
4253
4818
|
return new ImageClassificationTask(config).run(input);
|
|
4254
4819
|
};
|
|
4255
|
-
|
|
4820
|
+
Workflow22.prototype.imageClassification = CreateWorkflow22(ImageClassificationTask);
|
|
4256
4821
|
|
|
4257
4822
|
// src/task/ImageEmbeddingTask.ts
|
|
4258
|
-
import { CreateWorkflow as
|
|
4823
|
+
import { CreateWorkflow as CreateWorkflow23, Workflow as Workflow23 } from "@workglow/task-graph";
|
|
4259
4824
|
import {
|
|
4260
4825
|
TypedArraySchema as TypedArraySchema4
|
|
4261
4826
|
} from "@workglow/util/schema";
|
|
4262
|
-
var
|
|
4827
|
+
var modelSchema18 = TypeModel("model:ImageEmbeddingTask");
|
|
4263
4828
|
var ImageEmbeddingInputSchema = {
|
|
4264
4829
|
type: "object",
|
|
4265
4830
|
properties: {
|
|
4266
4831
|
image: TypeSingleOrArray(TypeImageInput),
|
|
4267
|
-
model:
|
|
4832
|
+
model: modelSchema18
|
|
4268
4833
|
},
|
|
4269
4834
|
required: ["image", "model"],
|
|
4270
4835
|
additionalProperties: false
|
|
@@ -4296,16 +4861,16 @@ class ImageEmbeddingTask extends AiVisionTask {
|
|
|
4296
4861
|
var imageEmbedding = (input, config) => {
|
|
4297
4862
|
return new ImageEmbeddingTask(config).run(input);
|
|
4298
4863
|
};
|
|
4299
|
-
|
|
4864
|
+
Workflow23.prototype.imageEmbedding = CreateWorkflow23(ImageEmbeddingTask);
|
|
4300
4865
|
|
|
4301
4866
|
// src/task/ImageSegmentationTask.ts
|
|
4302
|
-
import { CreateWorkflow as
|
|
4303
|
-
var
|
|
4867
|
+
import { CreateWorkflow as CreateWorkflow24, Workflow as Workflow24 } from "@workglow/task-graph";
|
|
4868
|
+
var modelSchema19 = TypeModel("model:ImageSegmentationTask");
|
|
4304
4869
|
var ImageSegmentationInputSchema = {
|
|
4305
4870
|
type: "object",
|
|
4306
4871
|
properties: {
|
|
4307
4872
|
image: TypeImageInput,
|
|
4308
|
-
model:
|
|
4873
|
+
model: modelSchema19,
|
|
4309
4874
|
threshold: {
|
|
4310
4875
|
type: "number",
|
|
4311
4876
|
title: "Threshold",
|
|
@@ -4384,11 +4949,11 @@ class ImageSegmentationTask extends AiVisionTask {
|
|
|
4384
4949
|
var imageSegmentation = (input, config) => {
|
|
4385
4950
|
return new ImageSegmentationTask(config).run(input);
|
|
4386
4951
|
};
|
|
4387
|
-
|
|
4952
|
+
Workflow24.prototype.imageSegmentation = CreateWorkflow24(ImageSegmentationTask);
|
|
4388
4953
|
|
|
4389
4954
|
// src/task/ImageToTextTask.ts
|
|
4390
|
-
import { CreateWorkflow as
|
|
4391
|
-
var
|
|
4955
|
+
import { CreateWorkflow as CreateWorkflow25, Workflow as Workflow25 } from "@workglow/task-graph";
|
|
4956
|
+
var modelSchema20 = TypeModel("model:ImageToTextTask");
|
|
4392
4957
|
var generatedTextSchema = {
|
|
4393
4958
|
type: "string",
|
|
4394
4959
|
title: "Text",
|
|
@@ -4398,7 +4963,7 @@ var ImageToTextInputSchema = {
|
|
|
4398
4963
|
type: "object",
|
|
4399
4964
|
properties: {
|
|
4400
4965
|
image: TypeImageInput,
|
|
4401
|
-
model:
|
|
4966
|
+
model: modelSchema20,
|
|
4402
4967
|
maxTokens: {
|
|
4403
4968
|
type: "number",
|
|
4404
4969
|
title: "Max Tokens",
|
|
@@ -4439,15 +5004,15 @@ class ImageToTextTask extends AiVisionTask {
|
|
|
4439
5004
|
var imageToText = (input, config) => {
|
|
4440
5005
|
return new ImageToTextTask(config).run(input);
|
|
4441
5006
|
};
|
|
4442
|
-
|
|
5007
|
+
Workflow25.prototype.imageToText = CreateWorkflow25(ImageToTextTask);
|
|
4443
5008
|
|
|
4444
5009
|
// src/task/ModelInfoTask.ts
|
|
4445
|
-
import { CreateWorkflow as
|
|
4446
|
-
var
|
|
5010
|
+
import { CreateWorkflow as CreateWorkflow26, Workflow as Workflow26 } from "@workglow/task-graph";
|
|
5011
|
+
var modelSchema21 = TypeModel("model");
|
|
4447
5012
|
var ModelInfoInputSchema = {
|
|
4448
5013
|
type: "object",
|
|
4449
5014
|
properties: {
|
|
4450
|
-
model:
|
|
5015
|
+
model: modelSchema21,
|
|
4451
5016
|
detail: {
|
|
4452
5017
|
type: "string",
|
|
4453
5018
|
enum: ["cached_status", "files", "files_with_metadata", "dimensions"],
|
|
@@ -4460,7 +5025,7 @@ var ModelInfoInputSchema = {
|
|
|
4460
5025
|
var ModelInfoOutputSchema = {
|
|
4461
5026
|
type: "object",
|
|
4462
5027
|
properties: {
|
|
4463
|
-
model:
|
|
5028
|
+
model: modelSchema21,
|
|
4464
5029
|
is_local: { type: "boolean" },
|
|
4465
5030
|
is_remote: { type: "boolean" },
|
|
4466
5031
|
supports_browser: { type: "boolean" },
|
|
@@ -4518,10 +5083,10 @@ class ModelInfoTask extends AiTask {
|
|
|
4518
5083
|
var modelInfo = (input, config) => {
|
|
4519
5084
|
return new ModelInfoTask(config).run(input);
|
|
4520
5085
|
};
|
|
4521
|
-
|
|
5086
|
+
Workflow26.prototype.modelInfo = CreateWorkflow26(ModelInfoTask);
|
|
4522
5087
|
|
|
4523
5088
|
// src/task/ModelSearchTask.ts
|
|
4524
|
-
import { CreateWorkflow as
|
|
5089
|
+
import { CreateWorkflow as CreateWorkflow27, Task as Task11, Workflow as Workflow27 } from "@workglow/task-graph";
|
|
4525
5090
|
var ModelSearchInputSchema = {
|
|
4526
5091
|
type: "object",
|
|
4527
5092
|
properties: {
|
|
@@ -4594,7 +5159,7 @@ var ModelSearchOutputSchema = {
|
|
|
4594
5159
|
additionalProperties: false
|
|
4595
5160
|
};
|
|
4596
5161
|
|
|
4597
|
-
class ModelSearchTask extends
|
|
5162
|
+
class ModelSearchTask extends Task11 {
|
|
4598
5163
|
static type = "ModelSearchTask";
|
|
4599
5164
|
static category = "AI Model";
|
|
4600
5165
|
static title = "Model Search";
|
|
@@ -4620,11 +5185,11 @@ class ModelSearchTask extends Task10 {
|
|
|
4620
5185
|
var modelSearch = (input, config) => {
|
|
4621
5186
|
return new ModelSearchTask(config).run(input);
|
|
4622
5187
|
};
|
|
4623
|
-
|
|
5188
|
+
Workflow27.prototype.modelSearch = CreateWorkflow27(ModelSearchTask);
|
|
4624
5189
|
|
|
4625
5190
|
// src/task/ObjectDetectionTask.ts
|
|
4626
|
-
import { CreateWorkflow as
|
|
4627
|
-
var
|
|
5191
|
+
import { CreateWorkflow as CreateWorkflow28, Workflow as Workflow28 } from "@workglow/task-graph";
|
|
5192
|
+
var modelSchema22 = TypeModel("model:ObjectDetectionTask");
|
|
4628
5193
|
var detectionSchema = {
|
|
4629
5194
|
type: "object",
|
|
4630
5195
|
properties: {
|
|
@@ -4649,7 +5214,7 @@ var ObjectDetectionInputSchema = {
|
|
|
4649
5214
|
type: "object",
|
|
4650
5215
|
properties: {
|
|
4651
5216
|
image: TypeImageInput,
|
|
4652
|
-
model:
|
|
5217
|
+
model: modelSchema22,
|
|
4653
5218
|
labels: {
|
|
4654
5219
|
type: "array",
|
|
4655
5220
|
items: {
|
|
@@ -4703,11 +5268,11 @@ class ObjectDetectionTask extends AiVisionTask {
|
|
|
4703
5268
|
var objectDetection = (input, config) => {
|
|
4704
5269
|
return new ObjectDetectionTask(config).run(input);
|
|
4705
5270
|
};
|
|
4706
|
-
|
|
5271
|
+
Workflow28.prototype.objectDetection = CreateWorkflow28(ObjectDetectionTask);
|
|
4707
5272
|
|
|
4708
5273
|
// src/task/PoseLandmarkerTask.ts
|
|
4709
|
-
import { CreateWorkflow as
|
|
4710
|
-
var
|
|
5274
|
+
import { CreateWorkflow as CreateWorkflow29, Workflow as Workflow29 } from "@workglow/task-graph";
|
|
5275
|
+
var modelSchema23 = TypeModel("model:PoseLandmarkerTask");
|
|
4711
5276
|
var TypeSegmentationMask = {
|
|
4712
5277
|
type: "object",
|
|
4713
5278
|
properties: {
|
|
@@ -4754,7 +5319,7 @@ var PoseLandmarkerInputSchema = {
|
|
|
4754
5319
|
type: "object",
|
|
4755
5320
|
properties: {
|
|
4756
5321
|
image: TypeImageInput,
|
|
4757
|
-
model:
|
|
5322
|
+
model: modelSchema23,
|
|
4758
5323
|
numPoses: {
|
|
4759
5324
|
type: "number",
|
|
4760
5325
|
minimum: 1,
|
|
@@ -4833,15 +5398,15 @@ class PoseLandmarkerTask extends AiVisionTask {
|
|
|
4833
5398
|
var poseLandmarker = (input, config) => {
|
|
4834
5399
|
return new PoseLandmarkerTask(config).run(input);
|
|
4835
5400
|
};
|
|
4836
|
-
|
|
5401
|
+
Workflow29.prototype.poseLandmarker = CreateWorkflow29(PoseLandmarkerTask);
|
|
4837
5402
|
|
|
4838
5403
|
// src/task/QueryExpanderTask.ts
|
|
4839
|
-
import { CreateWorkflow as
|
|
5404
|
+
import { CreateWorkflow as CreateWorkflow30, Task as Task12, Workflow as Workflow30 } from "@workglow/task-graph";
|
|
4840
5405
|
var QueryExpansionMethod = {
|
|
4841
5406
|
MULTI_QUERY: "multi-query",
|
|
4842
5407
|
SYNONYMS: "synonyms"
|
|
4843
5408
|
};
|
|
4844
|
-
var
|
|
5409
|
+
var inputSchema10 = {
|
|
4845
5410
|
type: "object",
|
|
4846
5411
|
properties: {
|
|
4847
5412
|
query: {
|
|
@@ -4868,7 +5433,7 @@ var inputSchema9 = {
|
|
|
4868
5433
|
required: ["query"],
|
|
4869
5434
|
additionalProperties: false
|
|
4870
5435
|
};
|
|
4871
|
-
var
|
|
5436
|
+
var outputSchema10 = {
|
|
4872
5437
|
type: "object",
|
|
4873
5438
|
properties: {
|
|
4874
5439
|
query: {
|
|
@@ -4897,17 +5462,17 @@ var outputSchema9 = {
|
|
|
4897
5462
|
additionalProperties: false
|
|
4898
5463
|
};
|
|
4899
5464
|
|
|
4900
|
-
class QueryExpanderTask extends
|
|
5465
|
+
class QueryExpanderTask extends Task12 {
|
|
4901
5466
|
static type = "QueryExpanderTask";
|
|
4902
5467
|
static category = "RAG";
|
|
4903
5468
|
static title = "Query Expander";
|
|
4904
5469
|
static description = "Expand queries to improve retrieval coverage";
|
|
4905
5470
|
static cacheable = true;
|
|
4906
5471
|
static inputSchema() {
|
|
4907
|
-
return
|
|
5472
|
+
return inputSchema10;
|
|
4908
5473
|
}
|
|
4909
5474
|
static outputSchema() {
|
|
4910
|
-
return
|
|
5475
|
+
return outputSchema10;
|
|
4911
5476
|
}
|
|
4912
5477
|
async execute(input, context) {
|
|
4913
5478
|
const { query, method = QueryExpansionMethod.MULTI_QUERY, numVariations = 3 } = input;
|
|
@@ -5006,11 +5571,11 @@ class QueryExpanderTask extends Task11 {
|
|
|
5006
5571
|
var queryExpander = (input, config) => {
|
|
5007
5572
|
return new QueryExpanderTask(config).run(input);
|
|
5008
5573
|
};
|
|
5009
|
-
|
|
5574
|
+
Workflow30.prototype.queryExpander = CreateWorkflow30(QueryExpanderTask);
|
|
5010
5575
|
|
|
5011
5576
|
// src/task/RerankerTask.ts
|
|
5012
|
-
import { CreateWorkflow as
|
|
5013
|
-
var
|
|
5577
|
+
import { CreateWorkflow as CreateWorkflow31, Task as Task13, Workflow as Workflow31 } from "@workglow/task-graph";
|
|
5578
|
+
var inputSchema11 = {
|
|
5014
5579
|
type: "object",
|
|
5015
5580
|
properties: {
|
|
5016
5581
|
query: {
|
|
@@ -5057,7 +5622,7 @@ var inputSchema10 = {
|
|
|
5057
5622
|
required: ["query", "chunks"],
|
|
5058
5623
|
additionalProperties: false
|
|
5059
5624
|
};
|
|
5060
|
-
var
|
|
5625
|
+
var outputSchema11 = {
|
|
5061
5626
|
type: "object",
|
|
5062
5627
|
properties: {
|
|
5063
5628
|
chunks: {
|
|
@@ -5098,17 +5663,17 @@ var outputSchema10 = {
|
|
|
5098
5663
|
additionalProperties: false
|
|
5099
5664
|
};
|
|
5100
5665
|
|
|
5101
|
-
class RerankerTask extends
|
|
5666
|
+
class RerankerTask extends Task13 {
|
|
5102
5667
|
static type = "RerankerTask";
|
|
5103
5668
|
static category = "RAG";
|
|
5104
5669
|
static title = "Reranker";
|
|
5105
5670
|
static description = "Rerank retrieved chunks to improve relevance";
|
|
5106
5671
|
static cacheable = true;
|
|
5107
5672
|
static inputSchema() {
|
|
5108
|
-
return
|
|
5673
|
+
return inputSchema11;
|
|
5109
5674
|
}
|
|
5110
5675
|
static outputSchema() {
|
|
5111
|
-
return
|
|
5676
|
+
return outputSchema11;
|
|
5112
5677
|
}
|
|
5113
5678
|
async execute(input, context) {
|
|
5114
5679
|
const { query, chunks, scores = [], metadata = [], topK, method = "simple" } = input;
|
|
@@ -5171,13 +5736,13 @@ class RerankerTask extends Task12 {
|
|
|
5171
5736
|
var reranker = (input, config) => {
|
|
5172
5737
|
return new RerankerTask(config).run(input);
|
|
5173
5738
|
};
|
|
5174
|
-
|
|
5739
|
+
Workflow31.prototype.reranker = CreateWorkflow31(RerankerTask);
|
|
5175
5740
|
|
|
5176
5741
|
// src/task/StructuralParserTask.ts
|
|
5177
5742
|
import { StructuralParser } from "@workglow/knowledge-base";
|
|
5178
|
-
import { CreateWorkflow as
|
|
5743
|
+
import { CreateWorkflow as CreateWorkflow32, Task as Task14, Workflow as Workflow32 } from "@workglow/task-graph";
|
|
5179
5744
|
import { uuid4 as uuid42 } from "@workglow/util";
|
|
5180
|
-
var
|
|
5745
|
+
var inputSchema12 = {
|
|
5181
5746
|
type: "object",
|
|
5182
5747
|
properties: {
|
|
5183
5748
|
text: {
|
|
@@ -5211,7 +5776,7 @@ var inputSchema11 = {
|
|
|
5211
5776
|
required: ["text", "title"],
|
|
5212
5777
|
additionalProperties: false
|
|
5213
5778
|
};
|
|
5214
|
-
var
|
|
5779
|
+
var outputSchema12 = {
|
|
5215
5780
|
type: "object",
|
|
5216
5781
|
properties: {
|
|
5217
5782
|
doc_id: {
|
|
@@ -5235,17 +5800,17 @@ var outputSchema11 = {
|
|
|
5235
5800
|
additionalProperties: false
|
|
5236
5801
|
};
|
|
5237
5802
|
|
|
5238
|
-
class StructuralParserTask extends
|
|
5803
|
+
class StructuralParserTask extends Task14 {
|
|
5239
5804
|
static type = "StructuralParserTask";
|
|
5240
5805
|
static category = "Document";
|
|
5241
5806
|
static title = "Structural Parser";
|
|
5242
5807
|
static description = "Parse documents into hierarchical tree structure";
|
|
5243
5808
|
static cacheable = true;
|
|
5244
5809
|
static inputSchema() {
|
|
5245
|
-
return
|
|
5810
|
+
return inputSchema12;
|
|
5246
5811
|
}
|
|
5247
5812
|
static outputSchema() {
|
|
5248
|
-
return
|
|
5813
|
+
return outputSchema12;
|
|
5249
5814
|
}
|
|
5250
5815
|
async execute(input, context) {
|
|
5251
5816
|
const { text, title, format = "auto", sourceUri, doc_id: providedDocId } = input;
|
|
@@ -5278,16 +5843,16 @@ class StructuralParserTask extends Task13 {
|
|
|
5278
5843
|
var structuralParser = (input, config) => {
|
|
5279
5844
|
return new StructuralParserTask(config).run(input);
|
|
5280
5845
|
};
|
|
5281
|
-
|
|
5846
|
+
Workflow32.prototype.structuralParser = CreateWorkflow32(StructuralParserTask);
|
|
5282
5847
|
|
|
5283
5848
|
// src/task/StructuredGenerationTask.ts
|
|
5284
|
-
import { CreateWorkflow as
|
|
5849
|
+
import { CreateWorkflow as CreateWorkflow33, TaskConfigurationError as TaskConfigurationError4, TaskError, Workflow as Workflow33 } from "@workglow/task-graph";
|
|
5285
5850
|
import { compileSchema as compileSchema2 } from "@workglow/util/schema";
|
|
5286
|
-
var
|
|
5851
|
+
var modelSchema24 = TypeModel("model:StructuredGenerationTask");
|
|
5287
5852
|
var StructuredGenerationInputSchema = {
|
|
5288
5853
|
type: "object",
|
|
5289
5854
|
properties: {
|
|
5290
|
-
model:
|
|
5855
|
+
model: modelSchema24,
|
|
5291
5856
|
prompt: {
|
|
5292
5857
|
type: "string",
|
|
5293
5858
|
title: "Prompt",
|
|
@@ -5456,18 +6021,18 @@ class StructuredGenerationTask extends StreamingAiTask {
|
|
|
5456
6021
|
var structuredGeneration = (input, config) => {
|
|
5457
6022
|
return new StructuredGenerationTask(config).run(input);
|
|
5458
6023
|
};
|
|
5459
|
-
|
|
6024
|
+
Workflow33.prototype.structuredGeneration = CreateWorkflow33(StructuredGenerationTask);
|
|
5460
6025
|
|
|
5461
6026
|
// src/task/TextChunkerTask.ts
|
|
5462
6027
|
import { ChunkRecordArraySchema as ChunkRecordArraySchema3 } from "@workglow/knowledge-base";
|
|
5463
|
-
import { CreateWorkflow as
|
|
6028
|
+
import { CreateWorkflow as CreateWorkflow34, Task as Task15, Workflow as Workflow34 } from "@workglow/task-graph";
|
|
5464
6029
|
var ChunkingStrategy = {
|
|
5465
6030
|
FIXED: "fixed",
|
|
5466
6031
|
SENTENCE: "sentence",
|
|
5467
6032
|
PARAGRAPH: "paragraph",
|
|
5468
6033
|
SEMANTIC: "semantic"
|
|
5469
6034
|
};
|
|
5470
|
-
var
|
|
6035
|
+
var inputSchema13 = {
|
|
5471
6036
|
type: "object",
|
|
5472
6037
|
properties: {
|
|
5473
6038
|
text: {
|
|
@@ -5505,7 +6070,7 @@ var inputSchema12 = {
|
|
|
5505
6070
|
required: ["text"],
|
|
5506
6071
|
additionalProperties: false
|
|
5507
6072
|
};
|
|
5508
|
-
var
|
|
6073
|
+
var outputSchema13 = {
|
|
5509
6074
|
type: "object",
|
|
5510
6075
|
properties: {
|
|
5511
6076
|
doc_id: {
|
|
@@ -5530,17 +6095,17 @@ var outputSchema12 = {
|
|
|
5530
6095
|
additionalProperties: false
|
|
5531
6096
|
};
|
|
5532
6097
|
|
|
5533
|
-
class TextChunkerTask extends
|
|
6098
|
+
class TextChunkerTask extends Task15 {
|
|
5534
6099
|
static type = "TextChunkerTask";
|
|
5535
6100
|
static category = "Document";
|
|
5536
6101
|
static title = "Text Chunker";
|
|
5537
6102
|
static description = "Splits text into chunks using various strategies (fixed, sentence, paragraph)";
|
|
5538
6103
|
static cacheable = true;
|
|
5539
6104
|
static inputSchema() {
|
|
5540
|
-
return
|
|
6105
|
+
return inputSchema13;
|
|
5541
6106
|
}
|
|
5542
6107
|
static outputSchema() {
|
|
5543
|
-
return
|
|
6108
|
+
return outputSchema13;
|
|
5544
6109
|
}
|
|
5545
6110
|
async execute(input, context) {
|
|
5546
6111
|
const {
|
|
@@ -5710,11 +6275,11 @@ class TextChunkerTask extends Task14 {
|
|
|
5710
6275
|
var textChunker = (input, config) => {
|
|
5711
6276
|
return new TextChunkerTask(config).run(input);
|
|
5712
6277
|
};
|
|
5713
|
-
|
|
6278
|
+
Workflow34.prototype.textChunker = CreateWorkflow34(TextChunkerTask);
|
|
5714
6279
|
|
|
5715
6280
|
// src/task/TextClassificationTask.ts
|
|
5716
|
-
import { CreateWorkflow as
|
|
5717
|
-
var
|
|
6281
|
+
import { CreateWorkflow as CreateWorkflow35, Workflow as Workflow35 } from "@workglow/task-graph";
|
|
6282
|
+
var modelSchema25 = TypeModel("model:TextClassificationTask");
|
|
5718
6283
|
var TextClassificationInputSchema = {
|
|
5719
6284
|
type: "object",
|
|
5720
6285
|
properties: {
|
|
@@ -5741,7 +6306,7 @@ var TextClassificationInputSchema = {
|
|
|
5741
6306
|
description: "The maximum number of categories to return",
|
|
5742
6307
|
"x-ui-group": "Configuration"
|
|
5743
6308
|
},
|
|
5744
|
-
model:
|
|
6309
|
+
model: modelSchema25
|
|
5745
6310
|
},
|
|
5746
6311
|
required: ["text", "model"],
|
|
5747
6312
|
additionalProperties: false
|
|
@@ -5791,11 +6356,11 @@ class TextClassificationTask extends AiTask {
|
|
|
5791
6356
|
var textClassification = (input, config) => {
|
|
5792
6357
|
return new TextClassificationTask(config).run(input);
|
|
5793
6358
|
};
|
|
5794
|
-
|
|
6359
|
+
Workflow35.prototype.textClassification = CreateWorkflow35(TextClassificationTask);
|
|
5795
6360
|
|
|
5796
6361
|
// src/task/TextFillMaskTask.ts
|
|
5797
|
-
import { CreateWorkflow as
|
|
5798
|
-
var
|
|
6362
|
+
import { CreateWorkflow as CreateWorkflow36, Workflow as Workflow36 } from "@workglow/task-graph";
|
|
6363
|
+
var modelSchema26 = TypeModel("model:TextFillMaskTask");
|
|
5799
6364
|
var TextFillMaskInputSchema = {
|
|
5800
6365
|
type: "object",
|
|
5801
6366
|
properties: {
|
|
@@ -5804,7 +6369,7 @@ var TextFillMaskInputSchema = {
|
|
|
5804
6369
|
title: "Text",
|
|
5805
6370
|
description: "The text with a mask token to fill"
|
|
5806
6371
|
},
|
|
5807
|
-
model:
|
|
6372
|
+
model: modelSchema26
|
|
5808
6373
|
},
|
|
5809
6374
|
required: ["text", "model"],
|
|
5810
6375
|
additionalProperties: false
|
|
@@ -5859,21 +6424,21 @@ class TextFillMaskTask extends AiTask {
|
|
|
5859
6424
|
var textFillMask = (input, config) => {
|
|
5860
6425
|
return new TextFillMaskTask(config).run(input);
|
|
5861
6426
|
};
|
|
5862
|
-
|
|
6427
|
+
Workflow36.prototype.textFillMask = CreateWorkflow36(TextFillMaskTask);
|
|
5863
6428
|
|
|
5864
6429
|
// src/task/TextGenerationTask.ts
|
|
5865
|
-
import { CreateWorkflow as
|
|
6430
|
+
import { CreateWorkflow as CreateWorkflow37, Workflow as Workflow37 } from "@workglow/task-graph";
|
|
5866
6431
|
var generatedTextSchema2 = {
|
|
5867
6432
|
type: "string",
|
|
5868
6433
|
title: "Text",
|
|
5869
6434
|
description: "The generated text",
|
|
5870
6435
|
"x-stream": "append"
|
|
5871
6436
|
};
|
|
5872
|
-
var
|
|
6437
|
+
var modelSchema27 = TypeModel("model:TextGenerationTask");
|
|
5873
6438
|
var TextGenerationInputSchema = {
|
|
5874
6439
|
type: "object",
|
|
5875
6440
|
properties: {
|
|
5876
|
-
model:
|
|
6441
|
+
model: modelSchema27,
|
|
5877
6442
|
prompt: {
|
|
5878
6443
|
type: "string",
|
|
5879
6444
|
title: "Prompt",
|
|
@@ -5948,11 +6513,11 @@ class TextGenerationTask extends StreamingAiTask {
|
|
|
5948
6513
|
var textGeneration = (input, config) => {
|
|
5949
6514
|
return new TextGenerationTask(config).run(input);
|
|
5950
6515
|
};
|
|
5951
|
-
|
|
6516
|
+
Workflow37.prototype.textGeneration = CreateWorkflow37(TextGenerationTask);
|
|
5952
6517
|
|
|
5953
6518
|
// src/task/TextLanguageDetectionTask.ts
|
|
5954
|
-
import { CreateWorkflow as
|
|
5955
|
-
var
|
|
6519
|
+
import { CreateWorkflow as CreateWorkflow38, Workflow as Workflow38 } from "@workglow/task-graph";
|
|
6520
|
+
var modelSchema28 = TypeModel("model:TextLanguageDetectionTask");
|
|
5956
6521
|
var TextLanguageDetectionInputSchema = {
|
|
5957
6522
|
type: "object",
|
|
5958
6523
|
properties: {
|
|
@@ -5969,7 +6534,7 @@ var TextLanguageDetectionInputSchema = {
|
|
|
5969
6534
|
title: "Max Languages",
|
|
5970
6535
|
description: "The maximum number of languages to return"
|
|
5971
6536
|
},
|
|
5972
|
-
model:
|
|
6537
|
+
model: modelSchema28
|
|
5973
6538
|
},
|
|
5974
6539
|
required: ["text", "model"],
|
|
5975
6540
|
additionalProperties: false
|
|
@@ -6019,10 +6584,10 @@ class TextLanguageDetectionTask extends AiTask {
|
|
|
6019
6584
|
var textLanguageDetection = (input, config) => {
|
|
6020
6585
|
return new TextLanguageDetectionTask(config).run(input);
|
|
6021
6586
|
};
|
|
6022
|
-
|
|
6587
|
+
Workflow38.prototype.textLanguageDetection = CreateWorkflow38(TextLanguageDetectionTask);
|
|
6023
6588
|
|
|
6024
6589
|
// src/task/TextQuestionAnswerTask.ts
|
|
6025
|
-
import { CreateWorkflow as
|
|
6590
|
+
import { CreateWorkflow as CreateWorkflow39, Workflow as Workflow39 } from "@workglow/task-graph";
|
|
6026
6591
|
var contextSchema = {
|
|
6027
6592
|
type: "string",
|
|
6028
6593
|
title: "Context",
|
|
@@ -6039,13 +6604,13 @@ var textSchema = {
|
|
|
6039
6604
|
description: "The generated text",
|
|
6040
6605
|
"x-stream": "append"
|
|
6041
6606
|
};
|
|
6042
|
-
var
|
|
6607
|
+
var modelSchema29 = TypeModel("model:TextQuestionAnswerTask");
|
|
6043
6608
|
var TextQuestionAnswerInputSchema = {
|
|
6044
6609
|
type: "object",
|
|
6045
6610
|
properties: {
|
|
6046
6611
|
context: contextSchema,
|
|
6047
6612
|
question: questionSchema,
|
|
6048
|
-
model:
|
|
6613
|
+
model: modelSchema29
|
|
6049
6614
|
},
|
|
6050
6615
|
required: ["context", "question", "model"],
|
|
6051
6616
|
additionalProperties: false
|
|
@@ -6075,11 +6640,11 @@ class TextQuestionAnswerTask extends StreamingAiTask {
|
|
|
6075
6640
|
var textQuestionAnswer = (input, config) => {
|
|
6076
6641
|
return new TextQuestionAnswerTask(config).run(input);
|
|
6077
6642
|
};
|
|
6078
|
-
|
|
6643
|
+
Workflow39.prototype.textQuestionAnswer = CreateWorkflow39(TextQuestionAnswerTask);
|
|
6079
6644
|
|
|
6080
6645
|
// src/task/TextRewriterTask.ts
|
|
6081
|
-
import { CreateWorkflow as
|
|
6082
|
-
var
|
|
6646
|
+
import { CreateWorkflow as CreateWorkflow40, Workflow as Workflow40 } from "@workglow/task-graph";
|
|
6647
|
+
var modelSchema30 = TypeModel("model:TextRewriterTask");
|
|
6083
6648
|
var TextRewriterInputSchema = {
|
|
6084
6649
|
type: "object",
|
|
6085
6650
|
properties: {
|
|
@@ -6093,7 +6658,7 @@ var TextRewriterInputSchema = {
|
|
|
6093
6658
|
title: "Prompt",
|
|
6094
6659
|
description: "The prompt to direct the rewriting"
|
|
6095
6660
|
},
|
|
6096
|
-
model:
|
|
6661
|
+
model: modelSchema30
|
|
6097
6662
|
},
|
|
6098
6663
|
required: ["text", "prompt", "model"],
|
|
6099
6664
|
additionalProperties: false
|
|
@@ -6128,11 +6693,11 @@ class TextRewriterTask extends StreamingAiTask {
|
|
|
6128
6693
|
var textRewriter = (input, config) => {
|
|
6129
6694
|
return new TextRewriterTask(config).run(input);
|
|
6130
6695
|
};
|
|
6131
|
-
|
|
6696
|
+
Workflow40.prototype.textRewriter = CreateWorkflow40(TextRewriterTask);
|
|
6132
6697
|
|
|
6133
6698
|
// src/task/TextTranslationTask.ts
|
|
6134
|
-
import { CreateWorkflow as
|
|
6135
|
-
var
|
|
6699
|
+
import { CreateWorkflow as CreateWorkflow41, Workflow as Workflow41 } from "@workglow/task-graph";
|
|
6700
|
+
var modelSchema31 = TypeModel("model:TextTranslationTask");
|
|
6136
6701
|
var translationTextSchema = {
|
|
6137
6702
|
type: "string",
|
|
6138
6703
|
title: "Text",
|
|
@@ -6159,7 +6724,7 @@ var TextTranslationInputSchema = {
|
|
|
6159
6724
|
minLength: 2,
|
|
6160
6725
|
maxLength: 2
|
|
6161
6726
|
}),
|
|
6162
|
-
model:
|
|
6727
|
+
model: modelSchema31
|
|
6163
6728
|
},
|
|
6164
6729
|
required: ["text", "source_lang", "target_lang", "model"],
|
|
6165
6730
|
additionalProperties: false
|
|
@@ -6195,10 +6760,10 @@ class TextTranslationTask extends StreamingAiTask {
|
|
|
6195
6760
|
var textTranslation = (input, config) => {
|
|
6196
6761
|
return new TextTranslationTask(config).run(input);
|
|
6197
6762
|
};
|
|
6198
|
-
|
|
6763
|
+
Workflow41.prototype.textTranslation = CreateWorkflow41(TextTranslationTask);
|
|
6199
6764
|
|
|
6200
6765
|
// src/task/ToolCallingTask.ts
|
|
6201
|
-
import { CreateWorkflow as
|
|
6766
|
+
import { CreateWorkflow as CreateWorkflow42, getTaskConstructors, Workflow as Workflow42 } from "@workglow/task-graph";
|
|
6202
6767
|
import { makeFingerprint } from "@workglow/util";
|
|
6203
6768
|
function taskTypesToTools(taskNames, registry) {
|
|
6204
6769
|
const constructors = getTaskConstructors(registry);
|
|
@@ -6282,11 +6847,11 @@ var ToolCallSchema = {
|
|
|
6282
6847
|
required: ["id", "name", "input"],
|
|
6283
6848
|
additionalProperties: false
|
|
6284
6849
|
};
|
|
6285
|
-
var
|
|
6850
|
+
var modelSchema32 = TypeModel("model:ToolCallingTask");
|
|
6286
6851
|
var ToolCallingInputSchema = {
|
|
6287
6852
|
type: "object",
|
|
6288
6853
|
properties: {
|
|
6289
|
-
model:
|
|
6854
|
+
model: modelSchema32,
|
|
6290
6855
|
prompt: {
|
|
6291
6856
|
oneOf: [
|
|
6292
6857
|
{ type: "string", title: "Prompt", description: "The prompt to send to the model" },
|
|
@@ -6431,16 +6996,16 @@ class ToolCallingTask extends StreamingAiTask {
|
|
|
6431
6996
|
var toolCalling = (input, config) => {
|
|
6432
6997
|
return new ToolCallingTask(config).run(input);
|
|
6433
6998
|
};
|
|
6434
|
-
|
|
6999
|
+
Workflow42.prototype.toolCalling = CreateWorkflow42(ToolCallingTask);
|
|
6435
7000
|
|
|
6436
7001
|
// src/task/TopicSegmenterTask.ts
|
|
6437
|
-
import { CreateWorkflow as
|
|
7002
|
+
import { CreateWorkflow as CreateWorkflow43, Task as Task16, Workflow as Workflow43 } from "@workglow/task-graph";
|
|
6438
7003
|
var SegmentationMethod = {
|
|
6439
7004
|
HEURISTIC: "heuristic",
|
|
6440
7005
|
EMBEDDING_SIMILARITY: "embedding-similarity",
|
|
6441
7006
|
HYBRID: "hybrid"
|
|
6442
7007
|
};
|
|
6443
|
-
var
|
|
7008
|
+
var inputSchema14 = {
|
|
6444
7009
|
type: "object",
|
|
6445
7010
|
properties: {
|
|
6446
7011
|
text: {
|
|
@@ -6481,7 +7046,7 @@ var inputSchema13 = {
|
|
|
6481
7046
|
required: ["text"],
|
|
6482
7047
|
additionalProperties: false
|
|
6483
7048
|
};
|
|
6484
|
-
var
|
|
7049
|
+
var outputSchema14 = {
|
|
6485
7050
|
type: "object",
|
|
6486
7051
|
properties: {
|
|
6487
7052
|
segments: {
|
|
@@ -6509,7 +7074,7 @@ var outputSchema13 = {
|
|
|
6509
7074
|
additionalProperties: false
|
|
6510
7075
|
};
|
|
6511
7076
|
|
|
6512
|
-
class TopicSegmenterTask extends
|
|
7077
|
+
class TopicSegmenterTask extends Task16 {
|
|
6513
7078
|
static type = "TopicSegmenterTask";
|
|
6514
7079
|
static category = "Document";
|
|
6515
7080
|
static title = "Topic Segmenter";
|
|
@@ -6517,10 +7082,10 @@ class TopicSegmenterTask extends Task15 {
|
|
|
6517
7082
|
static cacheable = true;
|
|
6518
7083
|
static EMBEDDING_DIMENSIONS = 256;
|
|
6519
7084
|
static inputSchema() {
|
|
6520
|
-
return
|
|
7085
|
+
return inputSchema14;
|
|
6521
7086
|
}
|
|
6522
7087
|
static outputSchema() {
|
|
6523
|
-
return
|
|
7088
|
+
return outputSchema14;
|
|
6524
7089
|
}
|
|
6525
7090
|
async execute(input, context) {
|
|
6526
7091
|
const {
|
|
@@ -6714,15 +7279,15 @@ class TopicSegmenterTask extends Task15 {
|
|
|
6714
7279
|
var topicSegmenter = (input, config) => {
|
|
6715
7280
|
return new TopicSegmenterTask(config).run(input);
|
|
6716
7281
|
};
|
|
6717
|
-
|
|
7282
|
+
Workflow43.prototype.topicSegmenter = CreateWorkflow43(TopicSegmenterTask);
|
|
6718
7283
|
|
|
6719
7284
|
// src/task/UnloadModelTask.ts
|
|
6720
|
-
import { CreateWorkflow as
|
|
6721
|
-
var
|
|
7285
|
+
import { CreateWorkflow as CreateWorkflow44, Workflow as Workflow44 } from "@workglow/task-graph";
|
|
7286
|
+
var modelSchema33 = TypeModel("model");
|
|
6722
7287
|
var UnloadModelInputSchema = {
|
|
6723
7288
|
type: "object",
|
|
6724
7289
|
properties: {
|
|
6725
|
-
model:
|
|
7290
|
+
model: modelSchema33
|
|
6726
7291
|
},
|
|
6727
7292
|
required: ["model"],
|
|
6728
7293
|
additionalProperties: false
|
|
@@ -6730,7 +7295,7 @@ var UnloadModelInputSchema = {
|
|
|
6730
7295
|
var UnloadModelOutputSchema = {
|
|
6731
7296
|
type: "object",
|
|
6732
7297
|
properties: {
|
|
6733
|
-
model:
|
|
7298
|
+
model: modelSchema33
|
|
6734
7299
|
},
|
|
6735
7300
|
required: ["model"],
|
|
6736
7301
|
additionalProperties: false
|
|
@@ -6752,16 +7317,16 @@ class UnloadModelTask extends AiTask {
|
|
|
6752
7317
|
var unloadModel = (input, config) => {
|
|
6753
7318
|
return new UnloadModelTask(config).run(input);
|
|
6754
7319
|
};
|
|
6755
|
-
|
|
7320
|
+
Workflow44.prototype.unloadModel = CreateWorkflow44(UnloadModelTask);
|
|
6756
7321
|
|
|
6757
7322
|
// src/task/VectorQuantizeTask.ts
|
|
6758
|
-
import { CreateWorkflow as
|
|
7323
|
+
import { CreateWorkflow as CreateWorkflow45, Task as Task17, Workflow as Workflow45 } from "@workglow/task-graph";
|
|
6759
7324
|
import {
|
|
6760
7325
|
normalizeNumberArray,
|
|
6761
7326
|
TensorType,
|
|
6762
7327
|
TypedArraySchema as TypedArraySchema5
|
|
6763
7328
|
} from "@workglow/util/schema";
|
|
6764
|
-
var
|
|
7329
|
+
var inputSchema15 = {
|
|
6765
7330
|
type: "object",
|
|
6766
7331
|
properties: {
|
|
6767
7332
|
vector: {
|
|
@@ -6798,7 +7363,7 @@ var inputSchema14 = {
|
|
|
6798
7363
|
required: ["vector", "targetType"],
|
|
6799
7364
|
additionalProperties: false
|
|
6800
7365
|
};
|
|
6801
|
-
var
|
|
7366
|
+
var outputSchema15 = {
|
|
6802
7367
|
type: "object",
|
|
6803
7368
|
properties: {
|
|
6804
7369
|
vector: {
|
|
@@ -6835,17 +7400,17 @@ var outputSchema14 = {
|
|
|
6835
7400
|
additionalProperties: false
|
|
6836
7401
|
};
|
|
6837
7402
|
|
|
6838
|
-
class VectorQuantizeTask extends
|
|
7403
|
+
class VectorQuantizeTask extends Task17 {
|
|
6839
7404
|
static type = "VectorQuantizeTask";
|
|
6840
7405
|
static category = "Vector";
|
|
6841
7406
|
static title = "Quantize";
|
|
6842
7407
|
static description = "Quantize vectors to reduce storage and improve performance";
|
|
6843
7408
|
static cacheable = true;
|
|
6844
7409
|
static inputSchema() {
|
|
6845
|
-
return
|
|
7410
|
+
return inputSchema15;
|
|
6846
7411
|
}
|
|
6847
7412
|
static outputSchema() {
|
|
6848
|
-
return
|
|
7413
|
+
return outputSchema15;
|
|
6849
7414
|
}
|
|
6850
7415
|
async execute(input) {
|
|
6851
7416
|
return this.executePreview(input);
|
|
@@ -6938,10 +7503,10 @@ class VectorQuantizeTask extends Task16 {
|
|
|
6938
7503
|
var vectorQuantize = (input, config) => {
|
|
6939
7504
|
return new VectorQuantizeTask(config).run(input);
|
|
6940
7505
|
};
|
|
6941
|
-
|
|
7506
|
+
Workflow45.prototype.vectorQuantize = CreateWorkflow45(VectorQuantizeTask);
|
|
6942
7507
|
|
|
6943
7508
|
// src/task/VectorSimilarityTask.ts
|
|
6944
|
-
import { CreateWorkflow as
|
|
7509
|
+
import { CreateWorkflow as CreateWorkflow46, GraphAsTask, Workflow as Workflow46 } from "@workglow/task-graph";
|
|
6945
7510
|
import {
|
|
6946
7511
|
cosineSimilarity,
|
|
6947
7512
|
hammingSimilarity,
|
|
@@ -7055,7 +7620,7 @@ class VectorSimilarityTask extends GraphAsTask {
|
|
|
7055
7620
|
var similarity = (input, config) => {
|
|
7056
7621
|
return new VectorSimilarityTask(config).run(input);
|
|
7057
7622
|
};
|
|
7058
|
-
|
|
7623
|
+
Workflow46.prototype.similarity = CreateWorkflow46(VectorSimilarityTask);
|
|
7059
7624
|
// src/task/MessageConversion.ts
|
|
7060
7625
|
function getInputMessages(input) {
|
|
7061
7626
|
const messages = input.messages;
|
|
@@ -7208,6 +7773,7 @@ function toTextFlatMessages(input) {
|
|
|
7208
7773
|
var registerAiTasks = () => {
|
|
7209
7774
|
const tasks = [
|
|
7210
7775
|
AiChatTask,
|
|
7776
|
+
AiChatWithKbTask,
|
|
7211
7777
|
BackgroundRemovalTask,
|
|
7212
7778
|
CountTokensTask,
|
|
7213
7779
|
ContextBuilderTask,
|
|
@@ -7224,6 +7790,7 @@ var registerAiTasks = () => {
|
|
|
7224
7790
|
HandLandmarkerTask,
|
|
7225
7791
|
HierarchicalChunkerTask,
|
|
7226
7792
|
HierarchyJoinTask,
|
|
7793
|
+
KbSearchTask,
|
|
7227
7794
|
KbToDocumentsTask,
|
|
7228
7795
|
ImageClassificationTask,
|
|
7229
7796
|
ImageEmbeddingTask,
|
|
@@ -7293,6 +7860,7 @@ export {
|
|
|
7293
7860
|
modelSearch,
|
|
7294
7861
|
modelInfo,
|
|
7295
7862
|
kbToDocuments,
|
|
7863
|
+
kbSearch,
|
|
7296
7864
|
isContentBlockInToolResultBody,
|
|
7297
7865
|
isContentBlock,
|
|
7298
7866
|
isChatMessage,
|
|
@@ -7321,6 +7889,7 @@ export {
|
|
|
7321
7889
|
chunkVectorUpsert,
|
|
7322
7890
|
chunkRetrieval,
|
|
7323
7891
|
buildToolDescription,
|
|
7892
|
+
buildResponseFormatAddendum,
|
|
7324
7893
|
backgroundRemoval,
|
|
7325
7894
|
VectorSimilarityTask,
|
|
7326
7895
|
VectorQuantizeTask,
|
|
@@ -7400,6 +7969,8 @@ export {
|
|
|
7400
7969
|
ModelConfigSchema,
|
|
7401
7970
|
MODEL_REPOSITORY,
|
|
7402
7971
|
KbToDocumentsTask,
|
|
7972
|
+
KbSearchTask,
|
|
7973
|
+
KB_INLINE_CITATION_DIRECTIVE,
|
|
7403
7974
|
InMemoryModelRepository,
|
|
7404
7975
|
ImageToTextTask,
|
|
7405
7976
|
ImageToTextOutputSchema,
|
|
@@ -7458,10 +8029,13 @@ export {
|
|
|
7458
8029
|
AiProvider,
|
|
7459
8030
|
AiJob,
|
|
7460
8031
|
AiImageOutputTask,
|
|
8032
|
+
AiChatWithKbTask,
|
|
8033
|
+
AiChatWithKbOutputSchema,
|
|
8034
|
+
AiChatWithKbInputSchema,
|
|
7461
8035
|
AiChatTask,
|
|
7462
8036
|
AiChatOutputSchema,
|
|
7463
8037
|
AiChatInputSchema,
|
|
7464
8038
|
AI_PROVIDER_REGISTRY
|
|
7465
8039
|
};
|
|
7466
8040
|
|
|
7467
|
-
//# debugId=
|
|
8041
|
+
//# debugId=AE848783BD0282C164756E2164756E21
|