graphai 0.1.1 → 0.2.0

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.
Files changed (94) hide show
  1. package/README.md +145 -106
  2. package/lib/experimental_agents/array_agents/packages.d.ts +4 -0
  3. package/lib/experimental_agents/array_agents/packages.js +12 -0
  4. package/lib/experimental_agents/array_agents/pop_agent.d.ts +26 -0
  5. package/lib/experimental_agents/array_agents/pop_agent.js +40 -0
  6. package/lib/experimental_agents/array_agents/push_agent.d.ts +16 -0
  7. package/lib/experimental_agents/array_agents/push_agent.js +18 -0
  8. package/lib/experimental_agents/array_agents/shift_agent.d.ts +26 -0
  9. package/lib/experimental_agents/array_agents/shift_agent.js +29 -0
  10. package/lib/experimental_agents/data_agents/data_object_merge_template_agent.d.ts +81 -0
  11. package/lib/experimental_agents/data_agents/data_object_merge_template_agent.js +37 -0
  12. package/lib/experimental_agents/data_agents/data_sum_template_agent.d.ts +1 -0
  13. package/lib/experimental_agents/data_agents/data_sum_template_agent.js +2 -1
  14. package/lib/experimental_agents/data_agents/packages.d.ts +4 -0
  15. package/lib/experimental_agents/data_agents/packages.js +12 -0
  16. package/lib/experimental_agents/data_agents/total_agent.d.ts +1 -0
  17. package/lib/experimental_agents/data_agents/total_agent.js +1 -0
  18. package/lib/experimental_agents/embedding_agent.d.ts +17 -3
  19. package/lib/experimental_agents/embedding_agent.js +13 -1
  20. package/lib/experimental_agents/graph_agents/index.d.ts +2 -0
  21. package/lib/experimental_agents/graph_agents/index.js +7 -0
  22. package/lib/experimental_agents/graph_agents/map_agent.d.ts +20 -0
  23. package/lib/experimental_agents/{map_agent.js → graph_agents/map_agent.js} +31 -10
  24. package/lib/experimental_agents/graph_agents/nested_agent.d.ts +22 -0
  25. package/lib/experimental_agents/graph_agents/nested_agent.js +70 -0
  26. package/lib/experimental_agents/graph_agents/packages.d.ts +3 -0
  27. package/lib/experimental_agents/graph_agents/packages.js +10 -0
  28. package/lib/experimental_agents/index.d.ts +4 -5
  29. package/lib/experimental_agents/index.js +4 -5
  30. package/lib/experimental_agents/matrix_agents/dot_product_agent.d.ts +18 -0
  31. package/lib/experimental_agents/{matrix_agent.js → matrix_agents/dot_product_agent.js} +26 -27
  32. package/lib/experimental_agents/matrix_agents/index.d.ts +2 -0
  33. package/lib/experimental_agents/matrix_agents/index.js +7 -0
  34. package/lib/experimental_agents/matrix_agents/packages.d.ts +3 -0
  35. package/lib/experimental_agents/matrix_agents/packages.js +10 -0
  36. package/lib/experimental_agents/matrix_agents/sort_by_values_agent.d.ts +20 -0
  37. package/lib/experimental_agents/matrix_agents/sort_by_values_agent.js +41 -0
  38. package/lib/experimental_agents/packages.d.ts +11 -0
  39. package/lib/experimental_agents/packages.js +33 -0
  40. package/lib/experimental_agents/slashgpt_agent.d.ts +24 -0
  41. package/lib/experimental_agents/slashgpt_agent.js +12 -0
  42. package/lib/experimental_agents/sleeper_agents/packages.d.ts +3 -0
  43. package/lib/experimental_agents/sleeper_agents/packages.js +10 -0
  44. package/lib/experimental_agents/sleeper_agents/sleeper_agent.d.ts +18 -0
  45. package/lib/experimental_agents/sleeper_agents/sleeper_agent.js +12 -0
  46. package/lib/experimental_agents/sleeper_agents/sleeper_agent_debug.d.ts +20 -0
  47. package/lib/experimental_agents/sleeper_agents/sleeper_agent_debug.js +13 -1
  48. package/lib/experimental_agents/string_agents/packages.d.ts +3 -0
  49. package/lib/experimental_agents/string_agents/packages.js +10 -0
  50. package/lib/experimental_agents/string_agents/string_splitter_agent.d.ts +33 -0
  51. package/lib/experimental_agents/string_agents/string_splitter_agent.js +41 -0
  52. package/lib/experimental_agents/string_agents/string_template_agent.d.ts +24 -0
  53. package/lib/experimental_agents/string_agents/string_template_agent.js +22 -0
  54. package/lib/experimental_agents/test_agents/bypass_agent.d.ts +3 -0
  55. package/lib/experimental_agents/test_agents/bypass_agent.js +24 -0
  56. package/lib/experimental_agents/test_agents/copy2array_agent.d.ts +7 -0
  57. package/lib/experimental_agents/test_agents/copy2array_agent.js +39 -0
  58. package/lib/experimental_agents/test_agents/copy_message_agent.d.ts +9 -1
  59. package/lib/experimental_agents/test_agents/copy_message_agent.js +19 -0
  60. package/lib/experimental_agents/test_agents/counting_agent.d.ts +8 -1
  61. package/lib/experimental_agents/test_agents/counting_agent.js +19 -0
  62. package/lib/experimental_agents/test_agents/echo_agent.d.ts +3 -0
  63. package/lib/experimental_agents/test_agents/echo_agent.js +13 -0
  64. package/lib/experimental_agents/test_agents/index.d.ts +1 -0
  65. package/lib/experimental_agents/test_agents/index.js +3 -1
  66. package/lib/experimental_agents/test_agents/merge_node_id_agent.d.ts +3 -0
  67. package/lib/experimental_agents/test_agents/merge_node_id_agent.js +22 -0
  68. package/lib/experimental_agents/test_agents/packages.d.ts +7 -0
  69. package/lib/experimental_agents/test_agents/packages.js +18 -0
  70. package/lib/experimental_agents/token_agent.d.ts +20 -0
  71. package/lib/experimental_agents/token_agent.js +12 -0
  72. package/lib/graphai.d.ts +1 -1
  73. package/lib/graphai.js +9 -16
  74. package/lib/node.d.ts +2 -2
  75. package/lib/node.js +19 -21
  76. package/lib/transaction_log.js +1 -1
  77. package/lib/type.d.ts +4 -3
  78. package/lib/utils/test_agents.d.ts +2 -0
  79. package/lib/utils/test_agents.js +20 -0
  80. package/lib/utils/test_utils.d.ts +12 -0
  81. package/lib/utils/test_utils.js +34 -0
  82. package/lib/utils/utils.d.ts +3 -1
  83. package/lib/utils/utils.js +30 -2
  84. package/package.json +10 -11
  85. package/lib/experimental_agents/map_agent.d.ts +0 -4
  86. package/lib/experimental_agents/matrix_agent.d.ts +0 -9
  87. package/lib/experimental_agents/nested_agent.d.ts +0 -6
  88. package/lib/experimental_agents/nested_agent.js +0 -30
  89. package/lib/experimental_agents/test_agents/echo_fork_index_agent.d.ts +0 -2
  90. package/lib/experimental_agents/test_agents/echo_fork_index_agent.js +0 -7
  91. package/lib/log.d.ts +0 -22
  92. package/lib/log.js +0 -49
  93. package/lib/task.d.ts +0 -18
  94. package/lib/task.js +0 -63
