graphai 0.2.2 → 0.2.4
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.js +1 -2
- package/lib/index.d.ts +1 -1
- package/lib/index.js +3 -1
- package/lib/node.d.ts +1 -0
- package/lib/node.js +5 -0
- package/lib/transaction_log.d.ts +1 -0
- package/lib/transaction_log.js +5 -0
- package/lib/type.d.ts +1 -2
- package/lib/type.js +0 -1
- package/package.json +1 -1
package/lib/graphai.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.GraphAI = void 0;
|
|
4
|
-
const type_1 = require("./type");
|
|
5
4
|
const node_1 = require("./node");
|
|
6
5
|
const utils_1 = require("./utils/utils");
|
|
7
6
|
const validator_1 = require("./validator");
|
|
@@ -144,7 +143,7 @@ class GraphAI {
|
|
|
144
143
|
}
|
|
145
144
|
// for computed
|
|
146
145
|
pushQueue(node) {
|
|
147
|
-
node.
|
|
146
|
+
node.beforeAddTask();
|
|
148
147
|
this.taskManager.addTask(node, this.graphId, (_node) => {
|
|
149
148
|
(0, utils_1.assert)(node.nodeId === _node.nodeId, "GraphAI.pushQueue node mismatch");
|
|
150
149
|
node.execute();
|
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { GraphAI } from "./graphai";
|
|
2
2
|
export { GraphAI };
|
|
3
|
-
export { AgentFunction, AgentFunctionDictonary, GraphData, ResultDataDictonary, ResultData } from "./type";
|
|
3
|
+
export { AgentFunction, AgentFunctionDictonary, GraphData, ResultDataDictonary, ResultData, NodeState } from "./type";
|
|
4
4
|
export type { TransactionLog } from "./transaction_log";
|
package/lib/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GraphAI = void 0;
|
|
3
|
+
exports.NodeState = exports.GraphAI = void 0;
|
|
4
4
|
const graphai_1 = require("./graphai");
|
|
5
5
|
Object.defineProperty(exports, "GraphAI", { enumerable: true, get: function () { return graphai_1.GraphAI; } });
|
|
6
|
+
var type_1 = require("./type");
|
|
7
|
+
Object.defineProperty(exports, "NodeState", { enumerable: true, get: function () { return type_1.NodeState; } });
|
package/lib/node.d.ts
CHANGED
package/lib/node.js
CHANGED
|
@@ -87,6 +87,11 @@ class ComputedNode extends Node {
|
|
|
87
87
|
});
|
|
88
88
|
return results.length > 0;
|
|
89
89
|
}
|
|
90
|
+
// This method is called right before the Graph add this node to the task manager.
|
|
91
|
+
beforeAddTask() {
|
|
92
|
+
this.state = type_1.NodeState.Queued;
|
|
93
|
+
this.log.beforeAddTask(this, this.graph);
|
|
94
|
+
}
|
|
90
95
|
// This method is called when the data became available on one of nodes,
|
|
91
96
|
// which this node needs data from.
|
|
92
97
|
removePending(nodeId) {
|
package/lib/transaction_log.d.ts
CHANGED
|
@@ -23,5 +23,6 @@ export declare class TransactionLog {
|
|
|
23
23
|
onInjected(node: StaticNode, graph: GraphAI, injectFrom?: string): void;
|
|
24
24
|
onComplete(node: ComputedNode, graph: GraphAI, localLog: TransactionLog[]): void;
|
|
25
25
|
beforeExecute(node: ComputedNode, graph: GraphAI, transactionId: number, inputs: ResultData[]): void;
|
|
26
|
+
beforeAddTask(node: ComputedNode, graph: GraphAI): void;
|
|
26
27
|
onError(node: ComputedNode, graph: GraphAI, errorMessage: string): void;
|
|
27
28
|
}
|
package/lib/transaction_log.js
CHANGED
|
@@ -45,6 +45,11 @@ class TransactionLog {
|
|
|
45
45
|
graph.setLoopLog(this);
|
|
46
46
|
graph.appendLog(this);
|
|
47
47
|
}
|
|
48
|
+
beforeAddTask(node, graph) {
|
|
49
|
+
this.state = node.state;
|
|
50
|
+
graph.setLoopLog(this);
|
|
51
|
+
graph.appendLog(this);
|
|
52
|
+
}
|
|
48
53
|
onError(node, graph, errorMessage) {
|
|
49
54
|
this.state = node.state;
|
|
50
55
|
this.errorMessage = errorMessage;
|
package/lib/type.d.ts
CHANGED
|
@@ -7,8 +7,7 @@ export declare enum NodeState {
|
|
|
7
7
|
Failed = "failed",
|
|
8
8
|
TimedOut = "timed-out",
|
|
9
9
|
Completed = "completed",
|
|
10
|
-
Injected = "injected"
|
|
11
|
-
Dispatched = "dispatched"
|
|
10
|
+
Injected = "injected"
|
|
12
11
|
}
|
|
13
12
|
export type DefaultResultData = Record<string, any> | string | number | Array<DefaultResultData>;
|
|
14
13
|
export type DefaultInputData = Record<string, any>;
|
package/lib/type.js
CHANGED