graphai 0.5.0 → 0.5.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/README.md +6 -4
- package/lib/graphai.d.ts +1 -0
- package/lib/graphai.js +1 -0
- package/lib/node.js +3 -1
- package/lib/type.d.ts +9 -8
- package/lib/validators/relation_validator.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -190,12 +190,14 @@ nodes:
|
|
|
190
190
|
inputs: [":source"] // == "sourceNode.query"
|
|
191
191
|
database:
|
|
192
192
|
agent: "nestedAgent"
|
|
193
|
-
inputs:
|
|
193
|
+
inputs:
|
|
194
|
+
prompt: ":question"
|
|
195
|
+
projectId: ":projectId"
|
|
194
196
|
graph:
|
|
195
197
|
nodes:
|
|
196
198
|
schema: // retrieves the database schema for the apecified projectId
|
|
197
199
|
agent: "schemaAgent"
|
|
198
|
-
inputs: ["
|
|
200
|
+
inputs: [":projectId"]
|
|
199
201
|
... // issue query to the database and build an appropriate prompt with it.
|
|
200
202
|
query: // send the generated prompt to the LLM
|
|
201
203
|
agent: "llama3Agent"
|
|
@@ -296,7 +298,7 @@ nodes:
|
|
|
296
298
|
value: [Steve Jobs, Elon Musk, Nikola Tesla]
|
|
297
299
|
retriever:
|
|
298
300
|
agent: "mapAgent"
|
|
299
|
-
inputs:
|
|
301
|
+
inputs: { rows: ":people" }
|
|
300
302
|
graph:
|
|
301
303
|
nodes:
|
|
302
304
|
query:
|
|
@@ -304,7 +306,7 @@ nodes:
|
|
|
304
306
|
params:
|
|
305
307
|
manifest:
|
|
306
308
|
prompt: Describe about the person in less than 100 words
|
|
307
|
-
inputs: ["
|
|
309
|
+
inputs: [":row"]
|
|
308
310
|
```
|
|
309
311
|
|
|
310
312
|
Here is the conceptual representation of this operation.
|
package/lib/graphai.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ export declare class GraphAI {
|
|
|
25
25
|
constructor(data: GraphData, agentFunctionInfoDictionary: AgentFunctionInfoDictionary, options?: GraphOptions);
|
|
26
26
|
getAgentFunctionInfo(agentId?: string): import("./type").AgentFunctionInfo | {
|
|
27
27
|
agent: () => Promise<null>;
|
|
28
|
+
inputs: null;
|
|
28
29
|
};
|
|
29
30
|
asString(): string;
|
|
30
31
|
results<T = DefaultResultData>(all: boolean): ResultDataDictionary<T>;
|
package/lib/graphai.js
CHANGED
package/lib/node.js
CHANGED
|
@@ -250,12 +250,14 @@ class ComputedNode extends Node {
|
|
|
250
250
|
const context = {
|
|
251
251
|
params: params,
|
|
252
252
|
inputs: previousResults,
|
|
253
|
+
inputSchema: this.agentFunction ? undefined : this.graph.getAgentFunctionInfo(this.agentId)?.inputs,
|
|
253
254
|
namedInputs: {},
|
|
254
255
|
debugInfo: {
|
|
255
256
|
nodeId: this.nodeId,
|
|
256
257
|
agentId: this.agentId,
|
|
257
258
|
retry: this.retryCount,
|
|
258
259
|
verbose: this.graph.verbose,
|
|
260
|
+
version: this.graph.version,
|
|
259
261
|
},
|
|
260
262
|
filterParams: this.filterParams,
|
|
261
263
|
agentFilters: this.graph.agentFilters,
|
|
@@ -283,7 +285,7 @@ class ComputedNode extends Node {
|
|
|
283
285
|
context.agents = this.graph.agentFunctionInfoDictionary;
|
|
284
286
|
}
|
|
285
287
|
if (this.console.before) {
|
|
286
|
-
console.log(this.console.before === true ? JSON.stringify(context.inputs, null, 2) : this.console.before);
|
|
288
|
+
console.log(this.console.before === true ? JSON.stringify(this.inputNames ? context.namedInputs : context.inputs, null, 2) : this.console.before);
|
|
287
289
|
}
|
|
288
290
|
const result = await this.agentFilterHandler(context, agentFunction);
|
|
289
291
|
if (this.console.after) {
|
package/lib/type.d.ts
CHANGED
|
@@ -61,25 +61,27 @@ export type GraphOptions = {
|
|
|
61
61
|
taskManager?: TaskManager | undefined;
|
|
62
62
|
bypassAgentIds?: string[] | undefined;
|
|
63
63
|
};
|
|
64
|
-
export type AgentFunctionContext<ParamsType = DefaultParamsType, InputDataType = DefaultInputData> = {
|
|
64
|
+
export type AgentFunctionContext<ParamsType = DefaultParamsType, InputDataType = DefaultInputData, NamedInputDataType = DefaultInputData> = {
|
|
65
65
|
params: NodeDataParams<ParamsType>;
|
|
66
66
|
inputs: Array<InputDataType>;
|
|
67
|
-
|
|
67
|
+
inputSchema?: any;
|
|
68
|
+
namedInputs: NamedInputDataType;
|
|
68
69
|
debugInfo: {
|
|
69
70
|
verbose: boolean;
|
|
70
71
|
nodeId: string;
|
|
71
72
|
retry: number;
|
|
72
73
|
agentId?: string;
|
|
74
|
+
version?: number;
|
|
73
75
|
};
|
|
74
|
-
graphData?: GraphData
|
|
76
|
+
graphData?: GraphData;
|
|
75
77
|
agents?: AgentFunctionInfoDictionary;
|
|
76
78
|
taskManager?: TaskManager;
|
|
77
79
|
filterParams: AgentFilterParams;
|
|
78
80
|
agentFilters?: AgentFilterInfo[];
|
|
79
81
|
log?: TransactionLog[];
|
|
80
82
|
};
|
|
81
|
-
export type AgentFunction<ParamsType = DefaultParamsType, ResultType = DefaultResultData, InputDataType = DefaultInputData> = (context: AgentFunctionContext<ParamsType, InputDataType>) => Promise<ResultData<ResultType>>;
|
|
82
|
-
export type AgentFilterFunction<ParamsType = DefaultParamsType, ResultType = DefaultResultData, InputDataType = DefaultInputData> = (context: AgentFunctionContext<ParamsType, InputDataType>, agent: AgentFunction) => Promise<ResultData<ResultType>>;
|
|
83
|
+
export type AgentFunction<ParamsType = DefaultParamsType, ResultType = DefaultResultData, InputDataType = DefaultInputData, NamedInputDataType = DefaultInputData> = (context: AgentFunctionContext<ParamsType, InputDataType, NamedInputDataType>) => Promise<ResultData<ResultType>>;
|
|
84
|
+
export type AgentFilterFunction<ParamsType = DefaultParamsType, ResultType = DefaultResultData, InputDataType = DefaultInputData, NamedInputDataType = DefaultInputData> = (context: AgentFunctionContext<ParamsType, InputDataType, NamedInputDataType>, agent: AgentFunction) => Promise<ResultData<ResultType>>;
|
|
83
85
|
export type AgentFilterInfo = {
|
|
84
86
|
name: string;
|
|
85
87
|
agent: AgentFilterFunction;
|
|
@@ -89,8 +91,8 @@ export type AgentFilterInfo = {
|
|
|
89
91
|
};
|
|
90
92
|
export type AgentFunctionInfo = {
|
|
91
93
|
name: string;
|
|
92
|
-
agent: AgentFunction<any, any, any>;
|
|
93
|
-
mock: AgentFunction<any, any, any>;
|
|
94
|
+
agent: AgentFunction<any, any, any, any>;
|
|
95
|
+
mock: AgentFunction<any, any, any, any>;
|
|
94
96
|
inputs?: any;
|
|
95
97
|
output?: any;
|
|
96
98
|
samples: {
|
|
@@ -99,7 +101,6 @@ export type AgentFunctionInfo = {
|
|
|
99
101
|
result: any;
|
|
100
102
|
graph?: GraphData;
|
|
101
103
|
}[];
|
|
102
|
-
skipTest?: boolean;
|
|
103
104
|
description: string;
|
|
104
105
|
category: string[];
|
|
105
106
|
author: string;
|
|
@@ -14,7 +14,7 @@ const relationValidator = (data, staticNodeIds, computedNodeIds) => {
|
|
|
14
14
|
if ("inputs" in nodeData && nodeData && nodeData.inputs) {
|
|
15
15
|
if (Array.isArray(nodeData.inputs)) {
|
|
16
16
|
nodeData.inputs.forEach((inputNodeId) => {
|
|
17
|
-
const sourceNodeId = (0, utils_1.parseNodeName)(inputNodeId, data.version ?? 0.
|
|
17
|
+
const sourceNodeId = (0, utils_1.parseNodeName)(inputNodeId, data.version ?? 0.2).nodeId;
|
|
18
18
|
if (sourceNodeId) {
|
|
19
19
|
if (!nodeIds.has(sourceNodeId)) {
|
|
20
20
|
throw new common_1.ValidationError(`Inputs not match: NodeId ${computedNodeId}, Inputs: ${sourceNodeId}`);
|
|
@@ -47,7 +47,7 @@ const relationValidator = (data, staticNodeIds, computedNodeIds) => {
|
|
|
47
47
|
const nodeData = data.nodes[staticNodeId];
|
|
48
48
|
if ("value" in nodeData && nodeData.update) {
|
|
49
49
|
const update = nodeData.update;
|
|
50
|
-
const updateNodeId = (0, utils_1.parseNodeName)(update, data.version ?? 0.
|
|
50
|
+
const updateNodeId = (0, utils_1.parseNodeName)(update, data.version ?? 0.2).nodeId;
|
|
51
51
|
if (!updateNodeId) {
|
|
52
52
|
throw new common_1.ValidationError("Update it a literal");
|
|
53
53
|
}
|