graphai 2.0.8 → 2.0.10
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/lib/bundle.cjs.js +1 -1
- package/lib/bundle.cjs.js.map +1 -1
- package/lib/bundle.esm.js +28 -3
- package/lib/bundle.esm.js.map +1 -1
- package/lib/bundle.umd.js +1 -1
- package/lib/bundle.umd.js.map +1 -1
- package/lib/graphai.d.ts +2 -1
- package/lib/graphai.js +7 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +3 -1
- package/lib/utils/prop_function.js +20 -1
- package/package.json +3 -3
package/lib/bundle.esm.js
CHANGED
|
@@ -76,6 +76,18 @@ const propArrayFunction = (result, propId) => {
|
|
|
76
76
|
if (propId === "isEmpty()") {
|
|
77
77
|
return result.length === 0;
|
|
78
78
|
}
|
|
79
|
+
if (propId === "average()" || propId === "mean()") {
|
|
80
|
+
return result.length ? result.reduce((a, b) => a + b, 0) / result.length : 0;
|
|
81
|
+
}
|
|
82
|
+
if (propId === "sum()") {
|
|
83
|
+
return result.reduce((a, b) => a + b, 0);
|
|
84
|
+
}
|
|
85
|
+
if (propId === "max()") {
|
|
86
|
+
return result.length ? Math.max(...result) : 0;
|
|
87
|
+
}
|
|
88
|
+
if (propId === "min()") {
|
|
89
|
+
return result.length ? Math.min(...result) : 0;
|
|
90
|
+
}
|
|
79
91
|
// array join
|
|
80
92
|
const matchJoin = propId.match(/^join\(([,-\s]?)\)$/);
|
|
81
93
|
if (matchJoin && Array.isArray(matchJoin)) {
|
|
@@ -101,10 +113,17 @@ const propObjectFunction = (result, propId) => {
|
|
|
101
113
|
const propStringFunction = (result, propId) => {
|
|
102
114
|
if (typeof result === "string") {
|
|
103
115
|
if (propId === "codeBlock()") {
|
|
104
|
-
const match = ("\n" + result).match(/\n```[a-zA-
|
|
116
|
+
const match = ("\n" + result).match(/\n```[a-zA-Z]*([\s\S]*?)\n```/);
|
|
117
|
+
if (match) {
|
|
118
|
+
return match[1];
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
if (propId === "codeBlockOrRaw()") {
|
|
122
|
+
const match = ("\n" + result).match(/\n```[a-zA-Z]*([\s\S]*?)\n```/);
|
|
105
123
|
if (match) {
|
|
106
124
|
return match[1];
|
|
107
125
|
}
|
|
126
|
+
return result;
|
|
108
127
|
}
|
|
109
128
|
if (propId === "jsonParse()") {
|
|
110
129
|
return JSON.parse(result);
|
|
@@ -1437,7 +1456,8 @@ class GraphAI {
|
|
|
1437
1456
|
async run(all = false) {
|
|
1438
1457
|
this.setStaticNodeResults();
|
|
1439
1458
|
const invalidStaticNodes = Object.values(this.nodes)
|
|
1440
|
-
.filter((node) => node.isStaticNode)
|
|
1459
|
+
.filter((node) => node.isStaticNode)
|
|
1460
|
+
.filter((node) => node.result === undefined && node.update === undefined);
|
|
1441
1461
|
if (invalidStaticNodes.length > 0) {
|
|
1442
1462
|
const nodeIds = invalidStaticNodes.map((node) => node.nodeId).join(", ");
|
|
1443
1463
|
throw new Error(`Static node(s) must have value. Set value, injectValue, or set update. Affected nodeIds: ${nodeIds}`);
|
|
@@ -1568,6 +1588,11 @@ class GraphAI {
|
|
|
1568
1588
|
this.staticNodeInitData[nodeId] = value;
|
|
1569
1589
|
this.updateStaticNodeValue(nodeId, value, injectFrom);
|
|
1570
1590
|
}
|
|
1591
|
+
setLoopCount(count) {
|
|
1592
|
+
this.loop = {
|
|
1593
|
+
count,
|
|
1594
|
+
};
|
|
1595
|
+
}
|
|
1571
1596
|
updateStaticNodeValue(nodeId, value, injectFrom) {
|
|
1572
1597
|
const node = this.nodes[nodeId];
|
|
1573
1598
|
if (node && node.isStaticNode) {
|
|
@@ -1589,5 +1614,5 @@ class GraphAI {
|
|
|
1589
1614
|
}
|
|
1590
1615
|
}
|
|
1591
1616
|
|
|
1592
|
-
export { GraphAI, GraphAILogger, NodeState, ValidationError, agentInfoWrapper, assert, debugResultKey, defaultAgentInfo, defaultConcurrency, defaultTestContext, graphDataLatestVersion, inputs2dataSources, isComputedNodeData, isObject, isStaticNodeData, parseNodeName, sleep, strIntentionalError };
|
|
1617
|
+
export { GraphAI, GraphAILogger, NodeState, TaskManager, ValidationError, agentInfoWrapper, assert, debugResultKey, defaultAgentInfo, defaultConcurrency, defaultTestContext, graphDataLatestVersion, inputs2dataSources, isComputedNodeData, isObject, isStaticNodeData, parseNodeName, sleep, strIntentionalError };
|
|
1593
1618
|
//# sourceMappingURL=bundle.esm.js.map
|