graphai 0.5.21 → 0.6.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/bundle.cjs.js +1 -1
- package/lib/bundle.cjs.js.map +1 -1
- package/lib/bundle.esm.js +16 -12
- 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 +0 -1
- package/lib/node.js +16 -12
- package/lib/type.d.ts +3 -4
- package/lib/utils/utils.d.ts +2 -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, params }) => agent(namedInputs, params) : 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,17 +300,19 @@ 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(),
|
|
315
318
|
cacheType: this.agentFunction ? undefined : this.graph.getAgentFunctionInfo(this.agentId)?.cacheType,
|
|
@@ -343,7 +346,8 @@ class ComputedNode extends Node {
|
|
|
343
346
|
}
|
|
344
347
|
beforeConsoleLog(context) {
|
|
345
348
|
if (this.console.before === true) {
|
|
346
|
-
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));
|
|
347
351
|
}
|
|
348
352
|
else if (this.console.before) {
|
|
349
353
|
console.log(this.console.before);
|
package/lib/type.d.ts
CHANGED
|
@@ -75,9 +75,8 @@ export type GraphOptions = {
|
|
|
75
75
|
graphLoader?: GraphDataLoader;
|
|
76
76
|
};
|
|
77
77
|
export type CacheTypes = "pureAgent" | "impureAgent";
|
|
78
|
-
export type AgentFunctionContext<ParamsType = DefaultParamsType,
|
|
78
|
+
export type AgentFunctionContext<ParamsType = DefaultParamsType, NamedInputDataType = DefaultInputData> = {
|
|
79
79
|
params: NodeDataParams<ParamsType>;
|
|
80
|
-
inputs: Array<InputDataType>;
|
|
81
80
|
inputSchema?: any;
|
|
82
81
|
namedInputs: NamedInputDataType;
|
|
83
82
|
debugInfo: {
|
|
@@ -104,8 +103,8 @@ export type AgentFunctionContext<ParamsType = DefaultParamsType, InputDataType =
|
|
|
104
103
|
log?: TransactionLog[];
|
|
105
104
|
config?: Record<string, unknown>;
|
|
106
105
|
};
|
|
107
|
-
export type AgentFunction<ParamsType = DefaultParamsType, ResultType = DefaultResultData, InputDataType = DefaultInputData, NamedInputDataType =
|
|
108
|
-
export type AgentFilterFunction<ParamsType = DefaultParamsType, ResultType = DefaultResultData, InputDataType = DefaultInputData, NamedInputDataType =
|
|
106
|
+
export type AgentFunction<ParamsType = DefaultParamsType, ResultType = DefaultResultData, InputDataType = DefaultInputData, NamedInputDataType = undefined> = NamedInputDataType extends undefined ? (context: AgentFunctionContext<ParamsType, InputDataType>) => Promise<ResultData<ResultType>> : (context: AgentFunctionContext<ParamsType, NamedInputDataType>) => Promise<ResultData<ResultType>>;
|
|
107
|
+
export type AgentFilterFunction<ParamsType = DefaultParamsType, ResultType = DefaultResultData, InputDataType = DefaultInputData, NamedInputDataType = undefined> = NamedInputDataType extends undefined ? (context: AgentFunctionContext<ParamsType, InputDataType>, agent: AgentFunction) => Promise<ResultData<ResultType>> : (context: AgentFunctionContext<ParamsType, NamedInputDataType>, agent: AgentFunction) => Promise<ResultData<ResultType>>;
|
|
109
108
|
export type AgentFilterInfo = {
|
|
110
109
|
name: string;
|
|
111
110
|
agent: AgentFilterFunction;
|
package/lib/utils/utils.d.ts
CHANGED
|
@@ -30,8 +30,8 @@ export declare const agentInfoWrapper: (agent: AgentFunction<any, any, any, any>
|
|
|
30
30
|
author: string;
|
|
31
31
|
repository: string;
|
|
32
32
|
license: string;
|
|
33
|
-
agent:
|
|
34
|
-
mock:
|
|
33
|
+
agent: ((context: import("../type").AgentFunctionContext<any, any>) => Promise<any>) | ((context: import("../type").AgentFunctionContext<any, any>) => Promise<any>);
|
|
34
|
+
mock: ((context: import("../type").AgentFunctionContext<any, any>) => Promise<any>) | ((context: import("../type").AgentFunctionContext<any, any>) => Promise<any>);
|
|
35
35
|
};
|
|
36
36
|
export declare const debugResultKey: (agentId: string, result: any) => string[];
|
|
37
37
|
export declare const isLogicallyTrue: (value: any) => boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "graphai",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.2",
|
|
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": {
|