graphai 0.5.0 → 0.5.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/README.md CHANGED
@@ -190,12 +190,14 @@ nodes:
190
190
  inputs: [":source"] // == "sourceNode.query"
191
191
  database:
192
192
  agent: "nestedAgent"
193
- inputs: [":question", ":projectId"]
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: [":$1"]
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: [":people"]
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: [":$0"]
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
@@ -103,6 +103,7 @@ class GraphAI {
103
103
  agent: async () => {
104
104
  return null;
105
105
  },
106
+ inputs: null,
106
107
  };
107
108
  }
108
109
  // We are not supposed to hit this error because the validator will catch it.
package/lib/index.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  export { GraphAI } from "./graphai";
2
- export { AgentFunction, AgentFunctionInfo, AgentFunctionInfoDictionary, AgentFunctionContext, GraphData, ResultDataDictionary, ResultData, NodeState, AgentFilterFunction, AgentFilterInfo, NodeData, StaticNodeData, ComputedNodeData, DefaultResultData, DefaultInputData, } from "./type";
2
+ export { AgentFunction, AgentFunctionInfo, AgentFunctionInfoDictionary, AgentFunctionInfoSample, AgentFunctionContext, GraphData, ResultDataDictionary, ResultData, NodeState, AgentFilterFunction, AgentFilterInfo, NodeData, StaticNodeData, ComputedNodeData, DefaultResultData, DefaultInputData, } from "./type";
3
3
  export type { TransactionLog } from "./transaction_log";
4
- export { agentFilterRunnerBuilder } from "./utils/runner";
5
4
  export { defaultAgentInfo, agentInfoWrapper, defaultTestContext, strIntentionalError, assert, sleep } from "./utils/utils";
6
5
  export { ValidationError } from "./validators/common";
package/lib/index.js CHANGED
@@ -1,12 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ValidationError = exports.sleep = exports.assert = exports.strIntentionalError = exports.defaultTestContext = exports.agentInfoWrapper = exports.defaultAgentInfo = exports.agentFilterRunnerBuilder = exports.NodeState = exports.GraphAI = void 0;
3
+ exports.ValidationError = exports.sleep = exports.assert = exports.strIntentionalError = exports.defaultTestContext = exports.agentInfoWrapper = exports.defaultAgentInfo = exports.NodeState = exports.GraphAI = void 0;
4
4
  var graphai_1 = require("./graphai");
5
5
  Object.defineProperty(exports, "GraphAI", { enumerable: true, get: function () { return graphai_1.GraphAI; } });
6
6
  var type_1 = require("./type");
7
7
  Object.defineProperty(exports, "NodeState", { enumerable: true, get: function () { return type_1.NodeState; } });
8
- var runner_1 = require("./utils/runner");
9
- Object.defineProperty(exports, "agentFilterRunnerBuilder", { enumerable: true, get: function () { return runner_1.agentFilterRunnerBuilder; } });
10
8
  var utils_1 = require("./utils/utils");
11
9
  Object.defineProperty(exports, "defaultAgentInfo", { enumerable: true, get: function () { return utils_1.defaultAgentInfo; } });
