graphai 0.6.12 → 0.6.14
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 +18 -5
- 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/node.d.ts +1 -1
- package/lib/node.js +18 -5
- package/package.json +1 -1
package/lib/node.d.ts
CHANGED
|
@@ -20,7 +20,6 @@ export declare class ComputedNode extends Node {
|
|
|
20
20
|
readonly params: NodeDataParams;
|
|
21
21
|
private readonly filterParams;
|
|
22
22
|
readonly nestedGraph?: GraphData | DataSource;
|
|
23
|
-
private readonly config?;
|
|
24
23
|
readonly retryLimit: number;
|
|
25
24
|
retryCount: number;
|
|
26
25
|
private readonly agentId?;
|
|
@@ -43,6 +42,7 @@ export declare class ComputedNode extends Node {
|
|
|
43
42
|
readonly isComputedNode = true;
|
|
44
43
|
constructor(graphId: string, nodeId: string, data: ComputedNodeData, graph: GraphAI);
|
|
45
44
|
getAgentId(): string;
|
|
45
|
+
private getConfig;
|
|
46
46
|
private addPendingNode;
|
|
47
47
|
isReadyNode(): boolean;
|
|
48
48
|
private retry;
|
package/lib/node.js
CHANGED
|
@@ -74,7 +74,6 @@ class ComputedNode extends Node {
|
|
|
74
74
|
const agent = data.agent;
|
|
75
75
|
this.agentFunction = async ({ namedInputs, params }) => agent(namedInputs, params);
|
|
76
76
|
}
|
|
77
|
-
this.config = this.agentId ? (data.graph ? this.graph.config : ((this.graph.config ?? {})[this.agentId] ?? {})) : {};
|
|
78
77
|
this.anyInput = data.anyInput ?? false;
|
|
79
78
|
this.inputs = data.inputs;
|
|
80
79
|
this.output = data.output;
|
|
@@ -108,6 +107,19 @@ class ComputedNode extends Node {
|
|
|
108
107
|
getAgentId() {
|
|
109
108
|
return this.agentId ?? "__custom__function"; // only for display purpose in the log.
|
|
110
109
|
}
|
|
110
|
+
getConfig(hasGraphData, agentId) {
|
|
111
|
+
if (agentId) {
|
|
112
|
+
if (hasGraphData) {
|
|
113
|
+
return this.graph.config;
|
|
114
|
+
}
|
|
115
|
+
const config = this.graph.config ?? {};
|
|
116
|
+
return {
|
|
117
|
+
...(config["global"] ?? {}),
|
|
118
|
+
...(config[agentId] ?? {}),
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
return {};
|
|
122
|
+
}
|
|
111
123
|
addPendingNode(nodeId) {
|
|
112
124
|
const source = (0, utils_2.parseNodeName)(nodeId);
|
|
113
125
|
(0, utils_2.assert)(!!source.nodeId, `Invalid data source ${nodeId}`);
|
|
@@ -220,6 +232,7 @@ class ComputedNode extends Node {
|
|
|
220
232
|
}
|
|
221
233
|
const previousResults = this.graph.resultsOf(this.inputs, this.anyInput);
|
|
222
234
|
const agentId = this.agentId ? this.graph.resultOf((0, utils_2.parseNodeName)(this.agentId)) : this.agentId;
|
|
235
|
+
const config = this.getConfig(!!this.nestedGraph, agentId);
|
|
223
236
|
const transactionId = Date.now();
|
|
224
237
|
this.prepareExecute(transactionId, Object.values(previousResults));
|
|
225
238
|
if (this.timeout && this.timeout > 0) {
|
|
@@ -230,7 +243,7 @@ class ComputedNode extends Node {
|
|
|
230
243
|
try {
|
|
231
244
|
const agentFunction = this.agentFunction ?? this.graph.getAgentFunctionInfo(agentId).agent;
|
|
232
245
|
const localLog = [];
|
|
233
|
-
const context = this.getContext(previousResults, localLog, agentId);
|
|
246
|
+
const context = this.getContext(previousResults, localLog, agentId, config);
|
|
234
247
|
// NOTE: We use the existence of graph object in the agent-specific params to determine
|
|
235
248
|
// if this is a nested agent or not.
|
|
236
249
|
if (this.nestedGraph) {
|
|
@@ -242,7 +255,7 @@ class ComputedNode extends Node {
|
|
|
242
255
|
agentFilters: this.graph.agentFilters,
|
|
243
256
|
taskManager: this.graph.taskManager,
|
|
244
257
|
bypassAgentIds: this.graph.bypassAgentIds,
|
|
245
|
-
config
|
|
258
|
+
config,
|
|
246
259
|
graphLoader: this.graph.graphLoader,
|
|
247
260
|
},
|
|
248
261
|
onLogCallback: this.graph.onLogCallback,
|
|
@@ -306,7 +319,7 @@ class ComputedNode extends Node {
|
|
|
306
319
|
this.retry(type_1.NodeState.Failed, Error("Unknown"));
|
|
307
320
|
}
|
|
308
321
|
}
|
|
309
|
-
getContext(previousResults, localLog, agentId) {
|
|
322
|
+
getContext(previousResults, localLog, agentId, config) {
|
|
310
323
|
const context = {
|
|
311
324
|
params: this.graph.resultsOf(this.params),
|
|
312
325
|
namedInputs: previousResults,
|
|
@@ -315,7 +328,7 @@ class ComputedNode extends Node {
|
|
|
315
328
|
cacheType: this.agentFunction ? undefined : this.graph.getAgentFunctionInfo(agentId)?.cacheType,
|
|
316
329
|
filterParams: this.filterParams,
|
|
317
330
|
agentFilters: this.graph.agentFilters,
|
|
318
|
-
config
|
|
331
|
+
config,
|
|
319
332
|
log: localLog,
|
|
320
333
|
};
|
|
321
334
|
return context;
|