@@ -14,3 +14,15 @@ const sleeperAgent = async (context) => {
14
14
  }, params.value ?? {});
15
15
  };
16
16
  exports.sleeperAgent = sleeperAgent;
17
+ const sleeperAgentInfo = {
18
+ name: "sleeperAgent",
19
+ agent: exports.sleeperAgent,
20
+ mock: exports.sleeperAgent,
21
+ samples: [],
22
+ description: "sleeper Agent",
23
+ category: [],
24
+ author: "Receptron team",
25
+ repository: "https://github.com/receptron/graphai",
26
+ license: "MIT",
27
+ };
28
+ exports.default = sleeperAgentInfo;
@@ -4,3 +4,23 @@ export declare const sleeperAgentDebug: AgentFunction<{
4
4
  value?: Record<string, any>;
5
5
  fail?: boolean;
6
6
  }>;
7
+ declare const sleeperAgentDebugInfo: {
8
+ name: string;
9
+ agent: AgentFunction<{
10
+ duration: number;
11
+ value?: Record<string, any> | undefined;
12
+ fail?: boolean | undefined;
13
+ }>;
14
+ mock: AgentFunction<{
15
+ duration: number;
16
+ value?: Record<string, any> | undefined;
17
+ fail?: boolean | undefined;
18
+ }>;
19
+ samples: never[];
20
+ description: string;
21
+ category: never[];
22
+ author: string;
23
+ repository: string;
24
+ license: string;
25
+ };
26
+ export default sleeperAgentDebugInfo;
@@ -10,10 +10,22 @@ const sleeperAgentDebug = async ({ params, inputs, debugInfo: { retry }, }) => {
10
10
  await (0, utils_1.sleep)(params.duration / (retry + 1));
11
11
  if (params.fail && retry < 2) {
12
12
  // console.log("failed (intentional)", nodeId, retry);
13
- throw new Error("Intentional Failure");
13
+ throw new Error(utils_1.strIntentionalError);
14
14
  }
15
15
  return inputs.reduce((result, input) => {
16
16
  return (0, deepmerge_1.default)(result, input);
17
17
  }, params.value ?? {});
18
18
  };
