graphai 0.6.1 → 0.6.3
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 +33 -22
- 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 +11 -14
- package/lib/type.d.ts +5 -8
- package/lib/utils/prop_function.js +10 -0
- package/lib/utils/utils.d.ts +3 -3
- package/package.json +2 -2
package/lib/node.js
CHANGED
|
@@ -45,7 +45,6 @@ class ComputedNode extends Node {
|
|
|
45
45
|
super(nodeId, graph);
|
|
46
46
|
this.retryCount = 0;
|
|
47
47
|
this.dataSources = []; // no longer needed. This is for transaction log.
|
|
48
|
-
this.isNamedInputs = false;
|
|
49
48
|
this.isStaticNode = false;
|
|
50
49
|
this.isComputedNode = true;
|
|
51
50
|
this.graphId = graphId;
|
|
@@ -59,7 +58,6 @@ class ComputedNode extends Node {
|
|
|
59
58
|
this.priority = data.priority ?? 0;
|
|
60
59
|
this.anyInput = data.anyInput ?? false;
|
|
61
60
|
this.inputs = data.inputs;
|
|
62
|
-
// this.isNamedInputs = isObject(data.inputs) && !Array.isArray(data.inputs);
|
|
63
61
|
this.dataSources = data.inputs ? (0, nodeUtils_1.inputs2dataSources)(data.inputs).flat(10) : [];
|
|
64
62
|
if (data.inputs && Array.isArray(data.inputs)) {
|
|
65
63
|
throw new Error(`array inputs have been deprecated. nodeId: ${nodeId}: see https://github.com/receptron/graphai/blob/main/docs/NamedInputs.md`);
|
|
@@ -71,7 +69,6 @@ class ComputedNode extends Node {
|
|
|
71
69
|
}
|
|
72
70
|
else {
|
|
73
71
|
const agent = data.agent;
|
|
74
|
-
// this.agentFunction = this.isNamedInputs ? async ({ namedInputs, params }) => agent(namedInputs, params) : async ({ inputs }) => agent(...inputs);
|
|
75
72
|
this.agentFunction = async ({ namedInputs, params }) => agent(namedInputs, params);
|
|
76
73
|
}
|
|
77
74
|
if (data.graph) {
|
|
@@ -221,18 +218,19 @@ class ComputedNode extends Node {
|
|
|
221
218
|
// if this is a nested agent or not.
|
|
222
219
|
if (this.nestedGraph) {
|
|
223
220
|
this.graph.taskManager.prepareForNesting();
|
|
224
|
-
context.taskManager = this.graph.taskManager;
|
|
221
|
+
// context.taskManager = this.graph.taskManager;
|
|
225
222
|
context.onLogCallback = this.graph.onLogCallback;
|
|
223
|
+
/*
|
|
226
224
|
if ("nodes" in this.nestedGraph) {
|
|
227
|
-
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
context.agents = this.graph.agentFunctionInfoDictionary;
|
|
225
|
+
context.graphData = this.nestedGraph;
|
|
226
|
+
} else {
|
|
227
|
+
context.graphData = this.graph.resultOf(this.nestedGraph) as GraphData; // HACK: compiler work-around
|
|
228
|
+
}
|
|
229
|
+
*/
|
|
230
|
+
// context.agents = this.graph.agentFunctionInfoDictionary;
|
|
233
231
|
context.forNestedGraph = {
|
|
234
|
-
graphData:
|
|
235
|
-
agents:
|
|
232
|
+
graphData: "nodes" in this.nestedGraph ? this.nestedGraph : this.graph.resultOf(this.nestedGraph), // HACK: compiler work-around
|
|
233
|
+
agents: this.graph.agentFunctionInfoDictionary,
|
|
236
234
|
graphOptions: {
|
|
237
235
|
agentFilters: this.graph.agentFilters,
|
|
238
236
|
taskManager: this.graph.taskManager,
|
|
@@ -240,6 +238,7 @@ class ComputedNode extends Node {
|
|
|
240
238
|
config: this.graph.config,
|
|
241
239
|
graphLoader: this.graph.graphLoader,
|
|
242
240
|
},
|
|
241
|
+
onLogCallback: this.graph.onLogCallback,
|
|
243
242
|
};
|
|
244
243
|
}
|
|
245
244
|
this.beforeConsoleLog(context);
|
|
@@ -311,7 +310,6 @@ class ComputedNode extends Node {
|
|
|
311
310
|
getContext(previousResults, localLog) {
|
|
312
311
|
const context = {
|
|
313
312
|
params: this.getParams(),
|
|
314
|
-
// inputs: this.getInputs(previousResults),
|
|
315
313
|
namedInputs: previousResults,
|
|
316
314
|
inputSchema: this.agentFunction ? undefined : this.graph.getAgentFunctionInfo(this.agentId)?.inputs,
|
|
317
315
|
debugInfo: this.getDebugInfo(),
|
|
@@ -346,7 +344,6 @@ class ComputedNode extends Node {
|
|
|
346
344
|
}
|
|
347
345
|
beforeConsoleLog(context) {
|
|
348
346
|
if (this.console.before === true) {
|
|
349
|
-
// console.log(JSON.stringify(this.isNamedInputs ? context.namedInputs : context.inputs, null, 2));
|
|
350
347
|
console.log(JSON.stringify(context.namedInputs, null, 2));
|
|
351
348
|
}
|
|
352
349
|
else if (this.console.before) {
|
package/lib/type.d.ts
CHANGED
|
@@ -75,7 +75,7 @@ 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
80
|
inputSchema?: any;
|
|
81
81
|
namedInputs: NamedInputDataType;
|
|
@@ -87,9 +87,6 @@ export type AgentFunctionContext<ParamsType = DefaultParamsType, InputDataType =
|
|
|
87
87
|
version?: number;
|
|
88
88
|
isResult?: boolean;
|
|
89
89
|
};
|
|
90
|
-
graphData?: GraphData;
|
|
91
|
-
agents?: AgentFunctionInfoDictionary;
|
|
92
|
-
taskManager?: TaskManager;
|
|
93
90
|
forNestedGraph?: {
|
|
94
91
|
graphData: GraphData;
|
|
95
92
|
agents: AgentFunctionInfoDictionary;
|
|
@@ -103,8 +100,8 @@ export type AgentFunctionContext<ParamsType = DefaultParamsType, InputDataType =
|
|
|
103
100
|
log?: TransactionLog[];
|
|
104
101
|
config?: Record<string, unknown>;
|
|
105
102
|
};
|
|
106
|
-
export type AgentFunction<ParamsType = DefaultParamsType, ResultType = DefaultResultData,
|
|
107
|
-
export type AgentFilterFunction<ParamsType = DefaultParamsType, ResultType = DefaultResultData,
|
|
103
|
+
export type AgentFunction<ParamsType = DefaultParamsType, ResultType = DefaultResultData, NamedInputDataType = DefaultInputData> = (context: AgentFunctionContext<ParamsType, NamedInputDataType>) => Promise<ResultData<ResultType>>;
|
|
104
|
+
export type AgentFilterFunction<ParamsType = DefaultParamsType, ResultType = DefaultResultData, NamedInputDataType = DefaultInputData> = (context: AgentFunctionContext<ParamsType, NamedInputDataType>, agent: AgentFunction) => Promise<ResultData<ResultType>>;
|
|
108
105
|
export type AgentFilterInfo = {
|
|
109
106
|
name: string;
|
|
110
107
|
agent: AgentFilterFunction;
|
|
@@ -120,8 +117,8 @@ export type AgentFunctionInfoSample = {
|
|
|
120
117
|
};
|
|
121
118
|
export type AgentFunctionInfo = {
|
|
122
119
|
name: string;
|
|
123
|
-
agent: AgentFunction<any, any, any
|
|
124
|
-
mock: AgentFunction<any, any, any
|
|
120
|
+
agent: AgentFunction<any, any, any>;
|
|
121
|
+
mock: AgentFunction<any, any, any>;
|
|
125
122
|
inputs?: any;
|
|
126
123
|
output?: any;
|
|
127
124
|
outputFormat?: any;
|
|
@@ -56,6 +56,16 @@ const propStringFunction = (result, propId) => {
|
|
|
56
56
|
return ret;
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
+
if (propId === "trim()") {
|
|
60
|
+
return result.trim();
|
|
61
|
+
}
|
|
62
|
+
if (propId === "toLowerCase()") {
|
|
63
|
+
return result.toLowerCase();
|
|
64
|
+
}
|
|
65
|
+
if (propId === "toUpperCase()") {
|
|
66
|
+
return result.toUpperCase();
|
|
67
|
+
}
|
|
68
|
+
// split()
|
|
59
69
|
}
|
|
60
70
|
return undefined;
|
|
61
71
|
};
|
package/lib/utils/utils.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export declare const defaultAgentInfo: {
|
|
|
18
18
|
repository: string;
|
|
19
19
|
license: string;
|
|
20
20
|
};
|
|
21
|
-
export declare const agentInfoWrapper: (agent: AgentFunction<any, any, any
|
|
21
|
+
export declare const agentInfoWrapper: (agent: AgentFunction<any, any, any>) => {
|
|
22
22
|
name: string;
|
|
23
23
|
samples: {
|
|
24
24
|
inputs: never[];
|
|
@@ -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: AgentFunction<any, any, any
|
|
34
|
-
mock: AgentFunction<any, any, any
|
|
33
|
+
agent: AgentFunction<any, any, any>;
|
|
34
|
+
mock: AgentFunction<any, any, 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.6.
|
|
3
|
+
"version": "0.6.3",
|
|
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.27.
|
|
30
|
+
"typedoc": "^0.27.3"
|
|
31
31
|
},
|
|
32
32
|
"types": "./lib/index.d.ts",
|
|
33
33
|
"directories": {
|