12
10
  Object.defineProperty(exports, "agentInfoWrapper", { enumerable: true, get: function () { return utils_1.agentInfoWrapper; } });
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
@@ -4,6 +4,7 @@ export declare enum NodeState {
4
4
  Waiting = "waiting",
5
5
  Queued = "queued",
6
6
  Executing = "executing",
7
+ ExecutingServer = "executing-server",
7
8
  Failed = "failed",
8
9
  TimedOut = "timed-out",
9
10
  Completed = "completed",
@@ -61,25 +62,27 @@ export type GraphOptions = {
61
62
  taskManager?: TaskManager | undefined;
62
63
  bypassAgentIds?: string[] | undefined;
63
64
  };
64
- export type AgentFunctionContext<ParamsType = DefaultParamsType, InputDataType = DefaultInputData> = {
65
+ export type AgentFunctionContext<ParamsType = DefaultParamsType, InputDataType = DefaultInputData, NamedInputDataType = DefaultInputData> = {
65
66
  params: NodeDataParams<ParamsType>;
66
67
  inputs: Array<InputDataType>;
67
- namedInputs: Record<string, any>;
68
+ inputSchema?: any;
69
+ namedInputs: NamedInputDataType;
68
70
  debugInfo: {
69
71
  verbose: boolean;
70
72
  nodeId: string;
71
73
  retry: number;
72
74
  agentId?: string;
75
+ version?: number;
73
76
  };
74
- graphData?: GraphData | string;
77
+ graphData?: GraphData;
75
78
  agents?: AgentFunctionInfoDictionary;
76
79
  taskManager?: TaskManager;
77
80
  filterParams: AgentFilterParams;
78
81
  agentFilters?: AgentFilterInfo[];
79
82
  log?: TransactionLog[];
80
83
  };
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>>;
84
+ export type AgentFunction<ParamsType = DefaultParamsType, ResultType = DefaultResultData, InputDataType = DefaultInputData, NamedInputDataType = DefaultInputData> = (context: AgentFunctionContext<ParamsType, InputDataType, NamedInputDataType>) => Promise<ResultData<ResultType>>;
85
+ export type AgentFilterFunction<ParamsType = DefaultParamsType, ResultType = DefaultResultData, InputDataType = DefaultInputData, NamedInputDataType = DefaultInputData> = (context: AgentFunctionContext<ParamsType, InputDataType, NamedInputDataType>, agent: AgentFunction) => Promise<ResultData<ResultType>>;
83
86
  export type AgentFilterInfo = {
84
87
  name: string;
85
88
  agent: AgentFilterFunction;
@@ -87,19 +90,19 @@ export type AgentFilterInfo = {
87
90
  nodeIds?: string[];
88
91
  filterParams?: AgentFilterParams;
89
92
  };
93
+ export type AgentFunctionInfoSample = {
94
+ inputs: any;
95
+ params: DefaultParamsType;
96
+ result: any;
97
+ graph?: GraphData;
98
+ };
90
99
  export type AgentFunctionInfo = {
91
100
  name: string;
92
- agent: AgentFunction<any, any, any>;
93
- mock: AgentFunction<any, any, any>;
101
+ agent: AgentFunction<any, any, any, any>;
102
+ mock: AgentFunction<any, any, any, any>;
94
103
  inputs?: any;
95
104
  output?: any;
96
- samples: {
97
- inputs: any;
98
- params: DefaultParamsType;
99
- result: any;
100
- graph?: GraphData;
101
- }[];
102
- skipTest?: boolean;
105
+ samples: AgentFunctionInfoSample[];
103
106
  description: string;
104
107
  category: string[];
105
108
  author: string;
package/lib/type.js CHANGED
@@ -6,6 +6,7 @@ var NodeState;
6
6
  NodeState["Waiting"] = "waiting";
7
7
  NodeState["Queued"] = "queued";
8
8
  NodeState["Executing"] = "executing";
9
+ NodeState["ExecutingServer"] = "executing-server";
9
10
  NodeState["Failed"] = "failed";
10
11
  NodeState["TimedOut"] = "timed-out";
11
12
  NodeState["Completed"] = "completed";
@@ -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.02).nodeId;
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.02).nodeId;
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "graphai",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "description": "Asynchronous data flow execution engine for agentic AI apps.",
5
5
  "main": "lib/index.js",
6
6
  "files": [
@@ -1,2 +0,0 @@
1
- import { AgentFunctionContext, AgentFunction, AgentFilterInfo, ResultData } from "../type";
2
- export declare const agentFilterRunnerBuilder: (__agentFilters: AgentFilterInfo[]) => (context: AgentFunctionContext, agent: AgentFunction) => Promise<ResultData>;
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.agentFilterRunnerBuilder = void 0;
4
- // for test and server.
5
- const agentFilterRunnerBuilder = (__agentFilters) => {
6
- const agentFilters = __agentFilters;
7
- const agentFilterRunner = (context, agent) => {
8
- let index = 0;
9
- const next = (context) => {
10
- const agentFilter = agentFilters[index++];
11
- if (agentFilter) {
12
- return agentFilter.agent(context, next);
13
- }
14
- return agent(context);
15
- };
16
- return next(context);
17
- };
18
- return agentFilterRunner;
19
- };
20
- exports.agentFilterRunnerBuilder = agentFilterRunnerBuilder;