19
19
  exports.sleeperAgentDebug = sleeperAgentDebug;
20
+ const sleeperAgentDebugInfo = {
21
+ name: "sleeperAgentDebug",
22
+ agent: exports.sleeperAgentDebug,
23
+ mock: exports.sleeperAgentDebug,
24
+ samples: [],
25
+ description: "sleeper debug Agent",
26
+ category: [],
27
+ author: "Receptron team",
28
+ repository: "https://github.com/receptron/graphai",
29
+ license: "MIT",
30
+ };
31
+ exports.default = sleeperAgentDebugInfo;
@@ -0,0 +1,3 @@
1
+ import stringSplitterAgent from "../../experimental_agents/string_agents/string_splitter_agent";
2
+ import stringTemplateAgent from "../../experimental_agents/string_agents/string_template_agent";
3
+ export { stringSplitterAgent, stringTemplateAgent };
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.stringTemplateAgent = exports.stringSplitterAgent = void 0;
7
+ const string_splitter_agent_1 = __importDefault(require("../../experimental_agents/string_agents/string_splitter_agent"));
8
+ exports.stringSplitterAgent = string_splitter_agent_1.default;
9
+ const string_template_agent_1 = __importDefault(require("../../experimental_agents/string_agents/string_template_agent"));
10
+ exports.stringTemplateAgent = string_template_agent_1.default;
@@ -5,3 +5,36 @@ export declare const stringSplitterAgent: AgentFunction<{
5
5
  }, {
6
6
  contents: Array<string>;
7
7
  }, string>;
8
+ declare const stringSplitterAgentInfo: {
9
+ name: string;
10
+ agent: AgentFunction<{
11
+ chunkSize?: number | undefined;
12
+ overlap?: number | undefined;
13
+ }, {
14
+ contents: Array<string>;
15
+ }, string>;
16
+ mock: AgentFunction<{
17
+ chunkSize?: number | undefined;
18
+ overlap?: number | undefined;
19
+ }, {
20
+ contents: Array<string>;
21
+ }, string>;
22
+ samples: {
23
+ inputs: string[];
24
+ params: {
25
+ chunkSize: number;
26
+ };
27
+ result: {
28
+ contents: string[];
29
+ count: number;
30
+ chunkSize: number;
31
+ overlap: number;
32
+ };
33
+ }[];
34
+ description: string;
35
+ category: never[];
36
+ author: string;
37
+ repository: string;
38
+ license: string;
39
+ };
40
+ export default stringSplitterAgentInfo;
@@ -22,3 +22,44 @@ const stringSplitterAgent = async ({ params, inputs }) => {
22
22
  return { contents, count, chunkSize, overlap };
23
23
  };
24
24
  exports.stringSplitterAgent = stringSplitterAgent;
