@workglow/ai 0.2.32 → 0.2.33
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 +840 -277
- package/dist/browser.js.map +9 -6
- package/dist/bun.js +840 -277
- package/dist/bun.js.map +9 -6
- package/dist/node.js +840 -277
- 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 +8 -1
- 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/node.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"],
|
|
@@ -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 });
|
|
@@ -1523,8 +1560,6 @@ class AiChatTask extends StreamingAiTask {
|
|
|
1523
1560
|
port: "messages",
|
|
1524
1561
|
objectDelta: [...history]
|
|
1525
1562
|
};
|
|
1526
|
-
let iterations = 0;
|
|
1527
|
-
let lastAssistantText = "";
|
|
1528
1563
|
for (let turn = 0;turn < maxIterations; turn++) {
|
|
1529
1564
|
const perTurnInput = { ...input, messages: [...history] };
|
|
1530
1565
|
const turnJobInput = await this.getJobInput(perTurnInput);
|
|
@@ -1536,12 +1571,475 @@ class AiChatTask extends StreamingAiTask {
|
|
|
1536
1571
|
...event,
|
|
1537
1572
|
port: event.port ?? "text"
|
|
1538
1573
|
};
|
|
1539
|
-
} else if (event.type === "finish") {} else {
|
|
1540
|
-
yield event;
|
|
1574
|
+
} else if (event.type === "finish") {} else {
|
|
1575
|
+
yield event;
|
|
1576
|
+
}
|
|
1577
|
+
}
|
|
1578
|
+
const assistantMsg = {
|
|
1579
|
+
role: "assistant",
|
|
1580
|
+
content: [{ type: "text", text: assistantText }]
|
|
1581
|
+
};
|
|
1582
|
+
history.push(assistantMsg);
|
|
1583
|
+
yield {
|
|
1584
|
+
type: "object-delta",
|
|
1585
|
+
port: "messages",
|
|
1586
|
+
objectDelta: [assistantMsg]
|
|
1587
|
+
};
|
|
1588
|
+
const request = {
|
|
1589
|
+
requestId: crypto.randomUUID(),
|
|
1590
|
+
targetHumanId: "default",
|
|
1591
|
+
kind: "elicit",
|
|
1592
|
+
message: "",
|
|
1593
|
+
contentSchema: chatConnectorContentSchema,
|
|
1594
|
+
contentData: undefined,
|
|
1595
|
+
expectsResponse: true,
|
|
1596
|
+
mode: "multi-turn",
|
|
1597
|
+
metadata: { iteration: turn, taskId: this.id }
|
|
1598
|
+
};
|
|
1599
|
+
const response = await connector.send(request, context.signal);
|
|
1600
|
+
if (response.action === "cancel" || response.action === "decline")
|
|
1601
|
+
break;
|
|
1602
|
+
const raw = response.content?.content;
|
|
1603
|
+
let userContent;
|
|
1604
|
+
if (typeof raw === "string") {
|
|
1605
|
+
const text = raw.trim();
|
|
1606
|
+
userContent = text.length > 0 ? [{ type: "text", text: raw }] : [];
|
|
1607
|
+
} else if (Array.isArray(raw)) {
|
|
1608
|
+
userContent = raw;
|
|
1609
|
+
} else {
|
|
1610
|
+
userContent = [];
|
|
1611
|
+
}
|
|
1612
|
+
if (userContent.length === 0)
|
|
1613
|
+
break;
|
|
1614
|
+
const userMsg = { role: "user", content: userContent };
|
|
1615
|
+
history.push(userMsg);
|
|
1616
|
+
yield {
|
|
1617
|
+
type: "object-delta",
|
|
1618
|
+
port: "messages",
|
|
1619
|
+
objectDelta: [userMsg]
|
|
1620
|
+
};
|
|
1621
|
+
}
|
|
1622
|
+
yield { type: "finish" };
|
|
1623
|
+
}
|
|
1624
|
+
}
|
|
1625
|
+
|
|
1626
|
+
// src/task/AiChatWithKbTask.ts
|
|
1627
|
+
import { getKnowledgeBase, slugifyHeading } from "@workglow/knowledge-base";
|
|
1628
|
+
import { TaskConfigSchema as TaskConfigSchema3 } from "@workglow/task-graph";
|
|
1629
|
+
import { resolveHumanConnector as resolveHumanConnector2 } from "@workglow/util";
|
|
1630
|
+
|
|
1631
|
+
// src/task/KbSearchTask.ts
|
|
1632
|
+
import { TypeKnowledgeBase } from "@workglow/knowledge-base";
|
|
1633
|
+
import { CreateWorkflow, Task as Task2, Workflow } from "@workglow/task-graph";
|
|
1634
|
+
var inputSchema = {
|
|
1635
|
+
type: "object",
|
|
1636
|
+
properties: {
|
|
1637
|
+
knowledgeBase: TypeKnowledgeBase({
|
|
1638
|
+
title: "Knowledge Base",
|
|
1639
|
+
description: "The knowledge base instance to search in"
|
|
1640
|
+
}),
|
|
1641
|
+
query: {
|
|
1642
|
+
type: "string",
|
|
1643
|
+
title: "Query",
|
|
1644
|
+
description: "Search query (the KB's onSearch handles embedding internally)"
|
|
1645
|
+
},
|
|
1646
|
+
topK: {
|
|
1647
|
+
type: "number",
|
|
1648
|
+
title: "Top K",
|
|
1649
|
+
description: "Number of top results to return",
|
|
1650
|
+
minimum: 1,
|
|
1651
|
+
default: 5
|
|
1652
|
+
},
|
|
1653
|
+
filter: {
|
|
1654
|
+
type: "object",
|
|
1655
|
+
title: "Metadata Filter",
|
|
1656
|
+
description: "Filter results by metadata fields"
|
|
1657
|
+
}
|
|
1658
|
+
},
|
|
1659
|
+
required: ["knowledgeBase", "query"],
|
|
1660
|
+
additionalProperties: false
|
|
1661
|
+
};
|
|
1662
|
+
var outputSchema = {
|
|
1663
|
+
type: "object",
|
|
1664
|
+
properties: {
|
|
1665
|
+
results: {
|
|
1666
|
+
type: "array",
|
|
1667
|
+
items: {
|
|
1668
|
+
type: "object",
|
|
1669
|
+
title: "Chunk Search Result",
|
|
1670
|
+
description: "A single chunk match with score and metadata"
|
|
1671
|
+
},
|
|
1672
|
+
title: "Results",
|
|
1673
|
+
description: "Matching chunks in score-desc order"
|
|
1674
|
+
},
|
|
1675
|
+
count: {
|
|
1676
|
+
type: "number",
|
|
1677
|
+
title: "Count",
|
|
1678
|
+
description: "Number of results returned"
|
|
1679
|
+
}
|
|
1680
|
+
},
|
|
1681
|
+
required: ["results", "count"],
|
|
1682
|
+
additionalProperties: false
|
|
1683
|
+
};
|
|
1684
|
+
|
|
1685
|
+
class KbSearchTask extends Task2 {
|
|
1686
|
+
static type = "KbSearchTask";
|
|
1687
|
+
static category = "RAG";
|
|
1688
|
+
static title = "KB Search";
|
|
1689
|
+
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).";
|
|
1690
|
+
static cacheable = true;
|
|
1691
|
+
static inputSchema() {
|
|
1692
|
+
return inputSchema;
|
|
1693
|
+
}
|
|
1694
|
+
static outputSchema() {
|
|
1695
|
+
return outputSchema;
|
|
1696
|
+
}
|
|
1697
|
+
async execute(input, _context) {
|
|
1698
|
+
const { knowledgeBase, query, topK = 5, filter } = input;
|
|
1699
|
+
const kb = knowledgeBase;
|
|
1700
|
+
const results = await kb.search(query, { topK, filter });
|
|
1701
|
+
return { results, count: results.length };
|
|
1702
|
+
}
|
|
1703
|
+
}
|
|
1704
|
+
var kbSearch = (input, config) => {
|
|
1705
|
+
return new KbSearchTask(config).run(input);
|
|
1706
|
+
};
|
|
1707
|
+
Workflow.prototype.kbSearch = CreateWorkflow(KbSearchTask);
|
|
1708
|
+
|
|
1709
|
+
// src/task/AiChatWithKbTask.ts
|
|
1710
|
+
var modelSchema2 = TypeModel("model:AiChatWithKbTask");
|
|
1711
|
+
var chatChunkReferenceSchema = {
|
|
1712
|
+
type: "object",
|
|
1713
|
+
properties: {
|
|
1714
|
+
kbId: { type: "string" },
|
|
1715
|
+
kbLabel: { type: "string" },
|
|
1716
|
+
title: { type: "string" },
|
|
1717
|
+
url: { type: "string" },
|
|
1718
|
+
snippet: { type: "string" },
|
|
1719
|
+
score: { type: "number" },
|
|
1720
|
+
index: { type: "number" }
|
|
1721
|
+
},
|
|
1722
|
+
required: ["kbId", "kbLabel", "title", "snippet", "score", "index"]
|
|
1723
|
+
};
|
|
1724
|
+
var chatConnectorContentSchema2 = {
|
|
1725
|
+
type: "object",
|
|
1726
|
+
properties: {
|
|
1727
|
+
content: {
|
|
1728
|
+
type: "string",
|
|
1729
|
+
title: "Message",
|
|
1730
|
+
description: "Your reply (leave blank to end the conversation)"
|
|
1731
|
+
}
|
|
1732
|
+
},
|
|
1733
|
+
additionalProperties: false
|
|
1734
|
+
};
|
|
1735
|
+
var AiChatWithKbInputSchema = {
|
|
1736
|
+
type: "object",
|
|
1737
|
+
properties: {
|
|
1738
|
+
model: modelSchema2,
|
|
1739
|
+
prompt: {
|
|
1740
|
+
oneOf: [
|
|
1741
|
+
{ type: "string", title: "Prompt", description: "The initial user message" },
|
|
1742
|
+
{
|
|
1743
|
+
type: "array",
|
|
1744
|
+
title: "Prompt",
|
|
1745
|
+
description: "The initial user message as structured content blocks",
|
|
1746
|
+
items: ContentBlockSchema
|
|
1747
|
+
}
|
|
1748
|
+
],
|
|
1749
|
+
title: "Prompt",
|
|
1750
|
+
description: "The first user message to start the conversation"
|
|
1751
|
+
},
|
|
1752
|
+
messages: {
|
|
1753
|
+
type: "array",
|
|
1754
|
+
title: "Messages",
|
|
1755
|
+
description: "Conversation history (managed internally by the chat loop; not a user-facing input)",
|
|
1756
|
+
items: ChatMessageSchema,
|
|
1757
|
+
"x-ui-hidden": true
|
|
1758
|
+
},
|
|
1759
|
+
systemPrompt: {
|
|
1760
|
+
type: "string",
|
|
1761
|
+
title: "System Prompt",
|
|
1762
|
+
description: "Optional system instructions for the model"
|
|
1763
|
+
},
|
|
1764
|
+
maxTokens: {
|
|
1765
|
+
type: "number",
|
|
1766
|
+
title: "Max Tokens",
|
|
1767
|
+
description: "Per-turn token limit",
|
|
1768
|
+
minimum: 1,
|
|
1769
|
+
"x-ui-group": "Configuration"
|
|
1770
|
+
},
|
|
1771
|
+
temperature: {
|
|
1772
|
+
type: "number",
|
|
1773
|
+
title: "Temperature",
|
|
1774
|
+
description: "Sampling temperature",
|
|
1775
|
+
minimum: 0,
|
|
1776
|
+
maximum: 2,
|
|
1777
|
+
"x-ui-group": "Configuration"
|
|
1778
|
+
},
|
|
1779
|
+
maxIterations: {
|
|
1780
|
+
type: "number",
|
|
1781
|
+
title: "Max Iterations",
|
|
1782
|
+
description: "Safety cap on conversation turns",
|
|
1783
|
+
minimum: 1,
|
|
1784
|
+
default: 100,
|
|
1785
|
+
"x-ui-group": "Configuration"
|
|
1786
|
+
},
|
|
1787
|
+
knowledgeBaseIds: {
|
|
1788
|
+
type: "array",
|
|
1789
|
+
title: "Knowledge Base IDs",
|
|
1790
|
+
description: "Knowledge bases to retrieve from on each turn",
|
|
1791
|
+
items: { type: "string" }
|
|
1792
|
+
},
|
|
1793
|
+
topKPerKb: {
|
|
1794
|
+
type: "number",
|
|
1795
|
+
title: "Top K per KB",
|
|
1796
|
+
description: "Top results per KB before threshold filtering",
|
|
1797
|
+
minimum: 1,
|
|
1798
|
+
default: 4,
|
|
1799
|
+
"x-ui-group": "Configuration"
|
|
1800
|
+
},
|
|
1801
|
+
minScore: {
|
|
1802
|
+
type: "number",
|
|
1803
|
+
title: "Min score",
|
|
1804
|
+
description: "Score floor for a chunk to count as a useful match",
|
|
1805
|
+
minimum: 0,
|
|
1806
|
+
maximum: 1,
|
|
1807
|
+
default: 0.3,
|
|
1808
|
+
"x-ui-group": "Configuration"
|
|
1809
|
+
},
|
|
1810
|
+
maxReferences: {
|
|
1811
|
+
type: "number",
|
|
1812
|
+
title: "Max references",
|
|
1813
|
+
description: "Cap on the chunk references emitted per turn",
|
|
1814
|
+
minimum: 1,
|
|
1815
|
+
default: 6,
|
|
1816
|
+
"x-ui-group": "Configuration"
|
|
1817
|
+
},
|
|
1818
|
+
noMatchReply: {
|
|
1819
|
+
type: "string",
|
|
1820
|
+
title: "No-match reply",
|
|
1821
|
+
description: "When set and zero chunks match: emit this verbatim and skip the provider",
|
|
1822
|
+
"x-ui-group": "Configuration"
|
|
1823
|
+
},
|
|
1824
|
+
noMatchReferences: {
|
|
1825
|
+
type: "array",
|
|
1826
|
+
title: "No-match references",
|
|
1827
|
+
description: "When set and zero chunks match: emit these verbatim on the references port",
|
|
1828
|
+
items: chatChunkReferenceSchema,
|
|
1829
|
+
"x-ui-group": "Configuration"
|
|
1830
|
+
},
|
|
1831
|
+
responseFormat: {
|
|
1832
|
+
type: "string",
|
|
1833
|
+
enum: ["text", "markdown"],
|
|
1834
|
+
default: "text",
|
|
1835
|
+
title: "Response format",
|
|
1836
|
+
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.",
|
|
1837
|
+
"x-ui-group": "Configuration"
|
|
1838
|
+
}
|
|
1839
|
+
},
|
|
1840
|
+
required: ["model", "prompt", "knowledgeBaseIds"],
|
|
1841
|
+
additionalProperties: false
|
|
1842
|
+
};
|
|
1843
|
+
var AiChatWithKbOutputSchema = {
|
|
1844
|
+
type: "object",
|
|
1845
|
+
properties: {
|
|
1846
|
+
text: {
|
|
1847
|
+
type: "string",
|
|
1848
|
+
title: "Text",
|
|
1849
|
+
description: "Last assistant response",
|
|
1850
|
+
"x-stream": "append"
|
|
1851
|
+
},
|
|
1852
|
+
messages: {
|
|
1853
|
+
type: "array",
|
|
1854
|
+
title: "Messages",
|
|
1855
|
+
description: "Full conversation history",
|
|
1856
|
+
items: ChatMessageSchema,
|
|
1857
|
+
"x-stream": "object"
|
|
1858
|
+
},
|
|
1859
|
+
iterations: {
|
|
1860
|
+
type: "number",
|
|
1861
|
+
title: "Iterations",
|
|
1862
|
+
description: "Number of completed turns"
|
|
1863
|
+
},
|
|
1864
|
+
references: {
|
|
1865
|
+
type: "array",
|
|
1866
|
+
title: "References",
|
|
1867
|
+
description: "Per-chunk citation references emitted each turn (one entry per surviving chunk; not deduped)",
|
|
1868
|
+
items: chatChunkReferenceSchema,
|
|
1869
|
+
"x-stream": "object"
|
|
1870
|
+
}
|
|
1871
|
+
},
|
|
1872
|
+
required: ["text", "messages", "iterations", "references"],
|
|
1873
|
+
additionalProperties: false
|
|
1874
|
+
};
|
|
1875
|
+
|
|
1876
|
+
class AiChatWithKbTask extends StreamingAiTask {
|
|
1877
|
+
static type = "AiChatWithKbTask";
|
|
1878
|
+
static streamingPhaseLabel = "Replying";
|
|
1879
|
+
static category = "AI Chat";
|
|
1880
|
+
static title = "AI Chat (Knowledge Base)";
|
|
1881
|
+
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.";
|
|
1882
|
+
static cacheable = false;
|
|
1883
|
+
static configSchema() {
|
|
1884
|
+
return {
|
|
1885
|
+
type: "object",
|
|
1886
|
+
properties: {
|
|
1887
|
+
...TaskConfigSchema3["properties"]
|
|
1888
|
+
},
|
|
1889
|
+
additionalProperties: false
|
|
1890
|
+
};
|
|
1891
|
+
}
|
|
1892
|
+
static inputSchema() {
|
|
1893
|
+
return AiChatWithKbInputSchema;
|
|
1894
|
+
}
|
|
1895
|
+
static outputSchema() {
|
|
1896
|
+
return AiChatWithKbOutputSchema;
|
|
1897
|
+
}
|
|
1898
|
+
_sessionId;
|
|
1899
|
+
async getJobInput(input) {
|
|
1900
|
+
const model = input.model;
|
|
1901
|
+
if (!this._sessionId) {
|
|
1902
|
+
this._sessionId = getAiProviderRegistry().createSession(model.provider, model);
|
|
1903
|
+
}
|
|
1904
|
+
return {
|
|
1905
|
+
taskType: "AiChatWithKbTask",
|
|
1906
|
+
aiProvider: model.provider,
|
|
1907
|
+
taskInput: input,
|
|
1908
|
+
sessionId: this._sessionId
|
|
1909
|
+
};
|
|
1910
|
+
}
|
|
1911
|
+
async* executeStream(input, context) {
|
|
1912
|
+
this._sessionId = undefined;
|
|
1913
|
+
const model = input.model;
|
|
1914
|
+
if (!model || typeof model !== "object") {
|
|
1915
|
+
throw new Error("AiChatWithKbTask: model was not resolved to ModelConfig");
|
|
1916
|
+
}
|
|
1917
|
+
const connector = resolveHumanConnector2(context);
|
|
1918
|
+
const history = [];
|
|
1919
|
+
if (input.systemPrompt) {
|
|
1920
|
+
history.push({ role: "system", content: [{ type: "text", text: input.systemPrompt }] });
|
|
1921
|
+
}
|
|
1922
|
+
const firstUserBlocks = typeof input.prompt === "string" ? [{ type: "text", text: input.prompt }] : input.prompt;
|
|
1923
|
+
history.push({ role: "user", content: firstUserBlocks });
|
|
1924
|
+
const workingInput = { ...input, messages: history };
|
|
1925
|
+
await this.getJobInput(workingInput);
|
|
1926
|
+
const maxIterations = input.maxIterations ?? 100;
|
|
1927
|
+
if (context.resourceScope && this._sessionId) {
|
|
1928
|
+
const sessionId = this._sessionId;
|
|
1929
|
+
context.resourceScope.register(`ai:session:${sessionId}`, async () => {
|
|
1930
|
+
await getAiProviderRegistry().disposeSession(model.provider, sessionId);
|
|
1931
|
+
});
|
|
1932
|
+
}
|
|
1933
|
+
yield {
|
|
1934
|
+
type: "object-delta",
|
|
1935
|
+
port: "messages",
|
|
1936
|
+
objectDelta: [...history]
|
|
1937
|
+
};
|
|
1938
|
+
const topK = input.topKPerKb ?? 4;
|
|
1939
|
+
const minScore = input.minScore ?? 0.3;
|
|
1940
|
+
const maxRefs = input.maxReferences ?? 6;
|
|
1941
|
+
let lastNonEmptyRefs = [];
|
|
1942
|
+
for (let turn = 0;turn < maxIterations; turn++) {
|
|
1943
|
+
const lastUserText = extractLastUserText(history);
|
|
1944
|
+
let perKbResults = [];
|
|
1945
|
+
if (lastUserText.length > 0) {
|
|
1946
|
+
perKbResults = await Promise.all((input.knowledgeBaseIds ?? []).map(async (kbId) => {
|
|
1947
|
+
const kb = getKnowledgeBase(kbId);
|
|
1948
|
+
if (!kb) {
|
|
1949
|
+
console.warn(`[AiChatWithKbTask] knowledge base "${kbId}" not registered`);
|
|
1950
|
+
return { kbId, kbLabel: kbId, kb: undefined, results: [] };
|
|
1951
|
+
}
|
|
1952
|
+
const search = context.own(new KbSearchTask);
|
|
1953
|
+
const out = await search.run({
|
|
1954
|
+
knowledgeBase: kb,
|
|
1955
|
+
query: lastUserText,
|
|
1956
|
+
topK
|
|
1957
|
+
});
|
|
1958
|
+
return {
|
|
1959
|
+
kbId,
|
|
1960
|
+
kbLabel: kb.title || kbId,
|
|
1961
|
+
kb,
|
|
1962
|
+
results: out.results
|
|
1963
|
+
};
|
|
1964
|
+
}));
|
|
1965
|
+
}
|
|
1966
|
+
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);
|
|
1967
|
+
const docUrls = new Map;
|
|
1968
|
+
const docFetches = [];
|
|
1969
|
+
for (const { kb, r } of allChunks) {
|
|
1970
|
+
if (!kb)
|
|
1971
|
+
continue;
|
|
1972
|
+
const key = `${r.doc_id}`;
|
|
1973
|
+
if (docUrls.has(key))
|
|
1974
|
+
continue;
|
|
1975
|
+
docUrls.set(key, undefined);
|
|
1976
|
+
docFetches.push(kb.getDocument(r.doc_id).then((doc) => {
|
|
1977
|
+
const md = doc?.metadata ?? {};
|
|
1978
|
+
const url = typeof md.url === "string" ? md.url : undefined;
|
|
1979
|
+
docUrls.set(key, url);
|
|
1980
|
+
}).catch(() => {}));
|
|
1981
|
+
}
|
|
1982
|
+
await Promise.all(docFetches);
|
|
1983
|
+
const refs = allChunks.map((entry, i) => buildChunkReference({
|
|
1984
|
+
index: i + 1,
|
|
1985
|
+
kbId: entry.kbId,
|
|
1986
|
+
kbLabel: entry.kbLabel,
|
|
1987
|
+
result: entry.r,
|
|
1988
|
+
url: docUrls.get(entry.r.doc_id)
|
|
1989
|
+
}));
|
|
1990
|
+
const effectiveRefs = refs.length > 0 ? refs : lastNonEmptyRefs;
|
|
1991
|
+
if (refs.length > 0) {
|
|
1992
|
+
lastNonEmptyRefs = refs;
|
|
1993
|
+
}
|
|
1994
|
+
const emitted = effectiveRefs.length > 0 ? [...effectiveRefs] : input.noMatchReferences ?? [];
|
|
1995
|
+
yield {
|
|
1996
|
+
type: "object-delta",
|
|
1997
|
+
port: "references",
|
|
1998
|
+
objectDelta: emitted
|
|
1999
|
+
};
|
|
2000
|
+
let assistantText = "";
|
|
2001
|
+
if (effectiveRefs.length === 0 && input.noMatchReply) {
|
|
2002
|
+
yield {
|
|
2003
|
+
type: "text-delta",
|
|
2004
|
+
port: "text",
|
|
2005
|
+
textDelta: input.noMatchReply
|
|
2006
|
+
};
|
|
2007
|
+
assistantText = input.noMatchReply;
|
|
2008
|
+
} else {
|
|
2009
|
+
const addendum = buildResponseFormatAddendum(input.responseFormat);
|
|
2010
|
+
const directive = input.responseFormat === "markdown" ? KB_INLINE_CITATION_DIRECTIVE : "";
|
|
2011
|
+
const userSystemPrompt = input.systemPrompt ?? "";
|
|
2012
|
+
const turnSystemPrompt = [
|
|
2013
|
+
userSystemPrompt,
|
|
2014
|
+
addendum,
|
|
2015
|
+
directive,
|
|
2016
|
+
"--- Context ---",
|
|
2017
|
+
formatChunksForPrompt(effectiveRefs, input.responseFormat)
|
|
2018
|
+
].filter((s) => s.length > 0).join(`
|
|
2019
|
+
|
|
2020
|
+
`);
|
|
2021
|
+
const perTurnInput = {
|
|
2022
|
+
...input,
|
|
2023
|
+
messages: [
|
|
2024
|
+
{ role: "system", content: [{ type: "text", text: turnSystemPrompt }] },
|
|
2025
|
+
...history.filter((m) => m.role !== "system")
|
|
2026
|
+
],
|
|
2027
|
+
systemPrompt: turnSystemPrompt
|
|
2028
|
+
};
|
|
2029
|
+
const turnJobInput = await this.getJobInput(perTurnInput);
|
|
2030
|
+
const strategy = getAiProviderRegistry().getStrategy(model);
|
|
2031
|
+
for await (const event of strategy.executeStream(turnJobInput, context, this.runConfig.runnerId)) {
|
|
2032
|
+
if (event.type === "text-delta") {
|
|
2033
|
+
assistantText += event.textDelta;
|
|
2034
|
+
yield {
|
|
2035
|
+
...event,
|
|
2036
|
+
port: event.port ?? "text"
|
|
2037
|
+
};
|
|
2038
|
+
} else if (event.type === "finish") {} else {
|
|
2039
|
+
yield event;
|
|
2040
|
+
}
|
|
1541
2041
|
}
|
|
1542
2042
|
}
|
|
1543
|
-
iterations++;
|
|
1544
|
-
lastAssistantText = assistantText;
|
|
1545
2043
|
const assistantMsg = {
|
|
1546
2044
|
role: "assistant",
|
|
1547
2045
|
content: [{ type: "text", text: assistantText }]
|
|
@@ -1557,7 +2055,7 @@ class AiChatTask extends StreamingAiTask {
|
|
|
1557
2055
|
targetHumanId: "default",
|
|
1558
2056
|
kind: "elicit",
|
|
1559
2057
|
message: "",
|
|
1560
|
-
contentSchema:
|
|
2058
|
+
contentSchema: chatConnectorContentSchema2,
|
|
1561
2059
|
contentData: undefined,
|
|
1562
2060
|
expectsResponse: true,
|
|
1563
2061
|
mode: "multi-turn",
|
|
@@ -1586,28 +2084,67 @@ class AiChatTask extends StreamingAiTask {
|
|
|
1586
2084
|
objectDelta: [userMsg]
|
|
1587
2085
|
};
|
|
1588
2086
|
}
|
|
1589
|
-
yield {
|
|
1590
|
-
type: "finish",
|
|
1591
|
-
data: {
|
|
1592
|
-
text: lastAssistantText,
|
|
1593
|
-
messages: [...history],
|
|
1594
|
-
iterations
|
|
1595
|
-
}
|
|
1596
|
-
};
|
|
2087
|
+
yield { type: "finish" };
|
|
1597
2088
|
}
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
2089
|
+
}
|
|
2090
|
+
function extractLastUserText(messages) {
|
|
2091
|
+
for (let i = messages.length - 1;i >= 0; i--) {
|
|
2092
|
+
const m = messages[i];
|
|
2093
|
+
if (!m || m.role !== "user")
|
|
2094
|
+
continue;
|
|
2095
|
+
const text = m.content.map((b) => b.type === "text" ? b.text : "").join(" ").trim();
|
|
2096
|
+
if (text.length > 0)
|
|
2097
|
+
return text;
|
|
2098
|
+
}
|
|
2099
|
+
return "";
|
|
2100
|
+
}
|
|
2101
|
+
function buildChunkReference(args) {
|
|
2102
|
+
const md = args.result.metadata ?? {};
|
|
2103
|
+
const title = md.doc_title ?? md.title ?? args.result.doc_id ?? "Untitled";
|
|
2104
|
+
const baseUrl = args.url ?? md.url ?? undefined;
|
|
2105
|
+
const url = withSectionAnchor(baseUrl, md.sectionTitles);
|
|
2106
|
+
const text = md.text ?? "";
|
|
2107
|
+
const snippet = text.length > 150 ? text.slice(0, 150).trim() + "…" : text;
|
|
2108
|
+
return {
|
|
2109
|
+
index: args.index,
|
|
2110
|
+
kbId: args.kbId,
|
|
2111
|
+
kbLabel: args.kbLabel,
|
|
2112
|
+
title,
|
|
2113
|
+
url,
|
|
2114
|
+
snippet,
|
|
2115
|
+
score: args.result.score
|
|
2116
|
+
};
|
|
2117
|
+
}
|
|
2118
|
+
function withSectionAnchor(url, sectionTitles) {
|
|
2119
|
+
if (!url)
|
|
2120
|
+
return url;
|
|
2121
|
+
if (url.includes("#"))
|
|
2122
|
+
return url;
|
|
2123
|
+
if (!sectionTitles || sectionTitles.length === 0)
|
|
2124
|
+
return url;
|
|
2125
|
+
const deepest = sectionTitles[sectionTitles.length - 1];
|
|
2126
|
+
if (typeof deepest !== "string")
|
|
2127
|
+
return url;
|
|
2128
|
+
const slug = slugifyHeading(deepest);
|
|
2129
|
+
if (slug.length === 0)
|
|
2130
|
+
return url;
|
|
2131
|
+
return `${url}#${slug}`;
|
|
2132
|
+
}
|
|
2133
|
+
function formatChunksForPrompt(refs, responseFormat) {
|
|
2134
|
+
return refs.map((r) => {
|
|
2135
|
+
const head = `[${r.index}] [${r.kbLabel}] (${r.title})`;
|
|
2136
|
+
if (responseFormat === "markdown" && r.url) {
|
|
2137
|
+
return `${head} <${r.url}>
|
|
2138
|
+
${r.snippet}`;
|
|
1604
2139
|
}
|
|
1605
|
-
return
|
|
1606
|
-
}
|
|
2140
|
+
return `${head} ${r.snippet}`;
|
|
2141
|
+
}).join(`
|
|
2142
|
+
|
|
2143
|
+
`);
|
|
1607
2144
|
}
|
|
1608
2145
|
|
|
1609
2146
|
// src/task/BackgroundRemovalTask.ts
|
|
1610
|
-
import { CreateWorkflow, Workflow } from "@workglow/task-graph";
|
|
2147
|
+
import { CreateWorkflow as CreateWorkflow2, Workflow as Workflow2 } from "@workglow/task-graph";
|
|
1611
2148
|
import { ImageValueSchema } from "@workglow/util/media";
|
|
1612
2149
|
|
|
1613
2150
|
// src/task/base/AiVisionTask.ts
|
|
@@ -1616,12 +2153,12 @@ class AiVisionTask extends AiTask {
|
|
|
1616
2153
|
}
|
|
1617
2154
|
|
|
1618
2155
|
// src/task/BackgroundRemovalTask.ts
|
|
1619
|
-
var
|
|
2156
|
+
var modelSchema3 = TypeModel("model:BackgroundRemovalTask");
|
|
1620
2157
|
var BackgroundRemovalInputSchema = {
|
|
1621
2158
|
type: "object",
|
|
1622
2159
|
properties: {
|
|
1623
2160
|
image: TypeImageInput,
|
|
1624
|
-
model:
|
|
2161
|
+
model: modelSchema3
|
|
1625
2162
|
},
|
|
1626
2163
|
required: ["image", "model"],
|
|
1627
2164
|
additionalProperties: false
|
|
@@ -1653,22 +2190,22 @@ class BackgroundRemovalTask extends AiVisionTask {
|
|
|
1653
2190
|
var backgroundRemoval = (input, config) => {
|
|
1654
2191
|
return new BackgroundRemovalTask(config).run(input);
|
|
1655
2192
|
};
|
|
1656
|
-
|
|
2193
|
+
Workflow2.prototype.backgroundRemoval = CreateWorkflow2(BackgroundRemovalTask);
|
|
1657
2194
|
|
|
1658
2195
|
// src/task/ChunkRetrievalTask.ts
|
|
1659
|
-
import { TypeKnowledgeBase } from "@workglow/knowledge-base";
|
|
1660
|
-
import { CreateWorkflow as
|
|
2196
|
+
import { TypeKnowledgeBase as TypeKnowledgeBase2 } from "@workglow/knowledge-base";
|
|
2197
|
+
import { CreateWorkflow as CreateWorkflow4, Task as Task3, Workflow as Workflow4 } from "@workglow/task-graph";
|
|
1661
2198
|
import {
|
|
1662
2199
|
isTypedArray,
|
|
1663
2200
|
TypedArraySchema as TypedArraySchema2
|
|
1664
2201
|
} from "@workglow/util/schema";
|
|
1665
2202
|
|
|
1666
2203
|
// src/task/TextEmbeddingTask.ts
|
|
1667
|
-
import { CreateWorkflow as
|
|
2204
|
+
import { CreateWorkflow as CreateWorkflow3, Workflow as Workflow3 } from "@workglow/task-graph";
|
|
1668
2205
|
import {
|
|
1669
2206
|
TypedArraySchema
|
|
1670
2207
|
} from "@workglow/util/schema";
|
|
1671
|
-
var
|
|
2208
|
+
var modelSchema4 = TypeModel("model:TextEmbeddingTask");
|
|
1672
2209
|
var TextEmbeddingInputSchema = {
|
|
1673
2210
|
type: "object",
|
|
1674
2211
|
properties: {
|
|
@@ -1677,7 +2214,7 @@ var TextEmbeddingInputSchema = {
|
|
|
1677
2214
|
title: "Text",
|
|
1678
2215
|
description: "The text to embed"
|
|
1679
2216
|
}),
|
|
1680
|
-
model:
|
|
2217
|
+
model: modelSchema4
|
|
1681
2218
|
},
|
|
1682
2219
|
required: ["text", "model"],
|
|
1683
2220
|
additionalProperties: false
|
|
@@ -1709,13 +2246,13 @@ class TextEmbeddingTask extends AiTask {
|
|
|
1709
2246
|
var textEmbedding = async (input, config) => {
|
|
1710
2247
|
return new TextEmbeddingTask(config).run(input);
|
|
1711
2248
|
};
|
|
1712
|
-
|
|
2249
|
+
Workflow3.prototype.textEmbedding = CreateWorkflow3(TextEmbeddingTask);
|
|
1713
2250
|
|
|
1714
2251
|
// src/task/ChunkRetrievalTask.ts
|
|
1715
|
-
var
|
|
2252
|
+
var inputSchema2 = {
|
|
1716
2253
|
type: "object",
|
|
1717
2254
|
properties: {
|
|
1718
|
-
knowledgeBase:
|
|
2255
|
+
knowledgeBase: TypeKnowledgeBase2({
|
|
1719
2256
|
title: "Knowledge Base",
|
|
1720
2257
|
description: "The knowledge base instance to search in"
|
|
1721
2258
|
}),
|
|
@@ -1788,7 +2325,7 @@ var inputSchema = {
|
|
|
1788
2325
|
else: {},
|
|
1789
2326
|
additionalProperties: false
|
|
1790
2327
|
};
|
|
1791
|
-
var
|
|
2328
|
+
var outputSchema2 = {
|
|
1792
2329
|
type: "object",
|
|
1793
2330
|
properties: {
|
|
1794
2331
|
chunks: {
|
|
@@ -1849,17 +2386,17 @@ var outputSchema = {
|
|
|
1849
2386
|
additionalProperties: false
|
|
1850
2387
|
};
|
|
1851
2388
|
|
|
1852
|
-
class ChunkRetrievalTask extends
|
|
2389
|
+
class ChunkRetrievalTask extends Task3 {
|
|
1853
2390
|
static type = "ChunkRetrievalTask";
|
|
1854
2391
|
static category = "RAG";
|
|
1855
2392
|
static title = "Chunk Retrieval";
|
|
1856
2393
|
static description = "End-to-end retrieval: embed query (if string) and search the knowledge base. Supports similarity and hybrid methods.";
|
|
1857
2394
|
static cacheable = true;
|
|
1858
2395
|
static inputSchema() {
|
|
1859
|
-
return
|
|
2396
|
+
return inputSchema2;
|
|
1860
2397
|
}
|
|
1861
2398
|
static outputSchema() {
|
|
1862
|
-
return
|
|
2399
|
+
return outputSchema2;
|
|
1863
2400
|
}
|
|
1864
2401
|
async execute(input, context) {
|
|
1865
2402
|
const {
|
|
@@ -1930,18 +2467,18 @@ class ChunkRetrievalTask extends Task2 {
|
|
|
1930
2467
|
var chunkRetrieval = (input, config) => {
|
|
1931
2468
|
return new ChunkRetrievalTask(config).run(input);
|
|
1932
2469
|
};
|
|
1933
|
-
|
|
2470
|
+
Workflow4.prototype.chunkRetrieval = CreateWorkflow4(ChunkRetrievalTask);
|
|
1934
2471
|
|
|
1935
2472
|
// src/task/ChunkVectorUpsertTask.ts
|
|
1936
|
-
import { ChunkRecordArraySchema, TypeKnowledgeBase as
|
|
1937
|
-
import { CreateWorkflow as
|
|
2473
|
+
import { ChunkRecordArraySchema, TypeKnowledgeBase as TypeKnowledgeBase3 } from "@workglow/knowledge-base";
|
|
2474
|
+
import { CreateWorkflow as CreateWorkflow5, Task as Task4, Workflow as Workflow5 } from "@workglow/task-graph";
|
|
1938
2475
|
import {
|
|
1939
2476
|
TypedArraySchema as TypedArraySchema3
|
|
1940
2477
|
} from "@workglow/util/schema";
|
|
1941
|
-
var
|
|
2478
|
+
var inputSchema3 = {
|
|
1942
2479
|
type: "object",
|
|
1943
2480
|
properties: {
|
|
1944
|
-
knowledgeBase:
|
|
2481
|
+
knowledgeBase: TypeKnowledgeBase3({
|
|
1945
2482
|
title: "Knowledge Base",
|
|
1946
2483
|
description: "The knowledge base instance to store vectors in"
|
|
1947
2484
|
}),
|
|
@@ -1959,7 +2496,7 @@ var inputSchema2 = {
|
|
|
1959
2496
|
required: ["knowledgeBase", "chunks", "vector"],
|
|
1960
2497
|
additionalProperties: false
|
|
1961
2498
|
};
|
|
1962
|
-
var
|
|
2499
|
+
var outputSchema3 = {
|
|
1963
2500
|
type: "object",
|
|
1964
2501
|
properties: {
|
|
1965
2502
|
count: {
|
|
@@ -1983,17 +2520,17 @@ var outputSchema2 = {
|
|
|
1983
2520
|
additionalProperties: false
|
|
1984
2521
|
};
|
|
1985
2522
|
|
|
1986
|
-
class ChunkVectorUpsertTask extends
|
|
2523
|
+
class ChunkVectorUpsertTask extends Task4 {
|
|
1987
2524
|
static type = "ChunkVectorUpsertTask";
|
|
1988
2525
|
static category = "Document";
|
|
1989
2526
|
static title = "Add to Vector Store";
|
|
1990
2527
|
static description = "Store chunks + their embeddings in a knowledge base (1:1 aligned)";
|
|
1991
2528
|
static cacheable = false;
|
|
1992
2529
|
static inputSchema() {
|
|
1993
|
-
return
|
|
2530
|
+
return inputSchema3;
|
|
1994
2531
|
}
|
|
1995
2532
|
static outputSchema() {
|
|
1996
|
-
return
|
|
2533
|
+
return outputSchema3;
|
|
1997
2534
|
}
|
|
1998
2535
|
async execute(input, context) {
|
|
1999
2536
|
const { knowledgeBase, chunks, vector, doc_title } = input;
|
|
@@ -2038,19 +2575,19 @@ class ChunkVectorUpsertTask extends Task3 {
|
|
|
2038
2575
|
var chunkVectorUpsert = (input, config) => {
|
|
2039
2576
|
return new ChunkVectorUpsertTask(config).run(input);
|
|
2040
2577
|
};
|
|
2041
|
-
|
|
2578
|
+
Workflow5.prototype.chunkVectorUpsert = CreateWorkflow5(ChunkVectorUpsertTask);
|
|
2042
2579
|
|
|
2043
2580
|
// src/task/ContextBuilderTask.ts
|
|
2044
2581
|
import { estimateTokens } from "@workglow/knowledge-base";
|
|
2045
2582
|
import {
|
|
2046
|
-
CreateWorkflow as
|
|
2047
|
-
Task as
|
|
2048
|
-
Workflow as
|
|
2583
|
+
CreateWorkflow as CreateWorkflow7,
|
|
2584
|
+
Task as Task5,
|
|
2585
|
+
Workflow as Workflow7
|
|
2049
2586
|
} from "@workglow/task-graph";
|
|
2050
2587
|
|
|
2051
2588
|
// src/task/CountTokensTask.ts
|
|
2052
|
-
import { CreateWorkflow as
|
|
2053
|
-
var
|
|
2589
|
+
import { CreateWorkflow as CreateWorkflow6, Workflow as Workflow6 } from "@workglow/task-graph";
|
|
2590
|
+
var modelSchema5 = TypeModel("model");
|
|
2054
2591
|
var CountTokensInputSchema = {
|
|
2055
2592
|
type: "object",
|
|
2056
2593
|
properties: {
|
|
@@ -2059,7 +2596,7 @@ var CountTokensInputSchema = {
|
|
|
2059
2596
|
title: "Text",
|
|
2060
2597
|
description: "The text to count tokens for"
|
|
2061
2598
|
},
|
|
2062
|
-
model:
|
|
2599
|
+
model: modelSchema5
|
|
2063
2600
|
},
|
|
2064
2601
|
required: ["text", "model"],
|
|
2065
2602
|
additionalProperties: false
|
|
@@ -2093,7 +2630,7 @@ class CountTokensTask extends AiTask {
|
|
|
2093
2630
|
var countTokens = async (input, config) => {
|
|
2094
2631
|
return new CountTokensTask(config).run(input);
|
|
2095
2632
|
};
|
|
2096
|
-
|
|
2633
|
+
Workflow6.prototype.countTokens = CreateWorkflow6(CountTokensTask);
|
|
2097
2634
|
|
|
2098
2635
|
// src/task/ContextBuilderTask.ts
|
|
2099
2636
|
var ContextFormat = {
|
|
@@ -2103,11 +2640,11 @@ var ContextFormat = {
|
|
|
2103
2640
|
MARKDOWN: "markdown",
|
|
2104
2641
|
JSON: "json"
|
|
2105
2642
|
};
|
|
2106
|
-
var
|
|
2643
|
+
var modelSchema6 = TypeModel("model", {
|
|
2107
2644
|
title: "Model",
|
|
2108
2645
|
description: "Model to use for token counting (optional, falls back to estimation)"
|
|
2109
2646
|
});
|
|
2110
|
-
var
|
|
2647
|
+
var inputSchema4 = {
|
|
2111
2648
|
type: "object",
|
|
2112
2649
|
properties: {
|
|
2113
2650
|
chunks: {
|
|
@@ -2167,12 +2704,12 @@ var inputSchema3 = {
|
|
|
2167
2704
|
|
|
2168
2705
|
`
|
|
2169
2706
|
},
|
|
2170
|
-
model:
|
|
2707
|
+
model: modelSchema6
|
|
2171
2708
|
},
|
|
2172
2709
|
required: ["chunks"],
|
|
2173
2710
|
additionalProperties: false
|
|
2174
2711
|
};
|
|
2175
|
-
var
|
|
2712
|
+
var outputSchema4 = {
|
|
2176
2713
|
type: "object",
|
|
2177
2714
|
properties: {
|
|
2178
2715
|
context: {
|
|
@@ -2200,17 +2737,17 @@ var outputSchema3 = {
|
|
|
2200
2737
|
additionalProperties: false
|
|
2201
2738
|
};
|
|
2202
2739
|
|
|
2203
|
-
class ContextBuilderTask extends
|
|
2740
|
+
class ContextBuilderTask extends Task5 {
|
|
2204
2741
|
static type = "ContextBuilderTask";
|
|
2205
2742
|
static category = "RAG";
|
|
2206
2743
|
static title = "Context Builder";
|
|
2207
2744
|
static description = "Format retrieved chunks into context for LLM prompts";
|
|
2208
2745
|
static cacheable = true;
|
|
2209
2746
|
static inputSchema() {
|
|
2210
|
-
return
|
|
2747
|
+
return inputSchema4;
|
|
2211
2748
|
}
|
|
2212
2749
|
static outputSchema() {
|
|
2213
|
-
return
|
|
2750
|
+
return outputSchema4;
|
|
2214
2751
|
}
|
|
2215
2752
|
async execute(input, context) {
|
|
2216
2753
|
return this.executePreview(input, context);
|
|
@@ -2396,15 +2933,15 @@ class ContextBuilderTask extends Task4 {
|
|
|
2396
2933
|
var contextBuilder = (input, config) => {
|
|
2397
2934
|
return new ContextBuilderTask(config).run(input);
|
|
2398
2935
|
};
|
|
2399
|
-
|
|
2936
|
+
Workflow7.prototype.contextBuilder = CreateWorkflow7(ContextBuilderTask);
|
|
2400
2937
|
|
|
2401
2938
|
// src/task/DocumentEnricherTask.ts
|
|
2402
2939
|
import { getChildren, hasChildren } from "@workglow/knowledge-base";
|
|
2403
|
-
import { CreateWorkflow as
|
|
2940
|
+
import { CreateWorkflow as CreateWorkflow10, Task as Task6, Workflow as Workflow10 } from "@workglow/task-graph";
|
|
2404
2941
|
|
|
2405
2942
|
// src/task/TextNamedEntityRecognitionTask.ts
|
|
2406
|
-
import { CreateWorkflow as
|
|
2407
|
-
var
|
|
2943
|
+
import { CreateWorkflow as CreateWorkflow8, Workflow as Workflow8 } from "@workglow/task-graph";
|
|
2944
|
+
var modelSchema7 = TypeModel("model:TextNamedEntityRecognitionTask");
|
|
2408
2945
|
var TextNamedEntityRecognitionInputSchema = {
|
|
2409
2946
|
type: "object",
|
|
2410
2947
|
properties: {
|
|
@@ -2423,7 +2960,7 @@ var TextNamedEntityRecognitionInputSchema = {
|
|
|
2423
2960
|
"x-ui-group": "Configuration",
|
|
2424
2961
|
"x-ui-group-open": false
|
|
2425
2962
|
},
|
|
2426
|
-
model:
|
|
2963
|
+
model: modelSchema7
|
|
2427
2964
|
},
|
|
2428
2965
|
required: ["text", "model"],
|
|
2429
2966
|
additionalProperties: false
|
|
@@ -2478,11 +3015,11 @@ class TextNamedEntityRecognitionTask extends AiTask {
|
|
|
2478
3015
|
var textNamedEntityRecognition = (input, config) => {
|
|
2479
3016
|
return new TextNamedEntityRecognitionTask(config).run(input);
|
|
2480
3017
|
};
|
|
2481
|
-
|
|
3018
|
+
Workflow8.prototype.textNamedEntityRecognition = CreateWorkflow8(TextNamedEntityRecognitionTask);
|
|
2482
3019
|
|
|
2483
3020
|
// src/task/TextSummaryTask.ts
|
|
2484
|
-
import { CreateWorkflow as
|
|
2485
|
-
var
|
|
3021
|
+
import { CreateWorkflow as CreateWorkflow9, Workflow as Workflow9 } from "@workglow/task-graph";
|
|
3022
|
+
var modelSchema8 = TypeModel("model:TextSummaryTask");
|
|
2486
3023
|
var TextSummaryInputSchema = {
|
|
2487
3024
|
type: "object",
|
|
2488
3025
|
properties: {
|
|
@@ -2491,7 +3028,7 @@ var TextSummaryInputSchema = {
|
|
|
2491
3028
|
title: "Text",
|
|
2492
3029
|
description: "The text to summarize"
|
|
2493
3030
|
},
|
|
2494
|
-
model:
|
|
3031
|
+
model: modelSchema8
|
|
2495
3032
|
},
|
|
2496
3033
|
required: ["text", "model"],
|
|
2497
3034
|
additionalProperties: false
|
|
@@ -2526,10 +3063,10 @@ class TextSummaryTask extends StreamingAiTask {
|
|
|
2526
3063
|
var textSummary = async (input, config) => {
|
|
2527
3064
|
return new TextSummaryTask(config).run(input);
|
|
2528
3065
|
};
|
|
2529
|
-
|
|
3066
|
+
Workflow9.prototype.textSummary = CreateWorkflow9(TextSummaryTask);
|
|
2530
3067
|
|
|
2531
3068
|
// src/task/DocumentEnricherTask.ts
|
|
2532
|
-
var
|
|
3069
|
+
var inputSchema5 = {
|
|
2533
3070
|
type: "object",
|
|
2534
3071
|
properties: {
|
|
2535
3072
|
doc_id: {
|
|
@@ -2573,7 +3110,7 @@ var inputSchema4 = {
|
|
|
2573
3110
|
required: [],
|
|
2574
3111
|
additionalProperties: false
|
|
2575
3112
|
};
|
|
2576
|
-
var
|
|
3113
|
+
var outputSchema5 = {
|
|
2577
3114
|
type: "object",
|
|
2578
3115
|
properties: {
|
|
2579
3116
|
doc_id: {
|
|
@@ -2600,17 +3137,17 @@ var outputSchema4 = {
|
|
|
2600
3137
|
additionalProperties: false
|
|
2601
3138
|
};
|
|
2602
3139
|
|
|
2603
|
-
class DocumentEnricherTask extends
|
|
3140
|
+
class DocumentEnricherTask extends Task6 {
|
|
2604
3141
|
static type = "DocumentEnricherTask";
|
|
2605
3142
|
static category = "Document";
|
|
2606
3143
|
static title = "Document Enricher";
|
|
2607
3144
|
static description = "Enrich document nodes with summaries and entities";
|
|
2608
3145
|
static cacheable = true;
|
|
2609
3146
|
static inputSchema() {
|
|
2610
|
-
return
|
|
3147
|
+
return inputSchema5;
|
|
2611
3148
|
}
|
|
2612
3149
|
static outputSchema() {
|
|
2613
|
-
return
|
|
3150
|
+
return outputSchema5;
|
|
2614
3151
|
}
|
|
2615
3152
|
async execute(input, context) {
|
|
2616
3153
|
const {
|
|
@@ -2759,19 +3296,19 @@ class DocumentEnricherTask extends Task5 {
|
|
|
2759
3296
|
var documentEnricher = (input, config) => {
|
|
2760
3297
|
return new DocumentEnricherTask(config).run(input);
|
|
2761
3298
|
};
|
|
2762
|
-
|
|
3299
|
+
Workflow10.prototype.documentEnricher = CreateWorkflow10(DocumentEnricherTask);
|
|
2763
3300
|
|
|
2764
3301
|
// src/task/DocumentUpsertTask.ts
|
|
2765
3302
|
import {
|
|
2766
3303
|
Document,
|
|
2767
3304
|
DocumentMetadataSchema,
|
|
2768
|
-
TypeKnowledgeBase as
|
|
3305
|
+
TypeKnowledgeBase as TypeKnowledgeBase4
|
|
2769
3306
|
} from "@workglow/knowledge-base";
|
|
2770
|
-
import { CreateWorkflow as
|
|
2771
|
-
var
|
|
3307
|
+
import { CreateWorkflow as CreateWorkflow11, Task as Task7, Workflow as Workflow11 } from "@workglow/task-graph";
|
|
3308
|
+
var inputSchema6 = {
|
|
2772
3309
|
type: "object",
|
|
2773
3310
|
properties: {
|
|
2774
|
-
knowledgeBase:
|
|
3311
|
+
knowledgeBase: TypeKnowledgeBase4({
|
|
2775
3312
|
title: "Knowledge Base",
|
|
2776
3313
|
description: "The knowledge base instance to store the document in"
|
|
2777
3314
|
}),
|
|
@@ -2799,7 +3336,7 @@ var inputSchema5 = {
|
|
|
2799
3336
|
required: ["knowledgeBase", "doc_id", "documentTree"],
|
|
2800
3337
|
additionalProperties: false
|
|
2801
3338
|
};
|
|
2802
|
-
var
|
|
3339
|
+
var outputSchema6 = {
|
|
2803
3340
|
type: "object",
|
|
2804
3341
|
properties: {
|
|
2805
3342
|
doc_id: {
|
|
@@ -2812,17 +3349,17 @@ var outputSchema5 = {
|
|
|
2812
3349
|
additionalProperties: false
|
|
2813
3350
|
};
|
|
2814
3351
|
|
|
2815
|
-
class DocumentUpsertTask extends
|
|
3352
|
+
class DocumentUpsertTask extends Task7 {
|
|
2816
3353
|
static type = "DocumentUpsertTask";
|
|
2817
3354
|
static category = "Document";
|
|
2818
3355
|
static title = "Add Document";
|
|
2819
3356
|
static description = "Persist a parsed document tree to a knowledge base";
|
|
2820
3357
|
static cacheable = false;
|
|
2821
3358
|
static inputSchema() {
|
|
2822
|
-
return
|
|
3359
|
+
return inputSchema6;
|
|
2823
3360
|
}
|
|
2824
3361
|
static outputSchema() {
|
|
2825
|
-
return
|
|
3362
|
+
return outputSchema6;
|
|
2826
3363
|
}
|
|
2827
3364
|
async execute(input, context) {
|
|
2828
3365
|
const { knowledgeBase, doc_id, documentTree, title, metadata } = input;
|
|
@@ -2845,15 +3382,15 @@ class DocumentUpsertTask extends Task6 {
|
|
|
2845
3382
|
var documentUpsert = (input, config) => {
|
|
2846
3383
|
return new DocumentUpsertTask(config).run(input);
|
|
2847
3384
|
};
|
|
2848
|
-
|
|
3385
|
+
Workflow11.prototype.documentUpsert = CreateWorkflow11(DocumentUpsertTask);
|
|
2849
3386
|
|
|
2850
3387
|
// src/task/DownloadModelTask.ts
|
|
2851
|
-
import { CreateWorkflow as
|
|
2852
|
-
var
|
|
3388
|
+
import { CreateWorkflow as CreateWorkflow12, Workflow as Workflow12 } from "@workglow/task-graph";
|
|
3389
|
+
var modelSchema9 = TypeModel("model");
|
|
2853
3390
|
var DownloadModelInputSchema = {
|
|
2854
3391
|
type: "object",
|
|
2855
3392
|
properties: {
|
|
2856
|
-
model:
|
|
3393
|
+
model: modelSchema9
|
|
2857
3394
|
},
|
|
2858
3395
|
required: ["model"],
|
|
2859
3396
|
additionalProperties: false
|
|
@@ -2861,7 +3398,7 @@ var DownloadModelInputSchema = {
|
|
|
2861
3398
|
var DownloadModelOutputSchema = {
|
|
2862
3399
|
type: "object",
|
|
2863
3400
|
properties: {
|
|
2864
|
-
model:
|
|
3401
|
+
model: modelSchema9
|
|
2865
3402
|
},
|
|
2866
3403
|
required: ["model"],
|
|
2867
3404
|
additionalProperties: false
|
|
@@ -2915,10 +3452,10 @@ class DownloadModelTask extends AiTask {
|
|
|
2915
3452
|
var downloadModel = (input, config) => {
|
|
2916
3453
|
return new DownloadModelTask(config).run(input);
|
|
2917
3454
|
};
|
|
2918
|
-
|
|
3455
|
+
Workflow12.prototype.downloadModel = CreateWorkflow12(DownloadModelTask);
|
|
2919
3456
|
|
|
2920
3457
|
// src/task/generation/ImageEditTask.ts
|
|
2921
|
-
import { CreateWorkflow as
|
|
3458
|
+
import { CreateWorkflow as CreateWorkflow13, Workflow as Workflow13 } from "@workglow/task-graph";
|
|
2922
3459
|
import { ImageValueSchema as ImageValueSchema3 } from "@workglow/util/media";
|
|
2923
3460
|
|
|
2924
3461
|
// src/task/base/AiImageOutputTask.ts
|
|
@@ -3050,11 +3587,11 @@ var AiImageOutputSchema = {
|
|
|
3050
3587
|
};
|
|
3051
3588
|
|
|
3052
3589
|
// src/task/generation/ImageEditTask.ts
|
|
3053
|
-
var
|
|
3590
|
+
var modelSchema10 = TypeModel("model:ImageEditTask");
|
|
3054
3591
|
var ImageEditInputSchema = {
|
|
3055
3592
|
type: "object",
|
|
3056
3593
|
properties: {
|
|
3057
|
-
model:
|
|
3594
|
+
model: modelSchema10,
|
|
3058
3595
|
prompt: {
|
|
3059
3596
|
type: "string",
|
|
3060
3597
|
title: "Prompt",
|
|
@@ -3102,11 +3639,11 @@ class ImageEditTask extends AiImageOutputTask {
|
|
|
3102
3639
|
}
|
|
3103
3640
|
}
|
|
3104
3641
|
var imageEdit = (input, config) => new ImageEditTask(config).run(input);
|
|
3105
|
-
|
|
3642
|
+
Workflow13.prototype.imageEdit = CreateWorkflow13(ImageEditTask);
|
|
3106
3643
|
|
|
3107
3644
|
// src/task/FaceDetectorTask.ts
|
|
3108
|
-
import { CreateWorkflow as
|
|
3109
|
-
var
|
|
3645
|
+
import { CreateWorkflow as CreateWorkflow14, Workflow as Workflow14 } from "@workglow/task-graph";
|
|
3646
|
+
var modelSchema11 = TypeModel("model:FaceDetectorTask");
|
|
3110
3647
|
var TypeBoundingBox2 = {
|
|
3111
3648
|
type: "object",
|
|
3112
3649
|
properties: {
|
|
@@ -3179,7 +3716,7 @@ var FaceDetectorInputSchema = {
|
|
|
3179
3716
|
type: "object",
|
|
3180
3717
|
properties: {
|
|
3181
3718
|
image: TypeImageInput,
|
|
3182
|
-
model:
|
|
3719
|
+
model: modelSchema11,
|
|
3183
3720
|
minDetectionConfidence: {
|
|
3184
3721
|
type: "number",
|
|
3185
3722
|
minimum: 0,
|
|
@@ -3233,11 +3770,11 @@ class FaceDetectorTask extends AiVisionTask {
|
|
|
3233
3770
|
var faceDetector = (input, config) => {
|
|
3234
3771
|
return new FaceDetectorTask(config).run(input);
|
|
3235
3772
|
};
|
|
3236
|
-
|
|
3773
|
+
Workflow14.prototype.faceDetector = CreateWorkflow14(FaceDetectorTask);
|
|
3237
3774
|
|
|
3238
3775
|
// src/task/FaceLandmarkerTask.ts
|
|
3239
|
-
import { CreateWorkflow as
|
|
3240
|
-
var
|
|
3776
|
+
import { CreateWorkflow as CreateWorkflow15, Workflow as Workflow15 } from "@workglow/task-graph";
|
|
3777
|
+
var modelSchema12 = TypeModel("model:FaceLandmarkerTask");
|
|
3241
3778
|
var TypeBlendshape = {
|
|
3242
3779
|
type: "object",
|
|
3243
3780
|
properties: {
|
|
@@ -3288,7 +3825,7 @@ var FaceLandmarkerInputSchema = {
|
|
|
3288
3825
|
type: "object",
|
|
3289
3826
|
properties: {
|
|
3290
3827
|
image: TypeImageInput,
|
|
3291
|
-
model:
|
|
3828
|
+
model: modelSchema12,
|
|
3292
3829
|
numFaces: {
|
|
3293
3830
|
type: "number",
|
|
3294
3831
|
minimum: 1,
|
|
@@ -3374,15 +3911,15 @@ class FaceLandmarkerTask extends AiVisionTask {
|
|
|
3374
3911
|
var faceLandmarker = (input, config) => {
|
|
3375
3912
|
return new FaceLandmarkerTask(config).run(input);
|
|
3376
3913
|
};
|
|
3377
|
-
|
|
3914
|
+
Workflow15.prototype.faceLandmarker = CreateWorkflow15(FaceLandmarkerTask);
|
|
3378
3915
|
|
|
3379
3916
|
// src/task/generation/ImageGenerateTask.ts
|
|
3380
|
-
import { CreateWorkflow as
|
|
3381
|
-
var
|
|
3917
|
+
import { CreateWorkflow as CreateWorkflow16, Workflow as Workflow16 } from "@workglow/task-graph";
|
|
3918
|
+
var modelSchema13 = TypeModel("model:ImageGenerateTask");
|
|
3382
3919
|
var ImageGenerateInputSchema = {
|
|
3383
3920
|
type: "object",
|
|
3384
3921
|
properties: {
|
|
3385
|
-
model:
|
|
3922
|
+
model: modelSchema13,
|
|
3386
3923
|
prompt: {
|
|
3387
3924
|
type: "string",
|
|
3388
3925
|
title: "Prompt",
|
|
@@ -3416,11 +3953,11 @@ class ImageGenerateTask extends AiImageOutputTask {
|
|
|
3416
3953
|
}
|
|
3417
3954
|
}
|
|
3418
3955
|
var imageGenerate = (input, config) => new ImageGenerateTask(config).run(input);
|
|
3419
|
-
|
|
3956
|
+
Workflow16.prototype.imageGenerate = CreateWorkflow16(ImageGenerateTask);
|
|
3420
3957
|
|
|
3421
3958
|
// src/task/GestureRecognizerTask.ts
|
|
3422
|
-
import { CreateWorkflow as
|
|
3423
|
-
var
|
|
3959
|
+
import { CreateWorkflow as CreateWorkflow17, Workflow as Workflow17 } from "@workglow/task-graph";
|
|
3960
|
+
var modelSchema14 = TypeModel("model:GestureRecognizerTask");
|
|
3424
3961
|
var TypeGesture = {
|
|
3425
3962
|
type: "object",
|
|
3426
3963
|
properties: {
|
|
@@ -3492,7 +4029,7 @@ var GestureRecognizerInputSchema = {
|
|
|
3492
4029
|
type: "object",
|
|
3493
4030
|
properties: {
|
|
3494
4031
|
image: TypeImageInput,
|
|
3495
|
-
model:
|
|
4032
|
+
model: modelSchema14,
|
|
3496
4033
|
numHands: {
|
|
3497
4034
|
type: "number",
|
|
3498
4035
|
minimum: 1,
|
|
@@ -3564,11 +4101,11 @@ class GestureRecognizerTask extends AiVisionTask {
|
|
|
3564
4101
|
var gestureRecognizer = (input, config) => {
|
|
3565
4102
|
return new GestureRecognizerTask(config).run(input);
|
|
3566
4103
|
};
|
|
3567
|
-
|
|
4104
|
+
Workflow17.prototype.gestureRecognizer = CreateWorkflow17(GestureRecognizerTask);
|
|
3568
4105
|
|
|
3569
4106
|
// src/task/HandLandmarkerTask.ts
|
|
3570
|
-
import { CreateWorkflow as
|
|
3571
|
-
var
|
|
4107
|
+
import { CreateWorkflow as CreateWorkflow18, Workflow as Workflow18 } from "@workglow/task-graph";
|
|
4108
|
+
var modelSchema15 = TypeModel("model:HandLandmarkerTask");
|
|
3572
4109
|
var TypeHandedness2 = {
|
|
3573
4110
|
type: "object",
|
|
3574
4111
|
properties: {
|
|
@@ -3617,7 +4154,7 @@ var HandLandmarkerInputSchema = {
|
|
|
3617
4154
|
type: "object",
|
|
3618
4155
|
properties: {
|
|
3619
4156
|
image: TypeImageInput,
|
|
3620
|
-
model:
|
|
4157
|
+
model: modelSchema15,
|
|
3621
4158
|
numHands: {
|
|
3622
4159
|
type: "number",
|
|
3623
4160
|
minimum: 1,
|
|
@@ -3689,22 +4226,23 @@ class HandLandmarkerTask extends AiVisionTask {
|
|
|
3689
4226
|
var handLandmarker = (input, config) => {
|
|
3690
4227
|
return new HandLandmarkerTask(config).run(input);
|
|
3691
4228
|
};
|
|
3692
|
-
|
|
4229
|
+
Workflow18.prototype.handLandmarker = CreateWorkflow18(HandLandmarkerTask);
|
|
3693
4230
|
|
|
3694
4231
|
// src/task/HierarchicalChunkerTask.ts
|
|
3695
4232
|
import {
|
|
3696
4233
|
ChunkRecordSchema,
|
|
3697
4234
|
estimateTokens as estimateTokens2,
|
|
3698
4235
|
getChildren as getChildren2,
|
|
3699
|
-
hasChildren as hasChildren2
|
|
4236
|
+
hasChildren as hasChildren2,
|
|
4237
|
+
NodeKind
|
|
3700
4238
|
} from "@workglow/knowledge-base";
|
|
3701
|
-
import { CreateWorkflow as
|
|
4239
|
+
import { CreateWorkflow as CreateWorkflow19, Task as Task8, Workflow as Workflow19 } from "@workglow/task-graph";
|
|
3702
4240
|
import { uuid4 } from "@workglow/util";
|
|
3703
|
-
var
|
|
4241
|
+
var modelSchema16 = TypeModel("model", {
|
|
3704
4242
|
title: "Model",
|
|
3705
4243
|
description: "Model to use for token counting"
|
|
3706
4244
|
});
|
|
3707
|
-
var
|
|
4245
|
+
var inputSchema7 = {
|
|
3708
4246
|
type: "object",
|
|
3709
4247
|
properties: {
|
|
3710
4248
|
doc_id: {
|
|
@@ -3746,12 +4284,12 @@ var inputSchema6 = {
|
|
|
3746
4284
|
description: "Strategy for chunking",
|
|
3747
4285
|
default: "hierarchical"
|
|
3748
4286
|
},
|
|
3749
|
-
model:
|
|
4287
|
+
model: modelSchema16
|
|
3750
4288
|
},
|
|
3751
4289
|
required: ["doc_id", "documentTree"],
|
|
3752
4290
|
additionalProperties: false
|
|
3753
4291
|
};
|
|
3754
|
-
var
|
|
4292
|
+
var outputSchema7 = {
|
|
3755
4293
|
type: "object",
|
|
3756
4294
|
properties: {
|
|
3757
4295
|
doc_id: {
|
|
@@ -3781,17 +4319,17 @@ var outputSchema6 = {
|
|
|
3781
4319
|
additionalProperties: false
|
|
3782
4320
|
};
|
|
3783
4321
|
|
|
3784
|
-
class HierarchicalChunkerTask extends
|
|
4322
|
+
class HierarchicalChunkerTask extends Task8 {
|
|
3785
4323
|
static type = "HierarchicalChunkerTask";
|
|
3786
4324
|
static category = "Document";
|
|
3787
4325
|
static title = "Hierarchical Chunker";
|
|
3788
4326
|
static description = "Chunk documents hierarchically respecting token budgets";
|
|
3789
4327
|
static cacheable = true;
|
|
3790
4328
|
static inputSchema() {
|
|
3791
|
-
return
|
|
4329
|
+
return inputSchema7;
|
|
3792
4330
|
}
|
|
3793
4331
|
static outputSchema() {
|
|
3794
|
-
return
|
|
4332
|
+
return outputSchema7;
|
|
3795
4333
|
}
|
|
3796
4334
|
async execute(input, context) {
|
|
3797
4335
|
const {
|
|
@@ -3828,7 +4366,7 @@ class HierarchicalChunkerTask extends Task7 {
|
|
|
3828
4366
|
}
|
|
3829
4367
|
const chunks = [];
|
|
3830
4368
|
if (strategy === "hierarchical") {
|
|
3831
|
-
await this.chunkHierarchically(root, [], doc_id, tokenBudget, chunks, countFn);
|
|
4369
|
+
await this.chunkHierarchically(root, [], [], doc_id, tokenBudget, chunks, countFn);
|
|
3832
4370
|
} else {
|
|
3833
4371
|
await this.chunkFlat(root, doc_id, tokenBudget, chunks, countFn);
|
|
3834
4372
|
}
|
|
@@ -3839,23 +4377,35 @@ class HierarchicalChunkerTask extends Task7 {
|
|
|
3839
4377
|
count: chunks.length
|
|
3840
4378
|
};
|
|
3841
4379
|
}
|
|
3842
|
-
async chunkHierarchically(node, nodePath, doc_id, tokenBudget, chunks, countFn) {
|
|
4380
|
+
async chunkHierarchically(node, nodePath, headingPath, doc_id, tokenBudget, chunks, countFn) {
|
|
3843
4381
|
const currentPath = [...nodePath, node.nodeId];
|
|
4382
|
+
const currentHeadings = node.kind === NodeKind.SECTION && typeof node.title === "string" && node.title.trim().length > 0 ? [...headingPath, node.title.trim()] : headingPath;
|
|
3844
4383
|
if (!hasChildren2(node)) {
|
|
3845
|
-
await this.chunkText(node.text, currentPath, doc_id, tokenBudget, chunks, node.nodeId, countFn);
|
|
4384
|
+
await this.chunkText(node.text, currentPath, currentHeadings, doc_id, tokenBudget, chunks, node.nodeId, countFn);
|
|
3846
4385
|
return;
|
|
3847
4386
|
}
|
|
3848
4387
|
const children = getChildren2(node);
|
|
3849
4388
|
for (const child of children) {
|
|
3850
|
-
await this.chunkHierarchically(child, currentPath, doc_id, tokenBudget, chunks, countFn);
|
|
4389
|
+
await this.chunkHierarchically(child, currentPath, currentHeadings, doc_id, tokenBudget, chunks, countFn);
|
|
3851
4390
|
}
|
|
3852
4391
|
}
|
|
3853
|
-
async chunkText(text, nodePath, doc_id, tokenBudget, chunks, leafNodeId, countFn) {
|
|
3854
|
-
|
|
4392
|
+
async chunkText(text, nodePath, headingPath, doc_id, tokenBudget, chunks, leafNodeId, countFn) {
|
|
4393
|
+
if (text.trim().length === 0)
|
|
4394
|
+
return;
|
|
4395
|
+
const budgetAfterReserved = tokenBudget.maxTokensPerChunk - tokenBudget.reservedTokens;
|
|
3855
4396
|
const overlapTokens = tokenBudget.overlapTokens;
|
|
3856
|
-
if (
|
|
4397
|
+
if (budgetAfterReserved <= 0) {
|
|
3857
4398
|
throw new Error(`Invalid token budget: reservedTokens (${tokenBudget.reservedTokens}) must be less than maxTokensPerChunk (${tokenBudget.maxTokensPerChunk})`);
|
|
3858
4399
|
}
|
|
4400
|
+
const breadcrumb = headingPath.join(" > ");
|
|
4401
|
+
const candidatePrefix = breadcrumb ? `${breadcrumb}
|
|
4402
|
+
|
|
4403
|
+
` : "";
|
|
4404
|
+
const prefixTokens = candidatePrefix ? await countFn(candidatePrefix) : 0;
|
|
4405
|
+
const usePrefix = prefixTokens > 0 && prefixTokens < budgetAfterReserved;
|
|
4406
|
+
const prefix = usePrefix ? candidatePrefix : "";
|
|
4407
|
+
const effectivePrefixTokens = usePrefix ? prefixTokens : 0;
|
|
4408
|
+
const maxTokens = budgetAfterReserved - effectivePrefixTokens;
|
|
3859
4409
|
if (overlapTokens >= maxTokens) {
|
|
3860
4410
|
throw new Error(`Invalid token budget: overlapTokens (${overlapTokens}) must be less than effective maxTokens (${maxTokens})`);
|
|
3861
4411
|
}
|
|
@@ -3864,9 +4414,11 @@ class HierarchicalChunkerTask extends Task7 {
|
|
|
3864
4414
|
chunks.push({
|
|
3865
4415
|
chunkId: uuid4(),
|
|
3866
4416
|
doc_id,
|
|
3867
|
-
text,
|
|
4417
|
+
text: prefix + text,
|
|
3868
4418
|
nodePath,
|
|
3869
|
-
depth: nodePath.length
|
|
4419
|
+
depth: nodePath.length,
|
|
4420
|
+
leafNodeId,
|
|
4421
|
+
sectionTitles: [...headingPath]
|
|
3870
4422
|
});
|
|
3871
4423
|
return;
|
|
3872
4424
|
}
|
|
@@ -3891,9 +4443,11 @@ class HierarchicalChunkerTask extends Task7 {
|
|
|
3891
4443
|
chunks.push({
|
|
3892
4444
|
chunkId: uuid4(),
|
|
3893
4445
|
doc_id,
|
|
3894
|
-
text: text.substring(startOffset, endOffset),
|
|
4446
|
+
text: prefix + text.substring(startOffset, endOffset),
|
|
3895
4447
|
nodePath,
|
|
3896
|
-
depth: nodePath.length
|
|
4448
|
+
depth: nodePath.length,
|
|
4449
|
+
leafNodeId,
|
|
4450
|
+
sectionTitles: [...headingPath]
|
|
3897
4451
|
});
|
|
3898
4452
|
if (endOffset >= text.length)
|
|
3899
4453
|
break;
|
|
@@ -3903,7 +4457,7 @@ class HierarchicalChunkerTask extends Task7 {
|
|
|
3903
4457
|
}
|
|
3904
4458
|
async chunkFlat(root, doc_id, tokenBudget, chunks, countFn) {
|
|
3905
4459
|
const allText = this.collectAllText(root);
|
|
3906
|
-
await this.chunkText(allText, [root.nodeId], doc_id, tokenBudget, chunks, root.nodeId, countFn);
|
|
4460
|
+
await this.chunkText(allText, [root.nodeId], [], doc_id, tokenBudget, chunks, root.nodeId, countFn);
|
|
3907
4461
|
}
|
|
3908
4462
|
collectAllText(node) {
|
|
3909
4463
|
const texts = [];
|
|
@@ -3925,15 +4479,15 @@ class HierarchicalChunkerTask extends Task7 {
|
|
|
3925
4479
|
var hierarchicalChunker = (input, config) => {
|
|
3926
4480
|
return new HierarchicalChunkerTask(config).run(input);
|
|
3927
4481
|
};
|
|
3928
|
-
|
|
4482
|
+
Workflow19.prototype.hierarchicalChunker = CreateWorkflow19(HierarchicalChunkerTask);
|
|
3929
4483
|
|
|
3930
4484
|
// src/task/HierarchyJoinTask.ts
|
|
3931
|
-
import { ChunkRecordArraySchema as ChunkRecordArraySchema2, TypeKnowledgeBase as
|
|
3932
|
-
import { CreateWorkflow as
|
|
3933
|
-
var
|
|
4485
|
+
import { ChunkRecordArraySchema as ChunkRecordArraySchema2, TypeKnowledgeBase as TypeKnowledgeBase5 } from "@workglow/knowledge-base";
|
|
4486
|
+
import { CreateWorkflow as CreateWorkflow20, Task as Task9, Workflow as Workflow20 } from "@workglow/task-graph";
|
|
4487
|
+
var inputSchema8 = {
|
|
3934
4488
|
type: "object",
|
|
3935
4489
|
properties: {
|
|
3936
|
-
knowledgeBase:
|
|
4490
|
+
knowledgeBase: TypeKnowledgeBase5({
|
|
3937
4491
|
title: "Knowledge Base",
|
|
3938
4492
|
description: "The knowledge base to query for hierarchy"
|
|
3939
4493
|
}),
|
|
@@ -3972,7 +4526,7 @@ var inputSchema7 = {
|
|
|
3972
4526
|
required: ["knowledgeBase", "metadata"],
|
|
3973
4527
|
additionalProperties: false
|
|
3974
4528
|
};
|
|
3975
|
-
var
|
|
4529
|
+
var outputSchema8 = {
|
|
3976
4530
|
type: "object",
|
|
3977
4531
|
properties: {
|
|
3978
4532
|
metadata: ChunkRecordArraySchema2,
|
|
@@ -4004,17 +4558,17 @@ var outputSchema7 = {
|
|
|
4004
4558
|
additionalProperties: false
|
|
4005
4559
|
};
|
|
4006
4560
|
|
|
4007
|
-
class HierarchyJoinTask extends
|
|
4561
|
+
class HierarchyJoinTask extends Task9 {
|
|
4008
4562
|
static type = "HierarchyJoinTask";
|
|
4009
4563
|
static category = "RAG";
|
|
4010
4564
|
static title = "Hierarchy Join";
|
|
4011
4565
|
static description = "Enrich retrieval metadata with document hierarchy context";
|
|
4012
4566
|
static cacheable = false;
|
|
4013
4567
|
static inputSchema() {
|
|
4014
|
-
return
|
|
4568
|
+
return inputSchema8;
|
|
4015
4569
|
}
|
|
4016
4570
|
static outputSchema() {
|
|
4017
|
-
return
|
|
4571
|
+
return outputSchema8;
|
|
4018
4572
|
}
|
|
4019
4573
|
async execute(input, context) {
|
|
4020
4574
|
const {
|
|
@@ -4100,15 +4654,15 @@ class HierarchyJoinTask extends Task8 {
|
|
|
4100
4654
|
var hierarchyJoin = (input, config) => {
|
|
4101
4655
|
return new HierarchyJoinTask(config).run(input);
|
|
4102
4656
|
};
|
|
4103
|
-
|
|
4657
|
+
Workflow20.prototype.hierarchyJoin = CreateWorkflow20(HierarchyJoinTask);
|
|
4104
4658
|
|
|
4105
4659
|
// src/task/KbToDocumentsTask.ts
|
|
4106
|
-
import { TypeKnowledgeBase as
|
|
4107
|
-
import { CreateWorkflow as
|
|
4108
|
-
var
|
|
4660
|
+
import { TypeKnowledgeBase as TypeKnowledgeBase6 } from "@workglow/knowledge-base";
|
|
4661
|
+
import { CreateWorkflow as CreateWorkflow21, Task as Task10, Workflow as Workflow21 } from "@workglow/task-graph";
|
|
4662
|
+
var inputSchema9 = {
|
|
4109
4663
|
type: "object",
|
|
4110
4664
|
properties: {
|
|
4111
|
-
knowledgeBase:
|
|
4665
|
+
knowledgeBase: TypeKnowledgeBase6({
|
|
4112
4666
|
title: "Knowledge Base",
|
|
4113
4667
|
description: "The knowledge base instance to list documents from"
|
|
4114
4668
|
}),
|
|
@@ -4122,7 +4676,7 @@ var inputSchema8 = {
|
|
|
4122
4676
|
required: ["knowledgeBase"],
|
|
4123
4677
|
additionalProperties: false
|
|
4124
4678
|
};
|
|
4125
|
-
var
|
|
4679
|
+
var outputSchema9 = {
|
|
4126
4680
|
type: "object",
|
|
4127
4681
|
properties: {
|
|
4128
4682
|
doc_id: {
|
|
@@ -4148,17 +4702,17 @@ var outputSchema8 = {
|
|
|
4148
4702
|
additionalProperties: false
|
|
4149
4703
|
};
|
|
4150
4704
|
|
|
4151
|
-
class KbToDocumentsTask extends
|
|
4705
|
+
class KbToDocumentsTask extends Task10 {
|
|
4152
4706
|
static type = "KbToDocumentsTask";
|
|
4153
4707
|
static category = "Document";
|
|
4154
4708
|
static title = "Knowledge Base to Documents";
|
|
4155
4709
|
static description = "List documents from a knowledge base, optionally filtering to only those that need embedding";
|
|
4156
4710
|
static cacheable = false;
|
|
4157
4711
|
static inputSchema() {
|
|
4158
|
-
return
|
|
4712
|
+
return inputSchema9;
|
|
4159
4713
|
}
|
|
4160
4714
|
static outputSchema() {
|
|
4161
|
-
return
|
|
4715
|
+
return outputSchema9;
|
|
4162
4716
|
}
|
|
4163
4717
|
async execute(input, context) {
|
|
4164
4718
|
const { knowledgeBase, onlyStale = true } = input;
|
|
@@ -4189,16 +4743,16 @@ class KbToDocumentsTask extends Task9 {
|
|
|
4189
4743
|
var kbToDocuments = (input, config) => {
|
|
4190
4744
|
return new KbToDocumentsTask(config).run(input);
|
|
4191
4745
|
};
|
|
4192
|
-
|
|
4746
|
+
Workflow21.prototype.kbToDocuments = CreateWorkflow21(KbToDocumentsTask);
|
|
4193
4747
|
|
|
4194
4748
|
// src/task/ImageClassificationTask.ts
|
|
4195
|
-
import { CreateWorkflow as
|
|
4196
|
-
var
|
|
4749
|
+
import { CreateWorkflow as CreateWorkflow22, Workflow as Workflow22 } from "@workglow/task-graph";
|
|
4750
|
+
var modelSchema17 = TypeModel("model:ImageClassificationTask");
|
|
4197
4751
|
var ImageClassificationInputSchema = {
|
|
4198
4752
|
type: "object",
|
|
4199
4753
|
properties: {
|
|
4200
4754
|
image: TypeImageInput,
|
|
4201
|
-
model:
|
|
4755
|
+
model: modelSchema17,
|
|
4202
4756
|
categories: {
|
|
4203
4757
|
type: "array",
|
|
4204
4758
|
items: {
|
|
@@ -4252,19 +4806,19 @@ class ImageClassificationTask extends AiVisionTask {
|
|
|
4252
4806
|
var imageClassification = (input, config) => {
|
|
4253
4807
|
return new ImageClassificationTask(config).run(input);
|
|
4254
4808
|
};
|
|
4255
|
-
|
|
4809
|
+
Workflow22.prototype.imageClassification = CreateWorkflow22(ImageClassificationTask);
|
|
4256
4810
|
|
|
4257
4811
|
// src/task/ImageEmbeddingTask.ts
|
|
4258
|
-
import { CreateWorkflow as
|
|
4812
|
+
import { CreateWorkflow as CreateWorkflow23, Workflow as Workflow23 } from "@workglow/task-graph";
|
|
4259
4813
|
import {
|
|
4260
4814
|
TypedArraySchema as TypedArraySchema4
|
|
4261
4815
|
} from "@workglow/util/schema";
|
|
4262
|
-
var
|
|
4816
|
+
var modelSchema18 = TypeModel("model:ImageEmbeddingTask");
|
|
4263
4817
|
var ImageEmbeddingInputSchema = {
|
|
4264
4818
|
type: "object",
|
|
4265
4819
|
properties: {
|
|
4266
4820
|
image: TypeSingleOrArray(TypeImageInput),
|
|
4267
|
-
model:
|
|
4821
|
+
model: modelSchema18
|
|
4268
4822
|
},
|
|
4269
4823
|
required: ["image", "model"],
|
|
4270
4824
|
additionalProperties: false
|
|
@@ -4296,16 +4850,16 @@ class ImageEmbeddingTask extends AiVisionTask {
|
|
|
4296
4850
|
var imageEmbedding = (input, config) => {
|
|
4297
4851
|
return new ImageEmbeddingTask(config).run(input);
|
|
4298
4852
|
};
|
|
4299
|
-
|
|
4853
|
+
Workflow23.prototype.imageEmbedding = CreateWorkflow23(ImageEmbeddingTask);
|
|
4300
4854
|
|
|
4301
4855
|
// src/task/ImageSegmentationTask.ts
|
|
4302
|
-
import { CreateWorkflow as
|
|
4303
|
-
var
|
|
4856
|
+
import { CreateWorkflow as CreateWorkflow24, Workflow as Workflow24 } from "@workglow/task-graph";
|
|
4857
|
+
var modelSchema19 = TypeModel("model:ImageSegmentationTask");
|
|
4304
4858
|
var ImageSegmentationInputSchema = {
|
|
4305
4859
|
type: "object",
|
|
4306
4860
|
properties: {
|
|
4307
4861
|
image: TypeImageInput,
|
|
4308
|
-
model:
|
|
4862
|
+
model: modelSchema19,
|
|
4309
4863
|
threshold: {
|
|
4310
4864
|
type: "number",
|
|
4311
4865
|
title: "Threshold",
|
|
@@ -4384,11 +4938,11 @@ class ImageSegmentationTask extends AiVisionTask {
|
|
|
4384
4938
|
var imageSegmentation = (input, config) => {
|
|
4385
4939
|
return new ImageSegmentationTask(config).run(input);
|
|
4386
4940
|
};
|
|
4387
|
-
|
|
4941
|
+
Workflow24.prototype.imageSegmentation = CreateWorkflow24(ImageSegmentationTask);
|
|
4388
4942
|
|
|
4389
4943
|
// src/task/ImageToTextTask.ts
|
|
4390
|
-
import { CreateWorkflow as
|
|
4391
|
-
var
|
|
4944
|
+
import { CreateWorkflow as CreateWorkflow25, Workflow as Workflow25 } from "@workglow/task-graph";
|
|
4945
|
+
var modelSchema20 = TypeModel("model:ImageToTextTask");
|
|
4392
4946
|
var generatedTextSchema = {
|
|
4393
4947
|
type: "string",
|
|
4394
4948
|
title: "Text",
|
|
@@ -4398,7 +4952,7 @@ var ImageToTextInputSchema = {
|
|
|
4398
4952
|
type: "object",
|
|
4399
4953
|
properties: {
|
|
4400
4954
|
image: TypeImageInput,
|
|
4401
|
-
model:
|
|
4955
|
+
model: modelSchema20,
|
|
4402
4956
|
maxTokens: {
|
|
4403
4957
|
type: "number",
|
|
4404
4958
|
title: "Max Tokens",
|
|
@@ -4439,15 +4993,15 @@ class ImageToTextTask extends AiVisionTask {
|
|
|
4439
4993
|
var imageToText = (input, config) => {
|
|
4440
4994
|
return new ImageToTextTask(config).run(input);
|
|
4441
4995
|
};
|
|
4442
|
-
|
|
4996
|
+
Workflow25.prototype.imageToText = CreateWorkflow25(ImageToTextTask);
|
|
4443
4997
|
|
|
4444
4998
|
// src/task/ModelInfoTask.ts
|
|
4445
|
-
import { CreateWorkflow as
|
|
4446
|
-
var
|
|
4999
|
+
import { CreateWorkflow as CreateWorkflow26, Workflow as Workflow26 } from "@workglow/task-graph";
|
|
5000
|
+
var modelSchema21 = TypeModel("model");
|
|
4447
5001
|
var ModelInfoInputSchema = {
|
|
4448
5002
|
type: "object",
|
|
4449
5003
|
properties: {
|
|
4450
|
-
model:
|
|
5004
|
+
model: modelSchema21,
|
|
4451
5005
|
detail: {
|
|
4452
5006
|
type: "string",
|
|
4453
5007
|
enum: ["cached_status", "files", "files_with_metadata", "dimensions"],
|
|
@@ -4460,7 +5014,7 @@ var ModelInfoInputSchema = {
|
|
|
4460
5014
|
var ModelInfoOutputSchema = {
|
|
4461
5015
|
type: "object",
|
|
4462
5016
|
properties: {
|
|
4463
|
-
model:
|
|
5017
|
+
model: modelSchema21,
|
|
4464
5018
|
is_local: { type: "boolean" },
|
|
4465
5019
|
is_remote: { type: "boolean" },
|
|
4466
5020
|
supports_browser: { type: "boolean" },
|
|
@@ -4518,10 +5072,10 @@ class ModelInfoTask extends AiTask {
|
|
|
4518
5072
|
var modelInfo = (input, config) => {
|
|
4519
5073
|
return new ModelInfoTask(config).run(input);
|
|
4520
5074
|
};
|
|
4521
|
-
|
|
5075
|
+
Workflow26.prototype.modelInfo = CreateWorkflow26(ModelInfoTask);
|
|
4522
5076
|
|
|
4523
5077
|
// src/task/ModelSearchTask.ts
|
|
4524
|
-
import { CreateWorkflow as
|
|
5078
|
+
import { CreateWorkflow as CreateWorkflow27, Task as Task11, Workflow as Workflow27 } from "@workglow/task-graph";
|
|
4525
5079
|
var ModelSearchInputSchema = {
|
|
4526
5080
|
type: "object",
|
|
4527
5081
|
properties: {
|
|
@@ -4594,7 +5148,7 @@ var ModelSearchOutputSchema = {
|
|
|
4594
5148
|
additionalProperties: false
|
|
4595
5149
|
};
|
|
4596
5150
|
|
|
4597
|
-
class ModelSearchTask extends
|
|
5151
|
+
class ModelSearchTask extends Task11 {
|
|
4598
5152
|
static type = "ModelSearchTask";
|
|
4599
5153
|
static category = "AI Model";
|
|
4600
5154
|
static title = "Model Search";
|
|
@@ -4620,11 +5174,11 @@ class ModelSearchTask extends Task10 {
|
|
|
4620
5174
|
var modelSearch = (input, config) => {
|
|
4621
5175
|
return new ModelSearchTask(config).run(input);
|
|
4622
5176
|
};
|
|
4623
|
-
|
|
5177
|
+
Workflow27.prototype.modelSearch = CreateWorkflow27(ModelSearchTask);
|
|
4624
5178
|
|
|
4625
5179
|
// src/task/ObjectDetectionTask.ts
|
|
4626
|
-
import { CreateWorkflow as
|
|
4627
|
-
var
|
|
5180
|
+
import { CreateWorkflow as CreateWorkflow28, Workflow as Workflow28 } from "@workglow/task-graph";
|
|
5181
|
+
var modelSchema22 = TypeModel("model:ObjectDetectionTask");
|
|
4628
5182
|
var detectionSchema = {
|
|
4629
5183
|
type: "object",
|
|
4630
5184
|
properties: {
|
|
@@ -4649,7 +5203,7 @@ var ObjectDetectionInputSchema = {
|
|
|
4649
5203
|
type: "object",
|
|
4650
5204
|
properties: {
|
|
4651
5205
|
image: TypeImageInput,
|
|
4652
|
-
model:
|
|
5206
|
+
model: modelSchema22,
|
|
4653
5207
|
labels: {
|
|
4654
5208
|
type: "array",
|
|
4655
5209
|
items: {
|
|
@@ -4703,11 +5257,11 @@ class ObjectDetectionTask extends AiVisionTask {
|
|
|
4703
5257
|
var objectDetection = (input, config) => {
|
|
4704
5258
|
return new ObjectDetectionTask(config).run(input);
|
|
4705
5259
|
};
|
|
4706
|
-
|
|
5260
|
+
Workflow28.prototype.objectDetection = CreateWorkflow28(ObjectDetectionTask);
|
|
4707
5261
|
|
|
4708
5262
|
// src/task/PoseLandmarkerTask.ts
|
|
4709
|
-
import { CreateWorkflow as
|
|
4710
|
-
var
|
|
5263
|
+
import { CreateWorkflow as CreateWorkflow29, Workflow as Workflow29 } from "@workglow/task-graph";
|
|
5264
|
+
var modelSchema23 = TypeModel("model:PoseLandmarkerTask");
|
|
4711
5265
|
var TypeSegmentationMask = {
|
|
4712
5266
|
type: "object",
|
|
4713
5267
|
properties: {
|
|
@@ -4754,7 +5308,7 @@ var PoseLandmarkerInputSchema = {
|
|
|
4754
5308
|
type: "object",
|
|
4755
5309
|
properties: {
|
|
4756
5310
|
image: TypeImageInput,
|
|
4757
|
-
model:
|
|
5311
|
+
model: modelSchema23,
|
|
4758
5312
|
numPoses: {
|
|
4759
5313
|
type: "number",
|
|
4760
5314
|
minimum: 1,
|
|
@@ -4833,15 +5387,15 @@ class PoseLandmarkerTask extends AiVisionTask {
|
|
|
4833
5387
|
var poseLandmarker = (input, config) => {
|
|
4834
5388
|
return new PoseLandmarkerTask(config).run(input);
|
|
4835
5389
|
};
|
|
4836
|
-
|
|
5390
|
+
Workflow29.prototype.poseLandmarker = CreateWorkflow29(PoseLandmarkerTask);
|
|
4837
5391
|
|
|
4838
5392
|
// src/task/QueryExpanderTask.ts
|
|
4839
|
-
import { CreateWorkflow as
|
|
5393
|
+
import { CreateWorkflow as CreateWorkflow30, Task as Task12, Workflow as Workflow30 } from "@workglow/task-graph";
|
|
4840
5394
|
var QueryExpansionMethod = {
|
|
4841
5395
|
MULTI_QUERY: "multi-query",
|
|
4842
5396
|
SYNONYMS: "synonyms"
|
|
4843
5397
|
};
|
|
4844
|
-
var
|
|
5398
|
+
var inputSchema10 = {
|
|
4845
5399
|
type: "object",
|
|
4846
5400
|
properties: {
|
|
4847
5401
|
query: {
|
|
@@ -4868,7 +5422,7 @@ var inputSchema9 = {
|
|
|
4868
5422
|
required: ["query"],
|
|
4869
5423
|
additionalProperties: false
|
|
4870
5424
|
};
|
|
4871
|
-
var
|
|
5425
|
+
var outputSchema10 = {
|
|
4872
5426
|
type: "object",
|
|
4873
5427
|
properties: {
|
|
4874
5428
|
query: {
|
|
@@ -4897,17 +5451,17 @@ var outputSchema9 = {
|
|
|
4897
5451
|
additionalProperties: false
|
|
4898
5452
|
};
|
|
4899
5453
|
|
|
4900
|
-
class QueryExpanderTask extends
|
|
5454
|
+
class QueryExpanderTask extends Task12 {
|
|
4901
5455
|
static type = "QueryExpanderTask";
|
|
4902
5456
|
static category = "RAG";
|
|
4903
5457
|
static title = "Query Expander";
|
|
4904
5458
|
static description = "Expand queries to improve retrieval coverage";
|
|
4905
5459
|
static cacheable = true;
|
|
4906
5460
|
static inputSchema() {
|
|
4907
|
-
return
|
|
5461
|
+
return inputSchema10;
|
|
4908
5462
|
}
|
|
4909
5463
|
static outputSchema() {
|
|
4910
|
-
return
|
|
5464
|
+
return outputSchema10;
|
|
4911
5465
|
}
|
|
4912
5466
|
async execute(input, context) {
|
|
4913
5467
|
const { query, method = QueryExpansionMethod.MULTI_QUERY, numVariations = 3 } = input;
|
|
@@ -5006,11 +5560,11 @@ class QueryExpanderTask extends Task11 {
|
|
|
5006
5560
|
var queryExpander = (input, config) => {
|
|
5007
5561
|
return new QueryExpanderTask(config).run(input);
|
|
5008
5562
|
};
|
|
5009
|
-
|
|
5563
|
+
Workflow30.prototype.queryExpander = CreateWorkflow30(QueryExpanderTask);
|
|
5010
5564
|
|
|
5011
5565
|
// src/task/RerankerTask.ts
|
|
5012
|
-
import { CreateWorkflow as
|
|
5013
|
-
var
|
|
5566
|
+
import { CreateWorkflow as CreateWorkflow31, Task as Task13, Workflow as Workflow31 } from "@workglow/task-graph";
|
|
5567
|
+
var inputSchema11 = {
|
|
5014
5568
|
type: "object",
|
|
5015
5569
|
properties: {
|
|
5016
5570
|
query: {
|
|
@@ -5057,7 +5611,7 @@ var inputSchema10 = {
|
|
|
5057
5611
|
required: ["query", "chunks"],
|
|
5058
5612
|
additionalProperties: false
|
|
5059
5613
|
};
|
|
5060
|
-
var
|
|
5614
|
+
var outputSchema11 = {
|
|
5061
5615
|
type: "object",
|
|
5062
5616
|
properties: {
|
|
5063
5617
|
chunks: {
|
|
@@ -5098,17 +5652,17 @@ var outputSchema10 = {
|
|
|
5098
5652
|
additionalProperties: false
|
|
5099
5653
|
};
|
|
5100
5654
|
|
|
5101
|
-
class RerankerTask extends
|
|
5655
|
+
class RerankerTask extends Task13 {
|
|
5102
5656
|
static type = "RerankerTask";
|
|
5103
5657
|
static category = "RAG";
|
|
5104
5658
|
static title = "Reranker";
|
|
5105
5659
|
static description = "Rerank retrieved chunks to improve relevance";
|
|
5106
5660
|
static cacheable = true;
|
|
5107
5661
|
static inputSchema() {
|
|
5108
|
-
return
|
|
5662
|
+
return inputSchema11;
|
|
5109
5663
|
}
|
|
5110
5664
|
static outputSchema() {
|
|
5111
|
-
return
|
|
5665
|
+
return outputSchema11;
|
|
5112
5666
|
}
|
|
5113
5667
|
async execute(input, context) {
|
|
5114
5668
|
const { query, chunks, scores = [], metadata = [], topK, method = "simple" } = input;
|
|
@@ -5171,13 +5725,13 @@ class RerankerTask extends Task12 {
|
|
|
5171
5725
|
var reranker = (input, config) => {
|
|
5172
5726
|
return new RerankerTask(config).run(input);
|
|
5173
5727
|
};
|
|
5174
|
-
|
|
5728
|
+
Workflow31.prototype.reranker = CreateWorkflow31(RerankerTask);
|
|
5175
5729
|
|
|
5176
5730
|
// src/task/StructuralParserTask.ts
|
|
5177
5731
|
import { StructuralParser } from "@workglow/knowledge-base";
|
|
5178
|
-
import { CreateWorkflow as
|
|
5732
|
+
import { CreateWorkflow as CreateWorkflow32, Task as Task14, Workflow as Workflow32 } from "@workglow/task-graph";
|
|
5179
5733
|
import { uuid4 as uuid42 } from "@workglow/util";
|
|
5180
|
-
var
|
|
5734
|
+
var inputSchema12 = {
|
|
5181
5735
|
type: "object",
|
|
5182
5736
|
properties: {
|
|
5183
5737
|
text: {
|
|
@@ -5211,7 +5765,7 @@ var inputSchema11 = {
|
|
|
5211
5765
|
required: ["text", "title"],
|
|
5212
5766
|
additionalProperties: false
|
|
5213
5767
|
};
|
|
5214
|
-
var
|
|
5768
|
+
var outputSchema12 = {
|
|
5215
5769
|
type: "object",
|
|
5216
5770
|
properties: {
|
|
5217
5771
|
doc_id: {
|
|
@@ -5235,17 +5789,17 @@ var outputSchema11 = {
|
|
|
5235
5789
|
additionalProperties: false
|
|
5236
5790
|
};
|
|
5237
5791
|
|
|
5238
|
-
class StructuralParserTask extends
|
|
5792
|
+
class StructuralParserTask extends Task14 {
|
|
5239
5793
|
static type = "StructuralParserTask";
|
|
5240
5794
|
static category = "Document";
|
|
5241
5795
|
static title = "Structural Parser";
|
|
5242
5796
|
static description = "Parse documents into hierarchical tree structure";
|
|
5243
5797
|
static cacheable = true;
|
|
5244
5798
|
static inputSchema() {
|
|
5245
|
-
return
|
|
5799
|
+
return inputSchema12;
|
|
5246
5800
|
}
|
|
5247
5801
|
static outputSchema() {
|
|
5248
|
-
return
|
|
5802
|
+
return outputSchema12;
|
|
5249
5803
|
}
|
|
5250
5804
|
async execute(input, context) {
|
|
5251
5805
|
const { text, title, format = "auto", sourceUri, doc_id: providedDocId } = input;
|
|
@@ -5278,16 +5832,16 @@ class StructuralParserTask extends Task13 {
|
|
|
5278
5832
|
var structuralParser = (input, config) => {
|
|
5279
5833
|
return new StructuralParserTask(config).run(input);
|
|
5280
5834
|
};
|
|
5281
|
-
|
|
5835
|
+
Workflow32.prototype.structuralParser = CreateWorkflow32(StructuralParserTask);
|
|
5282
5836
|
|
|
5283
5837
|
// src/task/StructuredGenerationTask.ts
|
|
5284
|
-
import { CreateWorkflow as
|
|
5838
|
+
import { CreateWorkflow as CreateWorkflow33, TaskConfigurationError as TaskConfigurationError4, TaskError, Workflow as Workflow33 } from "@workglow/task-graph";
|
|
5285
5839
|
import { compileSchema as compileSchema2 } from "@workglow/util/schema";
|
|
5286
|
-
var
|
|
5840
|
+
var modelSchema24 = TypeModel("model:StructuredGenerationTask");
|
|
5287
5841
|
var StructuredGenerationInputSchema = {
|
|
5288
5842
|
type: "object",
|
|
5289
5843
|
properties: {
|
|
5290
|
-
model:
|
|
5844
|
+
model: modelSchema24,
|
|
5291
5845
|
prompt: {
|
|
5292
5846
|
type: "string",
|
|
5293
5847
|
title: "Prompt",
|
|
@@ -5456,18 +6010,18 @@ class StructuredGenerationTask extends StreamingAiTask {
|
|
|
5456
6010
|
var structuredGeneration = (input, config) => {
|
|
5457
6011
|
return new StructuredGenerationTask(config).run(input);
|
|
5458
6012
|
};
|
|
5459
|
-
|
|
6013
|
+
Workflow33.prototype.structuredGeneration = CreateWorkflow33(StructuredGenerationTask);
|
|
5460
6014
|
|
|
5461
6015
|
// src/task/TextChunkerTask.ts
|
|
5462
6016
|
import { ChunkRecordArraySchema as ChunkRecordArraySchema3 } from "@workglow/knowledge-base";
|
|
5463
|
-
import { CreateWorkflow as
|
|
6017
|
+
import { CreateWorkflow as CreateWorkflow34, Task as Task15, Workflow as Workflow34 } from "@workglow/task-graph";
|
|
5464
6018
|
var ChunkingStrategy = {
|
|
5465
6019
|
FIXED: "fixed",
|
|
5466
6020
|
SENTENCE: "sentence",
|
|
5467
6021
|
PARAGRAPH: "paragraph",
|
|
5468
6022
|
SEMANTIC: "semantic"
|
|
5469
6023
|
};
|
|
5470
|
-
var
|
|
6024
|
+
var inputSchema13 = {
|
|
5471
6025
|
type: "object",
|
|
5472
6026
|
properties: {
|
|
5473
6027
|
text: {
|
|
@@ -5505,7 +6059,7 @@ var inputSchema12 = {
|
|
|
5505
6059
|
required: ["text"],
|
|
5506
6060
|
additionalProperties: false
|
|
5507
6061
|
};
|
|
5508
|
-
var
|
|
6062
|
+
var outputSchema13 = {
|
|
5509
6063
|
type: "object",
|
|
5510
6064
|
properties: {
|
|
5511
6065
|
doc_id: {
|
|
@@ -5530,17 +6084,17 @@ var outputSchema12 = {
|
|
|
5530
6084
|
additionalProperties: false
|
|
5531
6085
|
};
|
|
5532
6086
|
|
|
5533
|
-
class TextChunkerTask extends
|
|
6087
|
+
class TextChunkerTask extends Task15 {
|
|
5534
6088
|
static type = "TextChunkerTask";
|
|
5535
6089
|
static category = "Document";
|
|
5536
6090
|
static title = "Text Chunker";
|
|
5537
6091
|
static description = "Splits text into chunks using various strategies (fixed, sentence, paragraph)";
|
|
5538
6092
|
static cacheable = true;
|
|
5539
6093
|
static inputSchema() {
|
|
5540
|
-
return
|
|
6094
|
+
return inputSchema13;
|
|
5541
6095
|
}
|
|
5542
6096
|
static outputSchema() {
|
|
5543
|
-
return
|
|
6097
|
+
return outputSchema13;
|
|
5544
6098
|
}
|
|
5545
6099
|
async execute(input, context) {
|
|
5546
6100
|
const {
|
|
@@ -5710,11 +6264,11 @@ class TextChunkerTask extends Task14 {
|
|
|
5710
6264
|
var textChunker = (input, config) => {
|
|
5711
6265
|
return new TextChunkerTask(config).run(input);
|
|
5712
6266
|
};
|
|
5713
|
-
|
|
6267
|
+
Workflow34.prototype.textChunker = CreateWorkflow34(TextChunkerTask);
|
|
5714
6268
|
|
|
5715
6269
|
// src/task/TextClassificationTask.ts
|
|
5716
|
-
import { CreateWorkflow as
|
|
5717
|
-
var
|
|
6270
|
+
import { CreateWorkflow as CreateWorkflow35, Workflow as Workflow35 } from "@workglow/task-graph";
|
|
6271
|
+
var modelSchema25 = TypeModel("model:TextClassificationTask");
|
|
5718
6272
|
var TextClassificationInputSchema = {
|
|
5719
6273
|
type: "object",
|
|
5720
6274
|
properties: {
|
|
@@ -5741,7 +6295,7 @@ var TextClassificationInputSchema = {
|
|
|
5741
6295
|
description: "The maximum number of categories to return",
|
|
5742
6296
|
"x-ui-group": "Configuration"
|
|
5743
6297
|
},
|
|
5744
|
-
model:
|
|
6298
|
+
model: modelSchema25
|
|
5745
6299
|
},
|
|
5746
6300
|
required: ["text", "model"],
|
|
5747
6301
|
additionalProperties: false
|
|
@@ -5791,11 +6345,11 @@ class TextClassificationTask extends AiTask {
|
|
|
5791
6345
|
var textClassification = (input, config) => {
|
|
5792
6346
|
return new TextClassificationTask(config).run(input);
|
|
5793
6347
|
};
|
|
5794
|
-
|
|
6348
|
+
Workflow35.prototype.textClassification = CreateWorkflow35(TextClassificationTask);
|
|
5795
6349
|
|
|
5796
6350
|
// src/task/TextFillMaskTask.ts
|
|
5797
|
-
import { CreateWorkflow as
|
|
5798
|
-
var
|
|
6351
|
+
import { CreateWorkflow as CreateWorkflow36, Workflow as Workflow36 } from "@workglow/task-graph";
|
|
6352
|
+
var modelSchema26 = TypeModel("model:TextFillMaskTask");
|
|
5799
6353
|
var TextFillMaskInputSchema = {
|
|
5800
6354
|
type: "object",
|
|
5801
6355
|
properties: {
|
|
@@ -5804,7 +6358,7 @@ var TextFillMaskInputSchema = {
|
|
|
5804
6358
|
title: "Text",
|
|
5805
6359
|
description: "The text with a mask token to fill"
|
|
5806
6360
|
},
|
|
5807
|
-
model:
|
|
6361
|
+
model: modelSchema26
|
|
5808
6362
|
},
|
|
5809
6363
|
required: ["text", "model"],
|
|
5810
6364
|
additionalProperties: false
|
|
@@ -5859,21 +6413,21 @@ class TextFillMaskTask extends AiTask {
|
|
|
5859
6413
|
var textFillMask = (input, config) => {
|
|
5860
6414
|
return new TextFillMaskTask(config).run(input);
|
|
5861
6415
|
};
|
|
5862
|
-
|
|
6416
|
+
Workflow36.prototype.textFillMask = CreateWorkflow36(TextFillMaskTask);
|
|
5863
6417
|
|
|
5864
6418
|
// src/task/TextGenerationTask.ts
|
|
5865
|
-
import { CreateWorkflow as
|
|
6419
|
+
import { CreateWorkflow as CreateWorkflow37, Workflow as Workflow37 } from "@workglow/task-graph";
|
|
5866
6420
|
var generatedTextSchema2 = {
|
|
5867
6421
|
type: "string",
|
|
5868
6422
|
title: "Text",
|
|
5869
6423
|
description: "The generated text",
|
|
5870
6424
|
"x-stream": "append"
|
|
5871
6425
|
};
|
|
5872
|
-
var
|
|
6426
|
+
var modelSchema27 = TypeModel("model:TextGenerationTask");
|
|
5873
6427
|
var TextGenerationInputSchema = {
|
|
5874
6428
|
type: "object",
|
|
5875
6429
|
properties: {
|
|
5876
|
-
model:
|
|
6430
|
+
model: modelSchema27,
|
|
5877
6431
|
prompt: {
|
|
5878
6432
|
type: "string",
|
|
5879
6433
|
title: "Prompt",
|
|
@@ -5948,11 +6502,11 @@ class TextGenerationTask extends StreamingAiTask {
|
|
|
5948
6502
|
var textGeneration = (input, config) => {
|
|
5949
6503
|
return new TextGenerationTask(config).run(input);
|
|
5950
6504
|
};
|
|
5951
|
-
|
|
6505
|
+
Workflow37.prototype.textGeneration = CreateWorkflow37(TextGenerationTask);
|
|
5952
6506
|
|
|
5953
6507
|
// src/task/TextLanguageDetectionTask.ts
|
|
5954
|
-
import { CreateWorkflow as
|
|
5955
|
-
var
|
|
6508
|
+
import { CreateWorkflow as CreateWorkflow38, Workflow as Workflow38 } from "@workglow/task-graph";
|
|
6509
|
+
var modelSchema28 = TypeModel("model:TextLanguageDetectionTask");
|
|
5956
6510
|
var TextLanguageDetectionInputSchema = {
|
|
5957
6511
|
type: "object",
|
|
5958
6512
|
properties: {
|
|
@@ -5969,7 +6523,7 @@ var TextLanguageDetectionInputSchema = {
|
|
|
5969
6523
|
title: "Max Languages",
|
|
5970
6524
|
description: "The maximum number of languages to return"
|
|
5971
6525
|
},
|
|
5972
|
-
model:
|
|
6526
|
+
model: modelSchema28
|
|
5973
6527
|
},
|
|
5974
6528
|
required: ["text", "model"],
|
|
5975
6529
|
additionalProperties: false
|
|
@@ -6019,10 +6573,10 @@ class TextLanguageDetectionTask extends AiTask {
|
|
|
6019
6573
|
var textLanguageDetection = (input, config) => {
|
|
6020
6574
|
return new TextLanguageDetectionTask(config).run(input);
|
|
6021
6575
|
};
|
|
6022
|
-
|
|
6576
|
+
Workflow38.prototype.textLanguageDetection = CreateWorkflow38(TextLanguageDetectionTask);
|
|
6023
6577
|
|
|
6024
6578
|
// src/task/TextQuestionAnswerTask.ts
|
|
6025
|
-
import { CreateWorkflow as
|
|
6579
|
+
import { CreateWorkflow as CreateWorkflow39, Workflow as Workflow39 } from "@workglow/task-graph";
|
|
6026
6580
|
var contextSchema = {
|
|
6027
6581
|
type: "string",
|
|
6028
6582
|
title: "Context",
|
|
@@ -6039,13 +6593,13 @@ var textSchema = {
|
|
|
6039
6593
|
description: "The generated text",
|
|
6040
6594
|
"x-stream": "append"
|
|
6041
6595
|
};
|
|
6042
|
-
var
|
|
6596
|
+
var modelSchema29 = TypeModel("model:TextQuestionAnswerTask");
|
|
6043
6597
|
var TextQuestionAnswerInputSchema = {
|
|
6044
6598
|
type: "object",
|
|
6045
6599
|
properties: {
|
|
6046
6600
|
context: contextSchema,
|
|
6047
6601
|
question: questionSchema,
|
|
6048
|
-
model:
|
|
6602
|
+
model: modelSchema29
|
|
6049
6603
|
},
|
|
6050
6604
|
required: ["context", "question", "model"],
|
|
6051
6605
|
additionalProperties: false
|
|
@@ -6075,11 +6629,11 @@ class TextQuestionAnswerTask extends StreamingAiTask {
|
|
|
6075
6629
|
var textQuestionAnswer = (input, config) => {
|
|
6076
6630
|
return new TextQuestionAnswerTask(config).run(input);
|
|
6077
6631
|
};
|
|
6078
|
-
|
|
6632
|
+
Workflow39.prototype.textQuestionAnswer = CreateWorkflow39(TextQuestionAnswerTask);
|
|
6079
6633
|
|
|
6080
6634
|
// src/task/TextRewriterTask.ts
|
|
6081
|
-
import { CreateWorkflow as
|
|
6082
|
-
var
|
|
6635
|
+
import { CreateWorkflow as CreateWorkflow40, Workflow as Workflow40 } from "@workglow/task-graph";
|
|
6636
|
+
var modelSchema30 = TypeModel("model:TextRewriterTask");
|
|
6083
6637
|
var TextRewriterInputSchema = {
|
|
6084
6638
|
type: "object",
|
|
6085
6639
|
properties: {
|
|
@@ -6093,7 +6647,7 @@ var TextRewriterInputSchema = {
|
|
|
6093
6647
|
title: "Prompt",
|
|
6094
6648
|
description: "The prompt to direct the rewriting"
|
|
6095
6649
|
},
|
|
6096
|
-
model:
|
|
6650
|
+
model: modelSchema30
|
|
6097
6651
|
},
|
|
6098
6652
|
required: ["text", "prompt", "model"],
|
|
6099
6653
|
additionalProperties: false
|
|
@@ -6128,11 +6682,11 @@ class TextRewriterTask extends StreamingAiTask {
|
|
|
6128
6682
|
var textRewriter = (input, config) => {
|
|
6129
6683
|
return new TextRewriterTask(config).run(input);
|
|
6130
6684
|
};
|
|
6131
|
-
|
|
6685
|
+
Workflow40.prototype.textRewriter = CreateWorkflow40(TextRewriterTask);
|
|
6132
6686
|
|
|
6133
6687
|
// src/task/TextTranslationTask.ts
|
|
6134
|
-
import { CreateWorkflow as
|
|
6135
|
-
var
|
|
6688
|
+
import { CreateWorkflow as CreateWorkflow41, Workflow as Workflow41 } from "@workglow/task-graph";
|
|
6689
|
+
var modelSchema31 = TypeModel("model:TextTranslationTask");
|
|
6136
6690
|
var translationTextSchema = {
|
|
6137
6691
|
type: "string",
|
|
6138
6692
|
title: "Text",
|
|
@@ -6159,7 +6713,7 @@ var TextTranslationInputSchema = {
|
|
|
6159
6713
|
minLength: 2,
|
|
6160
6714
|
maxLength: 2
|
|
6161
6715
|
}),
|
|
6162
|
-
model:
|
|
6716
|
+
model: modelSchema31
|
|
6163
6717
|
},
|
|
6164
6718
|
required: ["text", "source_lang", "target_lang", "model"],
|
|
6165
6719
|
additionalProperties: false
|
|
@@ -6195,10 +6749,10 @@ class TextTranslationTask extends StreamingAiTask {
|
|
|
6195
6749
|
var textTranslation = (input, config) => {
|
|
6196
6750
|
return new TextTranslationTask(config).run(input);
|
|
6197
6751
|
};
|
|
6198
|
-
|
|
6752
|
+
Workflow41.prototype.textTranslation = CreateWorkflow41(TextTranslationTask);
|
|
6199
6753
|
|
|
6200
6754
|
// src/task/ToolCallingTask.ts
|
|
6201
|
-
import { CreateWorkflow as
|
|
6755
|
+
import { CreateWorkflow as CreateWorkflow42, getTaskConstructors, Workflow as Workflow42 } from "@workglow/task-graph";
|
|
6202
6756
|
import { makeFingerprint } from "@workglow/util";
|
|
6203
6757
|
function taskTypesToTools(taskNames, registry) {
|
|
6204
6758
|
const constructors = getTaskConstructors(registry);
|
|
@@ -6282,11 +6836,11 @@ var ToolCallSchema = {
|
|
|
6282
6836
|
required: ["id", "name", "input"],
|
|
6283
6837
|
additionalProperties: false
|
|
6284
6838
|
};
|
|
6285
|
-
var
|
|
6839
|
+
var modelSchema32 = TypeModel("model:ToolCallingTask");
|
|
6286
6840
|
var ToolCallingInputSchema = {
|
|
6287
6841
|
type: "object",
|
|
6288
6842
|
properties: {
|
|
6289
|
-
model:
|
|
6843
|
+
model: modelSchema32,
|
|
6290
6844
|
prompt: {
|
|
6291
6845
|
oneOf: [
|
|
6292
6846
|
{ type: "string", title: "Prompt", description: "The prompt to send to the model" },
|
|
@@ -6431,16 +6985,16 @@ class ToolCallingTask extends StreamingAiTask {
|
|
|
6431
6985
|
var toolCalling = (input, config) => {
|
|
6432
6986
|
return new ToolCallingTask(config).run(input);
|
|
6433
6987
|
};
|
|
6434
|
-
|
|
6988
|
+
Workflow42.prototype.toolCalling = CreateWorkflow42(ToolCallingTask);
|
|
6435
6989
|
|
|
6436
6990
|
// src/task/TopicSegmenterTask.ts
|
|
6437
|
-
import { CreateWorkflow as
|
|
6991
|
+
import { CreateWorkflow as CreateWorkflow43, Task as Task16, Workflow as Workflow43 } from "@workglow/task-graph";
|
|
6438
6992
|
var SegmentationMethod = {
|
|
6439
6993
|
HEURISTIC: "heuristic",
|
|
6440
6994
|
EMBEDDING_SIMILARITY: "embedding-similarity",
|
|
6441
6995
|
HYBRID: "hybrid"
|
|
6442
6996
|
};
|
|
6443
|
-
var
|
|
6997
|
+
var inputSchema14 = {
|
|
6444
6998
|
type: "object",
|
|
6445
6999
|
properties: {
|
|
6446
7000
|
text: {
|
|
@@ -6481,7 +7035,7 @@ var inputSchema13 = {
|
|
|
6481
7035
|
required: ["text"],
|
|
6482
7036
|
additionalProperties: false
|
|
6483
7037
|
};
|
|
6484
|
-
var
|
|
7038
|
+
var outputSchema14 = {
|
|
6485
7039
|
type: "object",
|
|
6486
7040
|
properties: {
|
|
6487
7041
|
segments: {
|
|
@@ -6509,7 +7063,7 @@ var outputSchema13 = {
|
|
|
6509
7063
|
additionalProperties: false
|
|
6510
7064
|
};
|
|
6511
7065
|
|
|
6512
|
-
class TopicSegmenterTask extends
|
|
7066
|
+
class TopicSegmenterTask extends Task16 {
|
|
6513
7067
|
static type = "TopicSegmenterTask";
|
|
6514
7068
|
static category = "Document";
|
|
6515
7069
|
static title = "Topic Segmenter";
|
|
@@ -6517,10 +7071,10 @@ class TopicSegmenterTask extends Task15 {
|
|
|
6517
7071
|
static cacheable = true;
|
|
6518
7072
|
static EMBEDDING_DIMENSIONS = 256;
|
|
6519
7073
|
static inputSchema() {
|
|
6520
|
-
return
|
|
7074
|
+
return inputSchema14;
|
|
6521
7075
|
}
|
|
6522
7076
|
static outputSchema() {
|
|
6523
|
-
return
|
|
7077
|
+
return outputSchema14;
|
|
6524
7078
|
}
|
|
6525
7079
|
async execute(input, context) {
|
|
6526
7080
|
const {
|
|
@@ -6714,15 +7268,15 @@ class TopicSegmenterTask extends Task15 {
|
|
|
6714
7268
|
var topicSegmenter = (input, config) => {
|
|
6715
7269
|
return new TopicSegmenterTask(config).run(input);
|
|
6716
7270
|
};
|
|
6717
|
-
|
|
7271
|
+
Workflow43.prototype.topicSegmenter = CreateWorkflow43(TopicSegmenterTask);
|
|
6718
7272
|
|
|
6719
7273
|
// src/task/UnloadModelTask.ts
|
|
6720
|
-
import { CreateWorkflow as
|
|
6721
|
-
var
|
|
7274
|
+
import { CreateWorkflow as CreateWorkflow44, Workflow as Workflow44 } from "@workglow/task-graph";
|
|
7275
|
+
var modelSchema33 = TypeModel("model");
|
|
6722
7276
|
var UnloadModelInputSchema = {
|
|
6723
7277
|
type: "object",
|
|
6724
7278
|
properties: {
|
|
6725
|
-
model:
|
|
7279
|
+
model: modelSchema33
|
|
6726
7280
|
},
|
|
6727
7281
|
required: ["model"],
|
|
6728
7282
|
additionalProperties: false
|
|
@@ -6730,7 +7284,7 @@ var UnloadModelInputSchema = {
|
|
|
6730
7284
|
var UnloadModelOutputSchema = {
|
|
6731
7285
|
type: "object",
|
|
6732
7286
|
properties: {
|
|
6733
|
-
model:
|
|
7287
|
+
model: modelSchema33
|
|
6734
7288
|
},
|
|
6735
7289
|
required: ["model"],
|
|
6736
7290
|
additionalProperties: false
|
|
@@ -6752,16 +7306,16 @@ class UnloadModelTask extends AiTask {
|
|
|
6752
7306
|
var unloadModel = (input, config) => {
|
|
6753
7307
|
return new UnloadModelTask(config).run(input);
|
|
6754
7308
|
};
|
|
6755
|
-
|
|
7309
|
+
Workflow44.prototype.unloadModel = CreateWorkflow44(UnloadModelTask);
|
|
6756
7310
|
|
|
6757
7311
|
// src/task/VectorQuantizeTask.ts
|
|
6758
|
-
import { CreateWorkflow as
|
|
7312
|
+
import { CreateWorkflow as CreateWorkflow45, Task as Task17, Workflow as Workflow45 } from "@workglow/task-graph";
|
|
6759
7313
|
import {
|
|
6760
7314
|
normalizeNumberArray,
|
|
6761
7315
|
TensorType,
|
|
6762
7316
|
TypedArraySchema as TypedArraySchema5
|
|
6763
7317
|
} from "@workglow/util/schema";
|
|
6764
|
-
var
|
|
7318
|
+
var inputSchema15 = {
|
|
6765
7319
|
type: "object",
|
|
6766
7320
|
properties: {
|
|
6767
7321
|
vector: {
|
|
@@ -6798,7 +7352,7 @@ var inputSchema14 = {
|
|
|
6798
7352
|
required: ["vector", "targetType"],
|
|
6799
7353
|
additionalProperties: false
|
|
6800
7354
|
};
|
|
6801
|
-
var
|
|
7355
|
+
var outputSchema15 = {
|
|
6802
7356
|
type: "object",
|
|
6803
7357
|
properties: {
|
|
6804
7358
|
vector: {
|
|
@@ -6835,17 +7389,17 @@ var outputSchema14 = {
|
|
|
6835
7389
|
additionalProperties: false
|
|
6836
7390
|
};
|
|
6837
7391
|
|
|
6838
|
-
class VectorQuantizeTask extends
|
|
7392
|
+
class VectorQuantizeTask extends Task17 {
|
|
6839
7393
|
static type = "VectorQuantizeTask";
|
|
6840
7394
|
static category = "Vector";
|
|
6841
7395
|
static title = "Quantize";
|
|
6842
7396
|
static description = "Quantize vectors to reduce storage and improve performance";
|
|
6843
7397
|
static cacheable = true;
|
|
6844
7398
|
static inputSchema() {
|
|
6845
|
-
return
|
|
7399
|
+
return inputSchema15;
|
|
6846
7400
|
}
|
|
6847
7401
|
static outputSchema() {
|
|
6848
|
-
return
|
|
7402
|
+
return outputSchema15;
|
|
6849
7403
|
}
|
|
6850
7404
|
async execute(input) {
|
|
6851
7405
|
return this.executePreview(input);
|
|
@@ -6938,10 +7492,10 @@ class VectorQuantizeTask extends Task16 {
|
|
|
6938
7492
|
var vectorQuantize = (input, config) => {
|
|
6939
7493
|
return new VectorQuantizeTask(config).run(input);
|
|
6940
7494
|
};
|
|
6941
|
-
|
|
7495
|
+
Workflow45.prototype.vectorQuantize = CreateWorkflow45(VectorQuantizeTask);
|
|
6942
7496
|
|
|
6943
7497
|
// src/task/VectorSimilarityTask.ts
|
|
6944
|
-
import { CreateWorkflow as
|
|
7498
|
+
import { CreateWorkflow as CreateWorkflow46, GraphAsTask, Workflow as Workflow46 } from "@workglow/task-graph";
|
|
6945
7499
|
import {
|
|
6946
7500
|
cosineSimilarity,
|
|
6947
7501
|
hammingSimilarity,
|
|
@@ -7055,7 +7609,7 @@ class VectorSimilarityTask extends GraphAsTask {
|
|
|
7055
7609
|
var similarity = (input, config) => {
|
|
7056
7610
|
return new VectorSimilarityTask(config).run(input);
|
|
7057
7611
|
};
|
|
7058
|
-
|
|
7612
|
+
Workflow46.prototype.similarity = CreateWorkflow46(VectorSimilarityTask);
|
|
7059
7613
|
// src/task/MessageConversion.ts
|
|
7060
7614
|
function getInputMessages(input) {
|
|
7061
7615
|
const messages = input.messages;
|
|
@@ -7208,6 +7762,7 @@ function toTextFlatMessages(input) {
|
|
|
7208
7762
|
var registerAiTasks = () => {
|
|
7209
7763
|
const tasks = [
|
|
7210
7764
|
AiChatTask,
|
|
7765
|
+
AiChatWithKbTask,
|
|
7211
7766
|
BackgroundRemovalTask,
|
|
7212
7767
|
CountTokensTask,
|
|
7213
7768
|
ContextBuilderTask,
|
|
@@ -7224,6 +7779,7 @@ var registerAiTasks = () => {
|
|
|
7224
7779
|
HandLandmarkerTask,
|
|
7225
7780
|
HierarchicalChunkerTask,
|
|
7226
7781
|
HierarchyJoinTask,
|
|
7782
|
+
KbSearchTask,
|
|
7227
7783
|
KbToDocumentsTask,
|
|
7228
7784
|
ImageClassificationTask,
|
|
7229
7785
|
ImageEmbeddingTask,
|
|
@@ -7293,6 +7849,7 @@ export {
|
|
|
7293
7849
|
modelSearch,
|
|
7294
7850
|
modelInfo,
|
|
7295
7851
|
kbToDocuments,
|
|
7852
|
+
kbSearch,
|
|
7296
7853
|
isContentBlockInToolResultBody,
|
|
7297
7854
|
isContentBlock,
|
|
7298
7855
|
isChatMessage,
|
|
@@ -7321,6 +7878,7 @@ export {
|
|
|
7321
7878
|
chunkVectorUpsert,
|
|
7322
7879
|
chunkRetrieval,
|
|
7323
7880
|
buildToolDescription,
|
|
7881
|
+
buildResponseFormatAddendum,
|
|
7324
7882
|
backgroundRemoval,
|
|
7325
7883
|
VectorSimilarityTask,
|
|
7326
7884
|
VectorQuantizeTask,
|
|
@@ -7400,6 +7958,8 @@ export {
|
|
|
7400
7958
|
ModelConfigSchema,
|
|
7401
7959
|
MODEL_REPOSITORY,
|
|
7402
7960
|
KbToDocumentsTask,
|
|
7961
|
+
KbSearchTask,
|
|
7962
|
+
KB_INLINE_CITATION_DIRECTIVE,
|
|
7403
7963
|
InMemoryModelRepository,
|
|
7404
7964
|
ImageToTextTask,
|
|
7405
7965
|
ImageToTextOutputSchema,
|
|
@@ -7458,10 +8018,13 @@ export {
|
|
|
7458
8018
|
AiProvider,
|
|
7459
8019
|
AiJob,
|
|
7460
8020
|
AiImageOutputTask,
|
|
8021
|
+
AiChatWithKbTask,
|
|
8022
|
+
AiChatWithKbOutputSchema,
|
|
8023
|
+
AiChatWithKbInputSchema,
|
|
7461
8024
|
AiChatTask,
|
|
7462
8025
|
AiChatOutputSchema,
|
|
7463
8026
|
AiChatInputSchema,
|
|
7464
8027
|
AI_PROVIDER_REGISTRY
|
|
7465
8028
|
};
|
|
7466
8029
|
|
|
7467
|
-
//# debugId=
|
|
8030
|
+
//# debugId=CA7309C15AE94A6564756E2164756E21
|