graphai 0.2.1 → 0.2.2
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/graphai.d.ts +1 -0
- package/lib/graphai.js +8 -5
- package/lib/node.js +1 -1
- package/lib/type.d.ts +1 -0
- package/lib/validators/common.js +1 -1
- package/lib/validators/relation_validator.js +3 -3
- package/package.json +1 -1
package/lib/graphai.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export declare class GraphAI {
|
|
|
12
12
|
private readonly logs;
|
|
13
13
|
readonly callbackDictonary: AgentFunctionDictonary;
|
|
14
14
|
readonly taskManager: TaskManager;
|
|
15
|
+
readonly retryLimit?: number;
|
|
15
16
|
nodes: GraphNodes;
|
|
16
17
|
onLogCallback: (__log: TransactionLog, __isUpdate: boolean) => void;
|
|
17
18
|
verbose: boolean;
|
package/lib/graphai.js
CHANGED
|
@@ -12,14 +12,16 @@ class GraphAI {
|
|
|
12
12
|
// or we are about to start n-th iteration (n>2).
|
|
13
13
|
createNodes(data) {
|
|
14
14
|
const nodes = Object.keys(data.nodes).reduce((_nodes, nodeId) => {
|
|
15
|
-
const
|
|
16
|
-
if (
|
|
17
|
-
_nodes[nodeId] = new node_1.StaticNode(nodeId,
|
|
15
|
+
const nodeData = data.nodes[nodeId];
|
|
16
|
+
if ("value" in nodeData) {
|
|
17
|
+
_nodes[nodeId] = new node_1.StaticNode(nodeId, nodeData, this);
|
|
18
18
|
}
|
|
19
|
-
else {
|
|
20
|
-
const nodeData = data.nodes[nodeId];
|
|
19
|
+
else if ("agentId" in nodeData) {
|
|
21
20
|
_nodes[nodeId] = new node_1.ComputedNode(this.graphId, nodeId, nodeData, this);
|
|
22
21
|
}
|
|
22
|
+
else {
|
|
23
|
+
throw new Error("Unknown node: " + nodeId);
|
|
24
|
+
}
|
|
23
25
|
return _nodes;
|
|
24
26
|
}, {});
|
|
25
27
|
// Generate the waitlist for each node.
|
|
@@ -72,6 +74,7 @@ class GraphAI {
|
|
|
72
74
|
console.log("------------ no version");
|
|
73
75
|
}
|
|
74
76
|
this.version = data.version ?? 0.2;
|
|
77
|
+
this.retryLimit = data.retry; // optional
|
|
75
78
|
this.graphId = URL.createObjectURL(new Blob()).slice(-36);
|
|
76
79
|
this.data = data;
|
|
77
80
|
this.callbackDictonary = callbackDictonary;
|
package/lib/node.js
CHANGED
|
@@ -40,7 +40,7 @@ class ComputedNode extends Node {
|
|
|
40
40
|
this.params = data.params ?? {};
|
|
41
41
|
this.nestedGraph = data.graph;
|
|
42
42
|
this.agentId = data.agentId;
|
|
43
|
-
this.retryLimit = data.retry ?? 0;
|
|
43
|
+
this.retryLimit = data.retry ?? graph.retryLimit ?? 0;
|
|
44
44
|
this.timeout = data.timeout;
|
|
45
45
|
this.isResult = data.isResult ?? false;
|
|
46
46
|
this.anyInput = data.anyInput ?? false;
|
package/lib/type.d.ts
CHANGED
package/lib/validators/common.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.staticNodeAttributeKeys = exports.computedNodeAttributeKeys = exports.graphDataAttributeKeys = void 0;
|
|
4
|
-
exports.graphDataAttributeKeys = ["nodes", "concurrency", "agentId", "loop", "verbose"];
|
|
4
|
+
exports.graphDataAttributeKeys = ["nodes", "concurrency", "agentId", "loop", "verbose", "version"];
|
|
5
5
|
exports.computedNodeAttributeKeys = ["inputs", "anyInput", "params", "retry", "timeout", "agentId", "graph", "isResult"];
|
|
6
6
|
exports.staticNodeAttributeKeys = ["value", "update", "isResult"];
|
|
@@ -10,7 +10,7 @@ const relationValidator = (data, staticNodeIds, computedNodeIds) => {
|
|
|
10
10
|
computedNodeIds.forEach((computedNodeId) => {
|
|
11
11
|
const nodeData = data.nodes[computedNodeId];
|
|
12
12
|
pendings[computedNodeId] = new Set();
|
|
13
|
-
if (nodeData.inputs) {
|
|
13
|
+
if ("inputs" in nodeData && nodeData && nodeData.inputs) {
|
|
14
14
|
nodeData.inputs.forEach((inputNodeId) => {
|
|
15
15
|
const sourceNodeId = (0, utils_1.parseNodeName)(inputNodeId).nodeId;
|
|
16
16
|
if (sourceNodeId) {
|
|
@@ -27,8 +27,8 @@ const relationValidator = (data, staticNodeIds, computedNodeIds) => {
|
|
|
27
27
|
// TODO. validate update
|
|
28
28
|
staticNodeIds.forEach((staticNodeId) => {
|
|
29
29
|
const nodeData = data.nodes[staticNodeId];
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
if ("value" in nodeData && nodeData.update) {
|
|
31
|
+
const update = nodeData.update;
|
|
32
32
|
const updateNodeId = (0, utils_1.parseNodeName)(update).nodeId;
|
|
33
33
|
if (!updateNodeId) {
|
|
34
34
|
throw new Error("Update it a literal");
|