25
+ // for test and document
26
+ const sampleInput = [
27
+ "Here's to the crazy ones, the misfits, the rebels, the troublemakers, the round pegs in the square holes ... the ones who see things differently -- they're not fond of rules, and they have no respect for the status quo. ... You can quote them, disagree with them, glorify or vilify them, but the only thing you can't do is ignore them because they change things. ... They push the human race forward, and while some may see them as the crazy ones, we see genius, because the people who are crazy enough to think that they can change the world, are the ones who do.",
28
+ ];
29
+ const sampleParams = { chunkSize: 64 };
30
+ const sampleResult = {
31
+ contents: [
32
+ "Here's to the crazy ones, the misfits, the rebels, the troublema",
33
+ "roublemakers, the round pegs in the square holes ... the ones wh",
34
+ " ones who see things differently -- they're not fond of rules, a",
35
+ "rules, and they have no respect for the status quo. ... You can ",
36
+ "You can quote them, disagree with them, glorify or vilify them, ",
37
+ "y them, but the only thing you can't do is ignore them because t",
38
+ "ecause they change things. ... They push the human race forward,",
39
+ "forward, and while some may see them as the crazy ones, we see g",
40
+ "we see genius, because the people who are crazy enough to think ",
41
+ "o think that they can change the world, are the ones who do.",
42
+ " do.",
43
+ ],
44
+ count: 11,
45
+ chunkSize: 64,
46
+ overlap: 8,
47
+ };
48
+ const stringSplitterAgentInfo = {
49
+ name: "stringSplitterAgent",
50
+ agent: exports.stringSplitterAgent,
51
+ mock: exports.stringSplitterAgent,
52
+ samples: [
53
+ {
54
+ inputs: sampleInput,
55
+ params: sampleParams,
56
+ result: sampleResult,
57
+ },
58
+ ],
59
+ description: "This agent strip one long string into chunks using following parameters",
60
+ category: [],
61
+ author: "Satoshi Nakajima",
62
+ repository: "https://github.com/receptron/graphai",
63
+ license: "MIT",
64
+ };
65
+ exports.default = stringSplitterAgentInfo;
@@ -2,3 +2,27 @@ import { AgentFunction } from "../../graphai";
2
2
  export declare const stringTemplateAgent: AgentFunction<{
3
3
  template: string;
4
4
  }, Record<string, any> | string, string>;
5
+ declare const stringTemplateAgentInfo: {
6
+ name: string;
7
+ agent: AgentFunction<{
8
+ template: string;
9
+ }, string | Record<string, any>, string>;
10
+ mock: AgentFunction<{
11
+ template: string;
12
+ }, string | Record<string, any>, string>;
13
+ samples: {
14
+ inputs: string[];
15
+ params: {
16
+ template: string;
17
+ };
18
+ result: {
19
+ content: string;
20
+ };
21
+ }[];
22
+ description: string;
23
+ category: never[];
24
+ author: string;
25
+ repository: string;
26
+ license: string;
27
+ };
28
+ export default stringTemplateAgentInfo;
@@ -10,3 +10,25 @@ const stringTemplateAgent = async ({ params, inputs }) => {
10
10
  return { content };
11
11
  };
12
12
  exports.stringTemplateAgent = stringTemplateAgent;
13
+ const sampleInput = ["hello", "test"];
14
+ const sampleParams = { template: "${0}: ${1}" };
15
+ const sampleResult = { content: "hello: test" };
16
+ // for test and document
17
+ const stringTemplateAgentInfo = {
18
+ name: "stringTemplateAgent",
19
+ agent: exports.stringTemplateAgent,
20
+ mock: exports.stringTemplateAgent,
21
+ samples: [
22
+ {
23
+ inputs: sampleInput,
24
+ params: sampleParams,
25
+ result: sampleResult,
26
+ },
27
+ ],
28
+ description: "Template agent",
29
+ category: [],
30
+ author: "Satoshi Nakajima",
31
+ repository: "https://github.com/receptron/graphai",
32
+ license: "MIT",
33
+ };
34
+ exports.default = stringTemplateAgentInfo;
@@ -1,2 +1,5 @@
1
1
  import { AgentFunction } from "../../graphai";
2
+ import { AgentFunctionInfo } from "../../type";
2
3
  export declare const bypassAgent: AgentFunction;
4
+ declare const bypassAgentInfo: AgentFunctionInfo;
5
+ export default bypassAgentInfo;
@@ -8,3 +8,27 @@ const bypassAgent = async (context) => {
8
8
  return context.inputs;
9
9
  };
10
10
  exports.bypassAgent = bypassAgent;
