graphai 0.6.9 → 0.6.11
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 -7
- 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 +2 -2
- package/lib/node.d.ts +1 -0
- package/lib/node.js +4 -3
- package/lib/type.d.ts +10 -6
- package/lib/validators/relation_validator.d.ts +1 -1
- package/lib/validators/relation_validator.js +12 -4
- package/package.json +2 -2
package/lib/node.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ 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?;
|
|
23
24
|
readonly retryLimit: number;
|
|
24
25
|
retryCount: number;
|
|
25
26
|
private readonly agentId?;
|
package/lib/node.js
CHANGED
|
@@ -40,7 +40,7 @@ class Node {
|
|
|
40
40
|
}
|
|
41
41
|
else if (this.console.after) {
|
|
42
42
|
if ((0, utils_2.isObject)(this.console.after)) {
|
|
43
|
-
console.log(JSON.stringify((0, result_1.resultsOf)(this.console.after, { self:
|
|
43
|
+
console.log(JSON.stringify((0, result_1.resultsOf)(this.console.after, { self: { result } }, this.graph.propFunctions, true), null, 2));
|
|
44
44
|
}
|
|
45
45
|
else {
|
|
46
46
|
console.log(this.console.after);
|
|
@@ -74,6 +74,7 @@ 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] ?? {})) : {};
|
|
77
78
|
this.anyInput = data.anyInput ?? false;
|
|
78
79
|
this.inputs = data.inputs;
|
|
79
80
|
this.output = data.output;
|
|
@@ -241,7 +242,7 @@ class ComputedNode extends Node {
|
|
|
241
242
|
agentFilters: this.graph.agentFilters,
|
|
242
243
|
taskManager: this.graph.taskManager,
|
|
243
244
|
bypassAgentIds: this.graph.bypassAgentIds,
|
|
244
|
-
config: this.
|
|
245
|
+
config: this.config,
|
|
245
246
|
graphLoader: this.graph.graphLoader,
|
|
246
247
|
},
|
|
247
248
|
onLogCallback: this.graph.onLogCallback,
|
|
@@ -314,7 +315,7 @@ class ComputedNode extends Node {
|
|
|
314
315
|
cacheType: this.agentFunction ? undefined : this.graph.getAgentFunctionInfo(agentId)?.cacheType,
|
|
315
316
|
filterParams: this.filterParams,
|
|
316
317
|
agentFilters: this.graph.agentFilters,
|
|
317
|
-
config: this.
|
|
318
|
+
config: this.config,
|
|
318
319
|
log: localLog,
|
|
319
320
|
};
|
|
320
321
|
return context;
|
package/lib/type.d.ts
CHANGED
|
@@ -13,8 +13,11 @@ export declare enum NodeState {
|
|
|
13
13
|
}
|
|
14
14
|
export type DefaultResultData = Record<string, any> | string | number | boolean | Array<DefaultResultData>;
|
|
15
15
|
export type DefaultInputData = Record<string, any>;
|
|
16
|
+
export type DefaultConfigData = Record<string, any>;
|
|
16
17
|
export type ResultData<ResultType = DefaultResultData> = ResultType | undefined;
|
|
17
18
|
export type ResultDataDictionary<ResultType = DefaultResultData> = Record<string, ResultData<ResultType>>;
|
|
19
|
+
export type ConfigData<ConfigType = DefaultConfigData> = ConfigType;
|
|
20
|
+
export type ConfigDataDictionary<ConfigType = DefaultConfigData> = Record<string, ConfigType>;
|
|
18
21
|
export type DefaultParamsType = Record<string, any>;
|
|
19
22
|
export type NodeDataParams<ParamsType = DefaultParamsType> = ParamsType;
|
|
20
23
|
export type PassThrough = Record<string, any>;
|
|
@@ -78,11 +81,11 @@ export type GraphOptions = {
|
|
|
78
81
|
agentFilters?: AgentFilterInfo[] | undefined;
|
|
79
82
|
taskManager?: TaskManager | undefined;
|
|
80
83
|
bypassAgentIds?: string[] | undefined;
|
|
81
|
-
config?:
|
|
84
|
+
config?: ConfigDataDictionary;
|
|
82
85
|
graphLoader?: GraphDataLoader;
|
|
83
86
|
};
|
|
84
87
|
export type CacheTypes = "pureAgent" | "impureAgent";
|
|
85
|
-
export type AgentFunctionContext<ParamsType = DefaultParamsType, NamedInputDataType = DefaultInputData> = {
|
|
88
|
+
export type AgentFunctionContext<ParamsType = DefaultParamsType, NamedInputDataType = DefaultInputData, ConfigType = DefaultConfigData> = {
|
|
86
89
|
params: NodeDataParams<ParamsType>;
|
|
87
90
|
inputSchema?: any;
|
|
88
91
|
namedInputs: NamedInputDataType;
|
|
@@ -104,9 +107,9 @@ export type AgentFunctionContext<ParamsType = DefaultParamsType, NamedInputDataT
|
|
|
104
107
|
filterParams: AgentFilterParams;
|
|
105
108
|
agentFilters?: AgentFilterInfo[];
|
|
106
109
|
log?: TransactionLog[];
|
|
107
|
-
config?:
|
|
110
|
+
config?: ConfigType;
|
|
108
111
|
};
|
|
109
|
-
export type AgentFunction<ParamsType = DefaultParamsType, ResultType = DefaultResultData, NamedInputDataType = DefaultInputData> = (context: AgentFunctionContext<ParamsType, NamedInputDataType>) => Promise<ResultData<ResultType>>;
|
|
112
|
+
export type AgentFunction<ParamsType = DefaultParamsType, ResultType = DefaultResultData, NamedInputDataType = DefaultInputData, ConfigType = DefaultConfigData> = (context: AgentFunctionContext<ParamsType, NamedInputDataType, ConfigType>) => Promise<ResultData<ResultType>>;
|
|
110
113
|
export type AgentFilterFunction<ParamsType = DefaultParamsType, ResultType = DefaultResultData, NamedInputDataType = DefaultInputData> = (context: AgentFunctionContext<ParamsType, NamedInputDataType>, agent: AgentFunction) => Promise<ResultData<ResultType>>;
|
|
111
114
|
export type AgentFilterInfo = {
|
|
112
115
|
name: string;
|
|
@@ -123,12 +126,13 @@ export type AgentFunctionInfoSample = {
|
|
|
123
126
|
};
|
|
124
127
|
export type AgentFunctionInfo = {
|
|
125
128
|
name: string;
|
|
126
|
-
agent: AgentFunction<any, any, any>;
|
|
127
|
-
mock: AgentFunction<any, any, any>;
|
|
129
|
+
agent: AgentFunction<any, any, any, any>;
|
|
130
|
+
mock: AgentFunction<any, any, any, any>;
|
|
128
131
|
inputs?: any;
|
|
129
132
|
output?: any;
|
|
130
133
|
outputFormat?: any;
|
|
131
134
|
params?: any;
|
|
135
|
+
config?: any;
|
|
132
136
|
samples: AgentFunctionInfoSample[];
|
|
133
137
|
description: string;
|
|
134
138
|
category: string[];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { GraphData } from "../type";
|
|
2
|
-
export declare const relationValidator: (
|
|
2
|
+
export declare const relationValidator: (graphData: GraphData, staticNodeIds: string[], computedNodeIds: string[]) => void;
|
|
@@ -4,13 +4,13 @@ exports.relationValidator = void 0;
|
|
|
4
4
|
const utils_1 = require("../utils/utils");
|
|
5
5
|
const common_1 = require("../validators/common");
|
|
6
6
|
const nodeUtils_1 = require("../utils/nodeUtils");
|
|
7
|
-
const relationValidator = (
|
|
8
|
-
const nodeIds = new Set(Object.keys(
|
|
7
|
+
const relationValidator = (graphData, staticNodeIds, computedNodeIds) => {
|
|
8
|
+
const nodeIds = new Set(Object.keys(graphData.nodes));
|
|
9
9
|
const pendings = {};
|
|
10
10
|
const waitlist = {};
|
|
11
11
|
// validate input relation and set pendings and wait list
|
|
12
12
|
computedNodeIds.forEach((computedNodeId) => {
|
|
13
|
-
const nodeData =
|
|
13
|
+
const nodeData = graphData.nodes[computedNodeId];
|
|
14
14
|
pendings[computedNodeId] = new Set();
|
|
15
15
|
const dataSourceValidator = (sourceType, sourceNodeIds) => {
|
|
16
16
|
sourceNodeIds.forEach((sourceNodeId) => {
|
|
@@ -29,6 +29,10 @@ const relationValidator = (data, staticNodeIds, computedNodeIds) => {
|
|
|
29
29
|
const sourceNodeIds = (0, nodeUtils_1.dataSourceNodeIds)((0, nodeUtils_1.inputs2dataSources)(nodeData.inputs));
|
|
30
30
|
dataSourceValidator("Inputs", sourceNodeIds);
|
|
31
31
|
}
|
|
32
|
+
if (nodeData.params) {
|
|
33
|
+
const sourceNodeIds = (0, nodeUtils_1.dataSourceNodeIds)((0, nodeUtils_1.inputs2dataSources)(nodeData.params));
|
|
34
|
+
dataSourceValidator("Params", sourceNodeIds);
|
|
35
|
+
}
|
|
32
36
|
if (nodeData.if) {
|
|
33
37
|
const sourceNodeIds = (0, nodeUtils_1.dataSourceNodeIds)((0, nodeUtils_1.inputs2dataSources)({ if: nodeData.if }));
|
|
34
38
|
dataSourceValidator("If", sourceNodeIds);
|
|
@@ -41,11 +45,15 @@ const relationValidator = (data, staticNodeIds, computedNodeIds) => {
|
|
|
41
45
|
const sourceNodeIds = (0, nodeUtils_1.dataSourceNodeIds)((0, nodeUtils_1.inputs2dataSources)({ graph: nodeData.graph }));
|
|
42
46
|
dataSourceValidator("Graph", sourceNodeIds);
|
|
43
47
|
}
|
|
48
|
+
if (typeof nodeData.agent === "string" && nodeData.agent[0] === ":") {
|
|
49
|
+
const sourceNodeIds = (0, nodeUtils_1.dataSourceNodeIds)((0, nodeUtils_1.inputs2dataSources)({ agent: nodeData.agent }));
|
|
50
|
+
dataSourceValidator("Agent", sourceNodeIds);
|
|
51
|
+
}
|
|
44
52
|
}
|
|
45
53
|
});
|
|
46
54
|
// TODO. validate update
|
|
47
55
|
staticNodeIds.forEach((staticNodeId) => {
|
|
48
|
-
const nodeData =
|
|
56
|
+
const nodeData = graphData.nodes[staticNodeId];
|
|
49
57
|
if ("value" in nodeData && nodeData.update) {
|
|
50
58
|
const update = nodeData.update;
|
|
51
59
|
const updateNodeId = (0, utils_1.parseNodeName)(update).nodeId;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "graphai",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.11",
|
|
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.5"
|
|
31
31
|
},
|
|
32
32
|
"types": "./lib/index.d.ts",
|
|
33
33
|
"directories": {
|