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