11
+ // for test and document
12
+ const bypassAgentInfo = {
13
+ name: "bypassAgent",
14
+ agent: exports.bypassAgent,
15
+ mock: exports.bypassAgent,
16
+ samples: [
17
+ {
18
+ inputs: [{ a: "123" }],
19
+ params: {},
20
+ result: { a: "123" },
21
+ },
22
+ {
23
+ inputs: [{ a: "123" }, { b: "abc" }],
24
+ params: {},
25
+ result: [{ a: "123" }, { b: "abc" }],
26
+ },
27
+ ],
28
+ description: "bypass agent",
29
+ category: [],
30
+ author: "Receptron team",
31
+ repository: "https://github.com/receptron/graphai",
32
+ license: "MIT",
33
+ };
34
+ exports.default = bypassAgentInfo;
@@ -0,0 +1,7 @@
1
+ import { AgentFunction } from "../../graphai";
2
+ import { AgentFunctionInfo } from "../../type";
3
+ export declare const copy2ArrayAgent: AgentFunction<{
4
+ count: number;
5
+ }>;
6
+ declare const copy2ArrayAgentInfo: AgentFunctionInfo;
7
+ export default copy2ArrayAgentInfo;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.copy2ArrayAgent = void 0;
4
+ const copy2ArrayAgent = async ({ inputs, params }) => {
5
+ return new Array(params.count).fill(undefined).map(() => {
6
+ return inputs[0];
7
+ });
8
+ };
9
+ exports.copy2ArrayAgent = copy2ArrayAgent;
10
+ // for test and document
11
+ const copy2ArrayAgentInfo = {
12
+ name: "copy2ArrayAgent",
13
+ agent: exports.copy2ArrayAgent,
14
+ mock: exports.copy2ArrayAgent,
15
+ samples: [
16
+ {
17
+ inputs: [{ message: "hello" }],
18
+ params: { count: 10 },
19
+ result: [
20
+ { message: "hello" },
21
+ { message: "hello" },
22
+ { message: "hello" },
23
+ { message: "hello" },
24
+ { message: "hello" },
25
+ { message: "hello" },
26
+ { message: "hello" },
27
+ { message: "hello" },
28
+ { message: "hello" },
29
+ { message: "hello" },
30
+ ],
31
+ },
32
+ ],
33
+ description: "Copy2Array agent",
34
+ category: [],
35
+ author: "Receptron team",
36
+ repository: "https://github.com/receptron/graphai",
37
+ license: "MIT",
38
+ };
39
+ exports.default = copy2ArrayAgentInfo;
@@ -1,2 +1,10 @@
1
1
  import { AgentFunction } from "../../graphai";
2
- export declare const copyMessageAgent: AgentFunction;
2
+ import { AgentFunctionInfo } from "../../type";
3
+ export declare const copyMessageAgent: AgentFunction<{
4
+ count: number;
5
+ message: string;
6
+ }, {
7
+ messages: string[];
8
+ }>;
9
+ declare const copyMessageAgentInfo: AgentFunctionInfo;
10
+ export default copyMessageAgentInfo;
@@ -9,3 +9,22 @@ const copyMessageAgent = async ({ params }) => {
9
9
  };
10
10
  };
11
11
  exports.copyMessageAgent = copyMessageAgent;
12
+ // for test and document
13
+ const copyMessageAgentInfo = {
14
+ name: "copyMessageAgent",
15
+ agent: exports.copyMessageAgent,
16
+ mock: exports.copyMessageAgent,
17
+ samples: [
18
+ {
19
+ inputs: [],
20
+ params: { count: 4, message: "hello" },
21
+ result: { messages: ["hello", "hello", "hello", "hello"] },
22
+ },
23
+ ],
24
+ description: "CopyMessage agent",
25
+ category: [],
26
+ author: "Receptron team",
27
+ repository: "https://github.com/receptron/graphai",
28
+ license: "MIT",
29
+ };
30
+ exports.default = copyMessageAgentInfo;
@@ -1,2 +1,9 @@
1
1
  import { AgentFunction } from "../../graphai";
2
- export declare const countingAgent: AgentFunction;
2
+ import { AgentFunctionInfo } from "../../type";
3
+ export declare const countingAgent: AgentFunction<{
4
+ count: number;
5
+ }, {
6
+ list: number[];
7
+ }>;
8
+ declare const countingAgentInfo: AgentFunctionInfo;
9
+ export default countingAgentInfo;
@@ -9,3 +9,22 @@ const countingAgent = async ({ params }) => {
9
9
  };
10
10
  };
11
11
  exports.countingAgent = countingAgent;
