graphai 0.5.20 → 0.6.1
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 +3 -1
- 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 +1 -0
- package/lib/graphai.js +1 -0
- package/lib/node.d.ts +0 -1
- package/lib/node.js +17 -12
- package/lib/type.d.ts +3 -2
- package/package.json +2 -2
package/lib/node.js
CHANGED
|
@@ -59,10 +59,10 @@ class ComputedNode extends Node {
|
|
|
59
59
|
this.priority = data.priority ?? 0;
|
|
60
60
|
this.anyInput = data.anyInput ?? false;
|
|
61
61
|
this.inputs = data.inputs;
|
|
62
|
-
this.isNamedInputs =
|
|
62
|
+
// this.isNamedInputs = isObject(data.inputs) && !Array.isArray(data.inputs);
|
|
63
63
|
this.dataSources = data.inputs ? (0, nodeUtils_1.inputs2dataSources)(data.inputs).flat(10) : [];
|
|
64
|
-
if (data.inputs &&
|
|
65
|
-
|
|
64
|
+
if (data.inputs && Array.isArray(data.inputs)) {
|
|
65
|
+
throw new Error(`array inputs have been deprecated. nodeId: ${nodeId}: see https://github.com/receptron/graphai/blob/main/docs/NamedInputs.md`);
|
|
66
66
|
}
|
|
67
67
|
this.pendings = new Set((0, nodeUtils_1.dataSourceNodeIds)(this.dataSources));
|
|
68
68
|
(0, utils_2.assert)(["function", "string"].includes(typeof data.agent), "agent must be either string or function");
|
|
@@ -71,7 +71,8 @@ class ComputedNode extends Node {
|
|
|
71
71
|
}
|
|
72
72
|
else {
|
|
73
73
|
const agent = data.agent;
|
|
74
|
-
this.agentFunction = this.isNamedInputs ? async ({ namedInputs }) => agent(namedInputs) : async ({ inputs }) => agent(...inputs);
|
|
74
|
+
// this.agentFunction = this.isNamedInputs ? async ({ namedInputs, params }) => agent(namedInputs, params) : async ({ inputs }) => agent(...inputs);
|
|
75
|
+
this.agentFunction = async ({ namedInputs, params }) => agent(namedInputs, params);
|
|
75
76
|
}
|
|
76
77
|
if (data.graph) {
|
|
77
78
|
this.nestedGraph = typeof data.graph === "string" ? this.addPendingNode(data.graph) : data.graph;
|
|
@@ -299,19 +300,22 @@ class ComputedNode extends Node {
|
|
|
299
300
|
return tmp;
|
|
300
301
|
}, { ...this.params });
|
|
301
302
|
}
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
303
|
+
/*
|
|
304
|
+
private getInputs(previousResults: Record<string, ResultData | undefined>) {
|
|
305
|
+
if (Array.isArray(this.inputs)) {
|
|
306
|
+
return (this.inputs ?? []).map((key) => previousResults[String(key)]).filter((a) => !this.anyInput || a);
|
|
307
|
+
}
|
|
308
|
+
return [];
|
|
307
309
|
}
|
|
310
|
+
*/
|
|
308
311
|
getContext(previousResults, localLog) {
|
|
309
312
|
const context = {
|
|
310
313
|
params: this.getParams(),
|
|
311
|
-
inputs: this.getInputs(previousResults),
|
|
312
|
-
namedInputs:
|
|
314
|
+
// inputs: this.getInputs(previousResults),
|
|
315
|
+
namedInputs: previousResults,
|
|
313
316
|
inputSchema: this.agentFunction ? undefined : this.graph.getAgentFunctionInfo(this.agentId)?.inputs,
|
|
314
317
|
debugInfo: this.getDebugInfo(),
|
|
318
|
+
cacheType: this.agentFunction ? undefined : this.graph.getAgentFunctionInfo(this.agentId)?.cacheType,
|
|
315
319
|
filterParams: this.filterParams,
|
|
316
320
|
agentFilters: this.graph.agentFilters,
|
|
317
321
|
config: this.graph.config,
|
|
@@ -342,7 +346,8 @@ class ComputedNode extends Node {
|
|
|
342
346
|
}
|
|
343
347
|
beforeConsoleLog(context) {
|
|
344
348
|
if (this.console.before === true) {
|
|
345
|
-
console.log(JSON.stringify(this.isNamedInputs ? context.namedInputs : context.inputs, null, 2));
|
|
349
|
+
// console.log(JSON.stringify(this.isNamedInputs ? context.namedInputs : context.inputs, null, 2));
|
|
350
|
+
console.log(JSON.stringify(context.namedInputs, null, 2));
|
|
346
351
|
}
|
|
347
352
|
else if (this.console.before) {
|
|
348
353
|
console.log(this.console.before);
|
package/lib/type.d.ts
CHANGED
|
@@ -74,9 +74,9 @@ export type GraphOptions = {
|
|
|
74
74
|
config?: Record<string, unknown>;
|
|
75
75
|
graphLoader?: GraphDataLoader;
|
|
76
76
|
};
|
|
77
|
+
export type CacheTypes = "pureAgent" | "impureAgent";
|
|
77
78
|
export type AgentFunctionContext<ParamsType = DefaultParamsType, InputDataType = DefaultInputData, NamedInputDataType = DefaultInputData> = {
|
|
78
79
|
params: NodeDataParams<ParamsType>;
|
|
79
|
-
inputs: Array<InputDataType>;
|
|
80
80
|
inputSchema?: any;
|
|
81
81
|
namedInputs: NamedInputDataType;
|
|
82
82
|
debugInfo: {
|
|
@@ -96,7 +96,7 @@ export type AgentFunctionContext<ParamsType = DefaultParamsType, InputDataType =
|
|
|
96
96
|
graphOptions: GraphOptions;
|
|
97
97
|
onLogCallback?: (log: TransactionLog, isUpdate: boolean) => void;
|
|
98
98
|
};
|
|
99
|
-
cacheType?:
|
|
99
|
+
cacheType?: CacheTypes;
|
|
100
100
|
onLogCallback?: (log: TransactionLog, isUpdate: boolean) => void;
|
|
101
101
|
filterParams: AgentFilterParams;
|
|
102
102
|
agentFilters?: AgentFilterInfo[];
|
|
@@ -132,6 +132,7 @@ export type AgentFunctionInfo = {
|
|
|
132
132
|
author: string;
|
|
133
133
|
repository: string;
|
|
134
134
|
license: string;
|
|
135
|
+
cacheType?: CacheTypes;
|
|
135
136
|
environmentVariables?: string[];
|
|
136
137
|
stream?: boolean;
|
|
137
138
|
apiKeys?: string[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "graphai",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "Asynchronous data flow execution engine for agentic AI apps.",
|
|
5
5
|
"main": "lib/bundle.cjs.js",
|
|
6
6
|
"module": "lib/bundle.esm.js",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"homepage": "https://github.com/receptron/graphai#readme",
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"typedoc": "^0.
|
|
30
|
+
"typedoc": "^0.27.2"
|
|
31
31
|
},
|
|
32
32
|
"types": "./lib/index.d.ts",
|
|
33
33
|
"directories": {
|