12
+ // for test and document
13
+ const countingAgentInfo = {
14
+ name: "countingAgent",
15
+ agent: exports.countingAgent,
16
+ mock: exports.countingAgent,
17
+ samples: [
18
+ {
19
+ inputs: [],
20
+ params: { count: 4 },
21
+ result: { list: [0, 1, 2, 3] },
22
+ },
23
+ ],
24
+ description: "Counting agent",
25
+ category: [],
26
+ author: "Receptron team",
27
+ repository: "https://github.com/receptron/graphai",
28
+ license: "MIT",
29
+ };
30
+ exports.default = countingAgentInfo;
@@ -1,2 +1,5 @@
1
1
  import { AgentFunction } from "../../graphai";
2
+ import { AgentFunctionInfo } from "../../type";
2
3
  export declare const echoAgent: AgentFunction;
4
+ declare const echoAgentInfo: AgentFunctionInfo;
5
+ export default echoAgentInfo;
@@ -5,3 +5,16 @@ const echoAgent = async ({ params }) => {
5
5
  return params;
6
6
  };
7
7
  exports.echoAgent = echoAgent;
8
+ // for test and document
9
+ const echoAgentInfo = {
10
+ name: "echoAgent",
11
+ agent: exports.echoAgent,
12
+ mock: exports.echoAgent,
13
+ samples: [],
14
+ description: "Echo agent",
15
+ category: [],
16
+ author: "Satoshi Nakajima",
17
+ repository: "https://github.com/receptron/graphai",
18
+ license: "MIT",
19
+ };
20
+ exports.default = echoAgentInfo;
@@ -3,3 +3,4 @@ export { echoAgent } from "../../experimental_agents/test_agents/echo_agent";
3
3
  export { copyMessageAgent } from "../../experimental_agents/test_agents/copy_message_agent";
4
4
  export { mergeNodeIdAgent } from "../../experimental_agents/test_agents/merge_node_id_agent";
5
5
  export { countingAgent } from "../../experimental_agents/test_agents/counting_agent";
6
+ export { copy2ArrayAgent } from "../../experimental_agents/test_agents/copy2array_agent";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.countingAgent = exports.mergeNodeIdAgent = exports.copyMessageAgent = exports.echoAgent = exports.bypassAgent = void 0;
3
+ exports.copy2ArrayAgent = exports.countingAgent = exports.mergeNodeIdAgent = exports.copyMessageAgent = exports.echoAgent = exports.bypassAgent = void 0;
4
4
  var bypass_agent_1 = require("../../experimental_agents/test_agents/bypass_agent");
5
5
  Object.defineProperty(exports, "bypassAgent", { enumerable: true, get: function () { return bypass_agent_1.bypassAgent; } });
6
6
  var echo_agent_1 = require("../../experimental_agents/test_agents/echo_agent");
@@ -11,3 +11,5 @@ var merge_node_id_agent_1 = require("../../experimental_agents/test_agents/merge
11
11
  Object.defineProperty(exports, "mergeNodeIdAgent", { enumerable: true, get: function () { return merge_node_id_agent_1.mergeNodeIdAgent; } });
12
12
  var counting_agent_1 = require("../../experimental_agents/test_agents/counting_agent");
13
13
  Object.defineProperty(exports, "countingAgent", { enumerable: true, get: function () { return counting_agent_1.countingAgent; } });
14
+ var copy2array_agent_1 = require("../../experimental_agents/test_agents/copy2array_agent");
15
+ Object.defineProperty(exports, "copy2ArrayAgent", { enumerable: true, get: function () { return copy2array_agent_1.copy2ArrayAgent; } });
@@ -1,2 +1,5 @@
1
1
  import { AgentFunction } from "../../graphai";
2
+ import { AgentFunctionInfo } from "../../type";
2
3
  export declare const mergeNodeIdAgent: AgentFunction;
4
+ declare const mergeNodeIdAgentInfo: AgentFunctionInfo;
5
+ export default mergeNodeIdAgentInfo;
@@ -8,3 +8,25 @@ const mergeNodeIdAgent = async ({ debugInfo: { nodeId }, inputs }) => {
8
8
  }, { [nodeId]: "hello" });
9
9
  };
10
10
  exports.mergeNodeIdAgent = mergeNodeIdAgent;
11
+ // for test and document
12
+ const mergeNodeIdAgentInfo = {
13
+ name: "mergeNodeIdAgent",
14
+ agent: exports.mergeNodeIdAgent,
15
+ mock: exports.mergeNodeIdAgent,
16
+ samples: [
17
+ {
18
+ inputs: [{ message: "hello" }],
19
+ params: {},
20
+ result: {
21
+ message: "hello",
22
+ test: "hello",
23
+ },
24
+ },
25
+ ],
26
+ description: "merge node id agent",
27
+ category: [],
28
+ author: "Receptron team",
29
+ repository: "https://github.com/receptron/graphai",
30
+ license: "MIT",
31
+ };
32
+ exports.default = mergeNodeIdAgentInfo;
@@ -0,0 +1,7 @@
1
+ import echoAgent from "../../experimental_agents/test_agents/echo_agent";
2
+ import bypassAgent from "../../experimental_agents/test_agents/bypass_agent";
3
+ import countingAgent from "../../experimental_agents/test_agents/counting_agent";
4
+ import copyMessageAgent from "../../experimental_agents/test_agents/copy_message_agent";
5
+ import copy2ArrayAgent from "../../experimental_agents/test_agents/copy2array_agent";
6
+ import mergeNodeIdAgent from "../../experimental_agents/test_agents/merge_node_id_agent";
7
+ export { echoAgent, bypassAgent, countingAgent, copyMessageAgent, copy2ArrayAgent, mergeNodeIdAgent };
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.mergeNodeIdAgent = exports.copy2ArrayAgent = exports.copyMessageAgent = exports.countingAgent = exports.bypassAgent = exports.echoAgent = void 0;
7
+ const echo_agent_1 = __importDefault(require("../../experimental_agents/test_agents/echo_agent"));
8
+ exports.echoAgent = echo_agent_1.default;
9
+ const bypass_agent_1 = __importDefault(require("../../experimental_agents/test_agents/bypass_agent"));
10
+ exports.bypassAgent = bypass_agent_1.default;
11
+ const counting_agent_1 = __importDefault(require("../../experimental_agents/test_agents/counting_agent"));
12
+ exports.countingAgent = counting_agent_1.default;
13
+ const copy_message_agent_1 = __importDefault(require("../../experimental_agents/test_agents/copy_message_agent"));
14
+ exports.copyMessageAgent = copy_message_agent_1.default;
15
+ const copy2array_agent_1 = __importDefault(require("../../experimental_agents/test_agents/copy2array_agent"));
16
+ exports.copy2ArrayAgent = copy2array_agent_1.default;
17
+ const merge_node_id_agent_1 = __importDefault(require("../../experimental_agents/test_agents/merge_node_id_agent"));
18
+ exports.mergeNodeIdAgent = merge_node_id_agent_1.default;
@@ -4,3 +4,23 @@ export declare const tokenBoundStringsAgent: AgentFunction<{
4
4
  }, {
5
5
  content: string;
6
6
  }, Array<string>>;
7
+ declare const tokenBoundStringsAgentInfo: {
8
+ name: string;
9
+ agent: AgentFunction<{
10
+ limit?: number | undefined;
11
+ }, {
12
+ content: string;
13
+ }, string[]>;
14
+ mock: AgentFunction<{
15
+ limit?: number | undefined;
16
+ }, {
17
+ content: string;
18
+ }, string[]>;
19
+ samples: never[];
20
+ description: string;
21
+ category: never[];
22
+ author: string;
23
+ repository: string;
24
+ license: string;
25
+ };
26
+ export default tokenBoundStringsAgentInfo;
@@ -31,3 +31,15 @@ const tokenBoundStringsAgent = async ({ params, inputs }) => {
31
31
  return { content, tokenCount, endIndex };
32
32
  };
33
33
  exports.tokenBoundStringsAgent = tokenBoundStringsAgent;
34
+ const tokenBoundStringsAgentInfo = {
35
+ name: "tokenBoundStringsAgent",
36
+ agent: exports.tokenBoundStringsAgent,
37
+ mock: exports.tokenBoundStringsAgent,
38
+ samples: [],
39
+ description: "token bound Agent",
40
+ category: [],
41
+ author: "Receptron team",
42
+ repository: "https://github.com/receptron/graphai",
43
+ license: "MIT",
44
+ };
45
+ exports.default = tokenBoundStringsAgentInfo;
package/lib/graphai.d.ts CHANGED
@@ -37,5 +37,5 @@ export declare class GraphAI {
37
37
  updateLog(log: TransactionLog): void;
38
38
  transactionLogs(): TransactionLog[];
39
39
  injectValue(nodeId: string, value: ResultData, injectFrom?: string): void;
40
- resultsOf(sources: Array<DataSource>, anyInput?: boolean): any[];
40
+ resultsOf(sources: Array<DataSource>): ResultData[];
41
41
  }
package/lib/graphai.js CHANGED
@@ -1,7 +1,4 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.GraphAI = void 0;
7
4
  const type_1 = require("./type");
@@ -9,7 +6,6 @@ const node_1 = require("./node");
9
6
  const utils_1 = require("./utils/utils");
10
7
  const validator_1 = require("./validator");
11
8
  const task_manager_1 = require("./task_manager");
12
- const crypto_1 = __importDefault(require("crypto"));
13
9
  const defaultConcurrency = 8;
14
10
  class GraphAI {
15
11
  // This method is called when either the GraphAI obect was created,
@@ -44,8 +40,7 @@ class GraphAI {
44
40
  }
45
41
  getValueFromResults(key, results) {
46
42
  const source = (0, utils_1.parseNodeName)(key);
47
- const result = results[source.nodeId];
48
- return result && source.propId ? result[source.propId] : result;
43
+ return (0, utils_1.getDataFromSource)(results[source.nodeId], source.propIds);
49
44
  }
50
45
  // for static
51
46
  initializeNodes(previousResults) {
@@ -73,7 +68,7 @@ class GraphAI {
73
68
  this.logs = [];
74
69
  this.onLogCallback = (__log, __isUpdate) => { };
75
70
  this.repeatCount = 0;
76
- this.graphId = crypto_1.default.randomUUID();
71
+ this.graphId = URL.createObjectURL(new Blob()).slice(-36);
77
72
  this.data = data;
78
73
  this.callbackDictonary = callbackDictonary;
79
74
  this.taskManager = taskManager ?? new task_manager_1.TaskManager(data.concurrency ?? defaultConcurrency);
@@ -100,10 +95,7 @@ class GraphAI {
100
95
  // Public API
101
96
  results(all) {
102
97
  return Object.keys(this.nodes)
103
- .filter((nodeId) => {
104
- const node = this.nodes[nodeId];
105
- return all || node.isResult;
106
- })
98
+ .filter((nodeId) => all || this.nodes[nodeId].isResult)
107
99
  .reduce((results, nodeId) => {
108
100
  const node = this.nodes[nodeId];
109
101
  if (node.result !== undefined) {
@@ -157,6 +149,10 @@ class GraphAI {
157
149
  console.error("-- Already Running");
158
150
  }
159
151
  this.pushReadyNodesIntoQueue();
152
+ if (!this.isRunning()) {
153
+ console.warn("-- nothing to execute");
154
+ return {};
155
+ }
160
156
  return new Promise((resolve, reject) => {
161
157
  this.onComplete = () => {
162
158
  const errors = this.errors();
@@ -231,13 +227,10 @@ class GraphAI {
231
227
  console.error("InjectionTo can only specify static nodes");
232
228
  }
233
229
  }
234
- resultsOf(sources, anyInput = false) {
230
+ resultsOf(sources) {
235
231
  return sources.map((source) => {
236
232
  const { result } = this.nodes[source.nodeId];
237
- if (source.propId) {
238
- (0, utils_1.assert)((0, utils_1.isObject)(result), `resultsOf: result is not object. nodeId ${source.nodeId}`, anyInput);
239
- }
240
- return result && source.propId ? result[source.propId] : result;
233
+ return (0, utils_1.getDataFromSource)(result, source.propIds);
241
234
  });
242
235
  }
243
236
  }
package/lib/node.d.ts CHANGED
@@ -23,15 +23,15 @@ export declare class ComputedNode extends Node {
23
23
  readonly timeout?: number;
24
24
  error?: Error;
25
25
  transactionId: undefined | number;
26
- sources: Record<string, DataSource>;
27
26
  readonly anyInput: boolean;
28
- inputs: Array<string>;
27
+ dataSources: Array<DataSource>;
29
28
  pendings: Set<string>;
30
29
  readonly isStaticNode = false;
31
30
  readonly isComputedNode = true;
32
31
  constructor(graphId: string, nodeId: string, data: ComputedNodeData, graph: GraphAI);
33
32
  isReadyNode(): boolean;
34
33
  private retry;
34
+ private checkDataAvailability;
35
35
  removePending(nodeId: string): void;
36
36
  private isCurrentTransaction;
37
37
  private executeTimeout;