graphai 0.1.2 → 0.2.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.
Files changed (95) hide show
  1. package/README.md +107 -78
  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 +27 -1
  5. package/lib/experimental_agents/array_agents/pop_agent.js +41 -6
  6. package/lib/experimental_agents/array_agents/push_agent.d.ts +17 -1
  7. package/lib/experimental_agents/array_agents/push_agent.js +20 -7
  8. package/lib/experimental_agents/array_agents/shift_agent.d.ts +27 -1
  9. package/lib/experimental_agents/array_agents/shift_agent.js +30 -6
  10. package/lib/experimental_agents/data_agents/data_object_merge_template_agent.d.ts +57 -2
  11. package/lib/experimental_agents/data_agents/data_object_merge_template_agent.js +13 -1
  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 +1 -0
  14. package/lib/experimental_agents/data_agents/index.d.ts +1 -0
  15. package/lib/experimental_agents/data_agents/index.js +3 -1
  16. package/lib/experimental_agents/data_agents/packages.d.ts +5 -0
  17. package/lib/experimental_agents/data_agents/packages.js +14 -0
  18. package/lib/experimental_agents/data_agents/property_filter_agent.d.ts +61 -0
  19. package/lib/experimental_agents/data_agents/property_filter_agent.js +40 -0
  20. package/lib/experimental_agents/data_agents/total_agent.d.ts +1 -0
  21. package/lib/experimental_agents/data_agents/total_agent.js +1 -0
  22. package/lib/experimental_agents/embedding_agent.d.ts +17 -3
  23. package/lib/experimental_agents/embedding_agent.js +13 -1
  24. package/lib/experimental_agents/function_agent.d.ts +42 -0
  25. package/lib/experimental_agents/function_agent.js +40 -0
  26. package/lib/experimental_agents/graph_agents/index.d.ts +2 -0
  27. package/lib/experimental_agents/graph_agents/index.js +7 -0
  28. package/lib/experimental_agents/graph_agents/map_agent.d.ts +20 -0
  29. package/lib/experimental_agents/{map_agent.js → graph_agents/map_agent.js} +31 -10
  30. package/lib/experimental_agents/graph_agents/nested_agent.d.ts +22 -0
  31. package/lib/experimental_agents/graph_agents/nested_agent.js +70 -0
  32. package/lib/experimental_agents/graph_agents/packages.d.ts +3 -0
  33. package/lib/experimental_agents/graph_agents/packages.js +10 -0
  34. package/lib/experimental_agents/index.d.ts +5 -5
  35. package/lib/experimental_agents/index.js +5 -5
  36. package/lib/experimental_agents/llm_agents/groq_agent.d.ts +26 -0
  37. package/lib/experimental_agents/llm_agents/groq_agent.js +39 -0
  38. package/lib/experimental_agents/llm_agents/index.d.ts +2 -0
  39. package/lib/experimental_agents/llm_agents/index.js +18 -0
  40. package/lib/experimental_agents/llm_agents/packages.d.ts +3 -0
  41. package/lib/experimental_agents/llm_agents/packages.js +10 -0
  42. package/lib/experimental_agents/llm_agents/slashgpt_agent.d.ts +27 -0
  43. package/lib/experimental_agents/{slashgpt_agent.js → llm_agents/slashgpt_agent.js} +13 -10
  44. package/lib/experimental_agents/matrix_agents/dot_product_agent.d.ts +17 -3
  45. package/lib/experimental_agents/matrix_agents/dot_product_agent.js +26 -1
  46. package/lib/experimental_agents/matrix_agents/packages.d.ts +3 -0
  47. package/lib/experimental_agents/matrix_agents/packages.js +10 -0
  48. package/lib/experimental_agents/matrix_agents/sort_by_values_agent.d.ts +17 -3
  49. package/lib/experimental_agents/matrix_agents/sort_by_values_agent.js +13 -1
  50. package/lib/experimental_agents/packages.d.ts +12 -0
  51. package/lib/experimental_agents/packages.js +34 -0
  52. package/lib/experimental_agents/sleeper_agents/packages.d.ts +3 -0
  53. package/lib/experimental_agents/sleeper_agents/packages.js +10 -0
  54. package/lib/experimental_agents/sleeper_agents/sleeper_agent.d.ts +18 -0
  55. package/lib/experimental_agents/sleeper_agents/sleeper_agent.js +12 -0
  56. package/lib/experimental_agents/sleeper_agents/sleeper_agent_debug.d.ts +20 -0
  57. package/lib/experimental_agents/sleeper_agents/sleeper_agent_debug.js +13 -1
  58. package/lib/experimental_agents/string_agents/packages.d.ts +3 -0
  59. package/lib/experimental_agents/string_agents/packages.js +10 -0
  60. package/lib/experimental_agents/string_agents/string_splitter_agent.d.ts +1 -0
  61. package/lib/experimental_agents/string_agents/string_splitter_agent.js +1 -0
  62. package/lib/experimental_agents/string_agents/string_template_agent.d.ts +5 -6
  63. package/lib/experimental_agents/string_agents/string_template_agent.js +3 -2
  64. package/lib/experimental_agents/test_agents/bypass_agent.d.ts +7 -1
  65. package/lib/experimental_agents/test_agents/bypass_agent.js +53 -4
  66. package/lib/experimental_agents/test_agents/copy2array_agent.d.ts +6 -1
  67. package/lib/experimental_agents/test_agents/copy2array_agent.js +32 -2
  68. package/lib/experimental_agents/test_agents/copy_message_agent.d.ts +9 -1
  69. package/lib/experimental_agents/test_agents/copy_message_agent.js +19 -0
  70. package/lib/experimental_agents/test_agents/counting_agent.d.ts +8 -1
  71. package/lib/experimental_agents/test_agents/counting_agent.js +19 -0
  72. package/lib/experimental_agents/test_agents/echo_agent.d.ts +3 -0
  73. package/lib/experimental_agents/test_agents/echo_agent.js +13 -0
  74. package/lib/experimental_agents/test_agents/merge_node_id_agent.d.ts +3 -0
  75. package/lib/experimental_agents/test_agents/merge_node_id_agent.js +22 -0
  76. package/lib/experimental_agents/test_agents/packages.d.ts +7 -0
  77. package/lib/experimental_agents/test_agents/packages.js +18 -0
  78. package/lib/experimental_agents/token_agent.d.ts +20 -0
  79. package/lib/experimental_agents/token_agent.js +12 -0
  80. package/lib/graphai.d.ts +2 -1
  81. package/lib/graphai.js +13 -12
  82. package/lib/node.d.ts +1 -0
  83. package/lib/node.js +18 -11
  84. package/lib/transaction_log.js +1 -1
  85. package/lib/type.d.ts +8 -5
  86. package/lib/utils/test_agents.js +1 -0
  87. package/lib/utils/test_utils.js +15 -10
  88. package/lib/utils/utils.d.ts +4 -2
  89. package/lib/utils/utils.js +47 -5
  90. package/lib/validators/relation_validator.js +11 -6
  91. package/package.json +4 -2
  92. package/lib/experimental_agents/map_agent.d.ts +0 -4
  93. package/lib/experimental_agents/nested_agent.d.ts +0 -5
  94. package/lib/experimental_agents/nested_agent.js +0 -40
  95. package/lib/experimental_agents/slashgpt_agent.d.ts +0 -9
@@ -0,0 +1,5 @@
1
+ import totalAgent from "../../experimental_agents/data_agents/total_agent";
2
+ import dataObjectMergeTemplateAgent from "../../experimental_agents/data_agents/data_object_merge_template_agent";
3
+ import dataSumTemplateAgent from "../../experimental_agents/data_agents/data_sum_template_agent";
4
+ import propertyFilterAgent from "../../experimental_agents/data_agents/property_filter_agent";
5
+ export { totalAgent, dataObjectMergeTemplateAgent, dataSumTemplateAgent, propertyFilterAgent };
@@ -0,0 +1,14 @@
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.propertyFilterAgent = exports.dataSumTemplateAgent = exports.dataObjectMergeTemplateAgent = exports.totalAgent = void 0;
7
+ const total_agent_1 = __importDefault(require("../../experimental_agents/data_agents/total_agent"));
8
+ exports.totalAgent = total_agent_1.default;
9
+ const data_object_merge_template_agent_1 = __importDefault(require("../../experimental_agents/data_agents/data_object_merge_template_agent"));
10
+ exports.dataObjectMergeTemplateAgent = data_object_merge_template_agent_1.default;
11
+ const data_sum_template_agent_1 = __importDefault(require("../../experimental_agents/data_agents/data_sum_template_agent"));
12
+ exports.dataSumTemplateAgent = data_sum_template_agent_1.default;
13
+ const property_filter_agent_1 = __importDefault(require("../../experimental_agents/data_agents/property_filter_agent"));
14
+ exports.propertyFilterAgent = property_filter_agent_1.default;
@@ -0,0 +1,61 @@
1
+ import { AgentFunction } from "../../graphai";
2
+ export declare const propertyFilterAgent: AgentFunction<{
3
+ include?: Array<string>;
4
+ exclude?: Array<string>;
5
+ }>;
6
+ declare const propertyFilterAgentInfo: {
7
+ name: string;
8
+ agent: AgentFunction<{
9
+ include?: string[] | undefined;
10
+ exclude?: string[] | undefined;
11
+ }>;
12
+ mock: AgentFunction<{
13
+ include?: string[] | undefined;
14
+ exclude?: string[] | undefined;
15
+ }>;
16
+ samples: ({
17
+ inputs: {
18
+ color: string;
19
+ model: string;
20
+ type: string;
21
+ maker: string;
22
+ range: number;
23
+ }[];
24
+ params: {
25
+ include: string[];
26
+ exclude?: undefined;
27
+ };
28
+ result: {
29
+ color: string;
30
+ model: string;
31
+ type?: undefined;
32
+ maker?: undefined;
33
+ range?: undefined;
34
+ };
35
+ } | {
36
+ inputs: {
37
+ color: string;
38
+ model: string;
39
+ type: string;
40
+ maker: string;
41
+ range: number;
42
+ }[];
43
+ params: {
44
+ exclude: string[];
45
+ include?: undefined;
46
+ };
47
+ result: {
48
+ type: string;
49
+ maker: string;
50
+ range: number;
51
+ color?: undefined;
52
+ model?: undefined;
53
+ };
54
+ })[];
55
+ description: string;
56
+ category: string[];
57
+ author: string;
58
+ repository: string;
59
+ license: string;
60
+ };
61
+ export default propertyFilterAgentInfo;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.propertyFilterAgent = void 0;
4
+ const propertyFilterAgent = async ({ inputs, params }) => {
5
+ const [input] = inputs;
6
+ const { include, exclude } = params;
7
+ const propIds = include ? include : Object.keys(input);
8
+ const excludeSet = new Set(exclude ?? []);
9
+ return propIds.reduce((tmp, propId) => {
10
+ if (!excludeSet.has(propId)) {
11
+ tmp[propId] = input[propId];
12
+ }
13
+ return tmp;
14
+ }, {});
15
+ };
16
+ exports.propertyFilterAgent = propertyFilterAgent;
17
+ const inputs = [{ color: "red", model: "Model 3", type: "EV", maker: "Tesla", range: 300 }];
18
+ const propertyFilterAgentInfo = {
19
+ name: "propertyFilterAgent",
20
+ agent: exports.propertyFilterAgent,
21
+ mock: exports.propertyFilterAgent,
22
+ samples: [
23
+ {
24
+ inputs,
25
+ params: { include: ["color", "model"] },
26
+ result: { color: "red", model: "Model 3" },
27
+ },
28
+ {
29
+ inputs,
30
+ params: { exclude: ["color", "model"] },
31
+ result: { type: "EV", maker: "Tesla", range: 300 },
32
+ },
33
+ ],
34
+ description: "Filter properties based on property name either with 'include' or 'exclude'",
35
+ category: ["data"],
36
+ author: "Receptron team",
37
+ repository: "https://github.com/receptron/graphai",
38
+ license: "MIT",
39
+ };
40
+ exports.default = propertyFilterAgentInfo;
@@ -39,6 +39,7 @@ declare const totalAgentInfo: {
39
39
  };
40
40
  })[];
41
41
  description: string;
42
+ category: string[];
42
43
  author: string;
43
44
  repository: string;
44
45
  license: string;
@@ -44,6 +44,7 @@ const totalAgentInfo = {
44
44
  },
45
45
  ],
46
46
  description: "Returns the sum of input values",
47
+ category: ["data"],
47
48
  author: "Satoshi Nakajima",
48
49
  repository: "https://github.com/snakajima/graphai",
49
50
  license: "MIT",
@@ -1,6 +1,20 @@
1
1
  import { AgentFunction } from "../graphai";
2
2
  export declare const stringEmbeddingsAgent: AgentFunction<{
3
3
  model?: string;
4
- }, {
5
- contents: any;
6
- }, Array<string> | string>;
4
+ }, any, Array<string> | string>;
5
+ declare const stringEmbeddingsAgentInfo: {
6
+ name: string;
7
+ agent: AgentFunction<{
8
+ model?: string | undefined;
9
+ }, any, string | string[]>;
10
+ mock: AgentFunction<{
11
+ model?: string | undefined;
12
+ }, any, string | string[]>;
13
+ samples: never[];
14
+ description: string;
15
+ category: never[];
16
+ author: string;
17
+ repository: string;
18
+ license: string;
19
+ };
20
+ export default stringEmbeddingsAgentInfo;
@@ -38,6 +38,18 @@ const stringEmbeddingsAgent = async ({ params, inputs }) => {
38
38
  const embeddings = jsonResponse.data.map((object) => {
39
39
  return object.embedding;
40
40
  });
41
- return { contents: embeddings };
41
+ return embeddings;
42
42
  };
43
43
  exports.stringEmbeddingsAgent = stringEmbeddingsAgent;
44
+ const stringEmbeddingsAgentInfo = {
45
+ name: "stringEmbeddingsAgent",
46
+ agent: exports.stringEmbeddingsAgent,
47
+ mock: exports.stringEmbeddingsAgent,
48
+ samples: [],
49
+ description: "Embeddings Agent",
50
+ category: [],
51
+ author: "Receptron team",
52
+ repository: "https://github.com/receptron/graphai",
53
+ license: "MIT",
54
+ };
55
+ exports.default = stringEmbeddingsAgentInfo;
@@ -0,0 +1,42 @@
1
+ import { AgentFunction } from "../graphai";
2
+ export declare const functionAgent: AgentFunction<{
3
+ function: (...args: any[]) => any;
4
+ }>;
5
+ declare const functionAgentInfo: {
6
+ name: string;
7
+ agent: AgentFunction<{
8
+ function: (...args: any[]) => any;
9
+ }>;
10
+ mock: AgentFunction<{
11
+ function: (...args: any[]) => any;
12
+ }>;
13
+ samples: ({
14
+ inputs: {
15
+ model: string;
16
+ maker: string;
17
+ range: number;
18
+ price: number;
19
+ }[];
20
+ params: {
21
+ function: (info: Record<string, any>) => string;
22
+ };
23
+ result: string;
24
+ } | {
25
+ inputs: string[];
26
+ params: {
27
+ function: (str: string) => any;
28
+ };
29
+ result: {
30
+ model: string;
31
+ maker: string;
32
+ range: number;
33
+ price: number;
34
+ };
35
+ })[];
36
+ description: string;
37
+ category: string[];
38
+ author: string;
39
+ repository: string;
40
+ license: string;
41
+ };
42
+ export default functionAgentInfo;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.functionAgent = void 0;
4
+ const functionAgent = async ({ inputs, params }) => {
5
+ return params.function(...inputs);
6
+ };
7
+ exports.functionAgent = functionAgent;
8
+ const carInfo = { model: "Model 3", maker: "Tesla", range: 300, price: 35000 };
9
+ const functionAgentInfo = {
10
+ name: "functionAgent",
11
+ agent: exports.functionAgent,
12
+ mock: exports.functionAgent,
13
+ samples: [
14
+ {
15
+ inputs: [carInfo],
16
+ params: {
17
+ function: (info) => {
18
+ const { model, maker, range, price } = info;
19
+ return `A ${maker} ${model} has the range of ${range} miles. It costs $${price}.`;
20
+ },
21
+ },
22
+ result: "A Tesla Model 3 has the range of 300 miles. It costs $35000.",
23
+ },
24
+ {
25
+ inputs: [JSON.stringify(carInfo)],
26
+ params: {
27
+ function: (str) => {
28
+ return JSON.parse(str);
29
+ },
30
+ },
31
+ result: carInfo,
32
+ },
33
+ ],
34
+ description: "It allows developers to implement the agent function within the graph itself.",
35
+ category: ["data"],
36
+ author: "Receptron team",
37
+ repository: "https://github.com/receptron/graphai",
38
+ license: "MIT",
39
+ };
40
+ exports.default = functionAgentInfo;
@@ -0,0 +1,2 @@
1
+ export { nestedAgent } from "../../experimental_agents/graph_agents/nested_agent";
2
+ export { mapAgent } from "../../experimental_agents/graph_agents/map_agent";
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mapAgent = exports.nestedAgent = void 0;
4
+ var nested_agent_1 = require("../../experimental_agents/graph_agents/nested_agent");
5
+ Object.defineProperty(exports, "nestedAgent", { enumerable: true, get: function () { return nested_agent_1.nestedAgent; } });
6
+ var map_agent_1 = require("../../experimental_agents/graph_agents/map_agent");
7
+ Object.defineProperty(exports, "mapAgent", { enumerable: true, get: function () { return map_agent_1.mapAgent; } });
@@ -0,0 +1,20 @@
1
+ import { AgentFunction } from "../../graphai";
2
+ export declare const mapAgent: AgentFunction<{
3
+ injectionTo?: Array<string>;
4
+ }, Record<string, Array<any>>, any>;
5
+ declare const mapAgentInfo: {
6
+ name: string;
7
+ agent: AgentFunction<{
8
+ injectionTo?: string[] | undefined;
9
+ }, Record<string, any[]>, any>;
10
+ mock: AgentFunction<{
11
+ injectionTo?: string[] | undefined;
12
+ }, Record<string, any[]>, any>;
13
+ samples: never[];
14
+ description: string;
15
+ category: never[];
16
+ author: string;
17
+ repository: string;
18
+ license: string;
19
+ };
20
+ export default mapAgentInfo;
@@ -1,23 +1,32 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.mapAgent = void 0;
4
- const graphai_1 = require("../graphai");
5
- const utils_1 = require("../utils/utils");
4
+ const graphai_1 = require("../../graphai");
5
+ const utils_1 = require("../../utils/utils");
6
+ const nested_agent_1 = require("./nested_agent");
6
7
  const mapAgent = async ({ params, inputs, agents, log, taskManager, graphData }) => {
7
8
  if (taskManager) {
8
9
  const status = taskManager.getStatus();
9
10
  (0, utils_1.assert)(status.concurrency > status.running, `mapAgent: Concurrency is too low: ${status.concurrency}`);
10
11
  }
11
- (0, utils_1.assert)(graphData !== undefined, "mapAgent: graphData is required");
12
+ const nestedGraphData = (0, nested_agent_1.getNestedGraphData)(graphData, inputs);
12
13
  const input = Array.isArray(inputs[0]) ? inputs[0] : inputs;
13
- const injectionTo = params.injectionTo ?? "$0";
14
- if (graphData.nodes[injectionTo] === undefined) {
15
- // If the input node does not exist, automatically create a static node
16
- graphData.nodes[injectionTo] = { value: {} };
17
- }
14
+ const injectionTo = params.injectionTo ??
15
+ inputs.map((__input, index) => {
16
+ return `$${index}`;
17
+ });
18
+ injectionTo.forEach((nodeId) => {
19
+ if (nestedGraphData.nodes[nodeId] === undefined) {
20
+ // If the input node does not exist, automatically create a static node
21
+ nestedGraphData.nodes[nodeId] = { value: {} };
22
+ }
23
+ });
18
24
  const graphs = input.map((data) => {
19
- const graphAI = new graphai_1.GraphAI(graphData, agents || {}, taskManager);
20
- graphAI.injectValue(injectionTo, data, "__mapAgent_inputs__");
25
+ const graphAI = new graphai_1.GraphAI(nestedGraphData, agents || {}, taskManager);
26
+ // Only the first input will be mapped
27
+ injectionTo.forEach((injectToNodeId, index) => {
28
+ graphAI.injectValue(injectToNodeId, index === 0 ? data : inputs[index], "__mapAgent_inputs__");
29
+ });
21
30
  return graphAI;
22
31
  });
23
32
  const runs = graphs.map((graph) => {
@@ -44,3 +53,15 @@ const mapAgent = async ({ params, inputs, agents, log, taskManager, graphData })
44
53
  return compositeResult;
45
54
  };
46
55
  exports.mapAgent = mapAgent;
56
+ const mapAgentInfo = {
57
+ name: "mapAgent",
58
+ agent: exports.mapAgent,
59
+ mock: exports.mapAgent,
60
+ samples: [],
61
+ description: "Map Agent",
62
+ category: [],
63
+ author: "Receptron team",
64
+ repository: "https://github.com/receptron/graphai",
65
+ license: "MIT",
66
+ };
67
+ exports.default = mapAgentInfo;
@@ -0,0 +1,22 @@
1
+ import { AgentFunction } from "../../graphai";
2
+ import { GraphData } from "../../type";
3
+ export declare const getNestedGraphData: (graphData: GraphData | string | undefined, inputs: Array<any>) => GraphData;
4
+ export declare const nestedAgent: AgentFunction<{
5
+ injectionTo?: Array<string>;
6
+ }>;
7
+ declare const nestedAgentInfo: {
8
+ name: string;
9
+ agent: AgentFunction<{
10
+ injectionTo?: string[] | undefined;
11
+ }>;
12
+ mock: AgentFunction<{
13
+ injectionTo?: string[] | undefined;
14
+ }>;
15
+ samples: never[];
16
+ description: string;
17
+ category: never[];
18
+ author: string;
19
+ repository: string;
20
+ license: string;
21
+ };
22
+ export default nestedAgentInfo;
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.nestedAgent = exports.getNestedGraphData = void 0;
4
+ const graphai_1 = require("../../graphai");
5
+ const utils_1 = require("../../utils/utils");
6
+ // This function allows us to use one of inputs as the graph data for this nested agent,
7
+ // which is equivalent to "eval" of JavaScript.
8
+ const getNestedGraphData = (graphData, inputs) => {
9
+ (0, utils_1.assert)(graphData !== undefined, "nestedAgent: graphData is required");
10
+ if (typeof graphData === "string") {
11
+ const regex = /^\$(\d+)$/;
12
+ const match = graphData.match(regex);
13
+ if (match) {
14
+ const index = parseInt(match[1], 10);
15
+ if (index < inputs.length) {
16
+ return inputs[index];
17
+ }
18
+ }
19
+ (0, utils_1.assert)(false, `getNestedGraphData: Invalid graphData string: ${graphData}`);
20
+ }
21
+ return graphData;
22
+ };
23
+ exports.getNestedGraphData = getNestedGraphData;
24
+ const nestedAgent = async ({ params, inputs, agents, log, taskManager, graphData }) => {
25
+ if (taskManager) {
26
+ const status = taskManager.getStatus(false);
27
+ (0, utils_1.assert)(status.concurrency > status.running, `nestedAgent: Concurrency is too low: ${status.concurrency}`);
28
+ }
29
+ const nestedGraphData = (0, exports.getNestedGraphData)(graphData, inputs);
30
+ const injectionTo = params.injectionTo ??
31
+ inputs.map((__input, index) => {
32
+ return `$${index}`;
33
+ });
34
+ injectionTo.forEach((nodeId) => {
35
+ if (nestedGraphData.nodes[nodeId] === undefined) {
36
+ // If the input node does not exist, automatically create a static node
37
+ nestedGraphData.nodes[nodeId] = { value: {} };
38
+ }
39
+ });
40
+ const graphAI = new graphai_1.GraphAI(nestedGraphData, agents || {}, taskManager);
41
+ try {
42
+ // Inject inputs to specified source nodes
43
+ injectionTo.forEach((injectToNodeId, index) => {
44
+ graphAI.injectValue(injectToNodeId, inputs[index]);
45
+ });
46
+ const results = await graphAI.run(false);
47
+ log?.push(...graphAI.transactionLogs());
48
+ return results;
49
+ }
50
+ catch (error) {
51
+ log?.push(...graphAI.transactionLogs());
52
+ if (error instanceof Error) {
53
+ console.log("Error:", error.message);
54
+ }
55
+ throw error;
56
+ }
57
+ };
58
+ exports.nestedAgent = nestedAgent;
59
+ const nestedAgentInfo = {
60
+ name: "nestedAgent",
61
+ agent: exports.nestedAgent,
62
+ mock: exports.nestedAgent,
63
+ samples: [],
64
+ description: "nested Agent",
65
+ category: [],
66
+ author: "Receptron team",
67
+ repository: "https://github.com/receptron/graphai",
68
+ license: "MIT",
69
+ };
70
+ exports.default = nestedAgentInfo;
@@ -0,0 +1,3 @@
1
+ import nestedAgent from "../../experimental_agents/graph_agents/nested_agent";
2
+ import mapAgent from "../../experimental_agents/graph_agents/map_agent";
3
+ export { nestedAgent, mapAgent };
@@ -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.mapAgent = exports.nestedAgent = void 0;
7
+ const nested_agent_1 = __importDefault(require("../../experimental_agents/graph_agents/nested_agent"));
8
+ exports.nestedAgent = nested_agent_1.default;
9
+ const map_agent_1 = __importDefault(require("../../experimental_agents/graph_agents/map_agent"));
10
+ exports.mapAgent = map_agent_1.default;
@@ -1,11 +1,11 @@
1
1
  export * from "./string_agents";
2
- export * from "./slashgpt_agent";
3
2
  export * from "./sleeper_agents";
4
3
  export * from "./data_agents";
5
- export * from "./nested_agent";
6
4
  export * from "./array_agents";
7
- export * from "./embedding_agent";
8
5
  export * from "./matrix_agents";
9
- export * from "./token_agent";
10
6
  export * from "./test_agents";
11
- export * from "./map_agent";
7
+ export * from "./graph_agents";
8
+ export * from "./llm_agents";
9
+ export * from "./embedding_agent";
10
+ export * from "./token_agent";
11
+ export * from "./function_agent";
@@ -15,13 +15,13 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./string_agents"), exports);
18
- __exportStar(require("./slashgpt_agent"), exports);
19
18
  __exportStar(require("./sleeper_agents"), exports);
20
19
  __exportStar(require("./data_agents"), exports);
21
- __exportStar(require("./nested_agent"), exports);
22
20
  __exportStar(require("./array_agents"), exports);
23
- __exportStar(require("./embedding_agent"), exports);
24
21
  __exportStar(require("./matrix_agents"), exports);
25
- __exportStar(require("./token_agent"), exports);
26
22
  __exportStar(require("./test_agents"), exports);
27
- __exportStar(require("./map_agent"), exports);
23
+ __exportStar(require("./graph_agents"), exports);
24
+ __exportStar(require("./llm_agents"), exports);
25
+ __exportStar(require("./embedding_agent"), exports);
26
+ __exportStar(require("./token_agent"), exports);
27
+ __exportStar(require("./function_agent"), exports);
@@ -0,0 +1,26 @@
1
+ import { AgentFunction } from "../../graphai";
2
+ export declare const gloqAgent: AgentFunction<{
3
+ model: string;
4
+ query?: string;
5
+ system?: string;
6
+ }, Record<string, any> | string, string>;
7
+ declare const gloqAgentInfo: {
8
+ name: string;
9
+ agent: AgentFunction<{
10
+ model: string;
11
+ query?: string | undefined;
12
+ system?: string | undefined;
13
+ }, string | Record<string, any>, string>;
14
+ mock: AgentFunction<{
15
+ model: string;
16
+ query?: string | undefined;
17
+ system?: string | undefined;
18
+ }, string | Record<string, any>, string>;
19
+ samples: never[];
20
+ description: string;
21
+ category: string[];
22
+ author: string;
23
+ repository: string;
24
+ license: string;
25
+ };
26
+ export default gloqAgentInfo;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.gloqAgent = void 0;
4
+ const groq_sdk_1 = require("groq-sdk");
5
+ const utils_1 = require("../../utils/utils");
6
+ const groq = process.env.GROQ_API_KEY
7
+ ? new groq_sdk_1.Groq({
8
+ apiKey: process.env.GROQ_API_KEY,
9
+ })
10
+ : undefined;
11
+ const gloqAgent = async ({ params, inputs }) => {
12
+ (0, utils_1.assert)(groq !== undefined, "The GROQ_API_KEY environment variable is missing.");
13
+ const query = params?.query ? [params.query] : [];
14
+ const content = query.concat(inputs).join("\n");
15
+ const messages = params?.system ? [{ role: "system", content: params.system }] : [];
16
+ messages.push({
17
+ role: "user",
18
+ content,
19
+ });
20
+ console.log(messages);
21
+ const result = await groq.chat.completions.create({
22
+ messages,
23
+ model: params.model,
24
+ });
25
+ return result;
26
+ };
27
+ exports.gloqAgent = gloqAgent;
28
+ const gloqAgentInfo = {
29
+ name: "gloqAgent",
30
+ agent: exports.gloqAgent,
31
+ mock: exports.gloqAgent,
32
+ samples: [],
33
+ description: "Groq Agent",
34
+ category: ["llm"],
35
+ author: "Receptron team",
36
+ repository: "https://github.com/receptron/graphai",
37
+ license: "MIT",
38
+ };
39
+ exports.default = gloqAgentInfo;
@@ -0,0 +1,2 @@
1
+ export * from "./slashgpt_agent";
2
+ export * from "./groq_agent";
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./slashgpt_agent"), exports);
18
+ __exportStar(require("./groq_agent"), exports);
@@ -0,0 +1,3 @@
1
+ import gloqAgent from "../../experimental_agents/llm_agents/groq_agent";
2
+ import slashGPTAgent from "../../experimental_agents/llm_agents/slashgpt_agent";
3
+ export { gloqAgent, slashGPTAgent };
@@ -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.slashGPTAgent = exports.gloqAgent = void 0;
7
+ const groq_agent_1 = __importDefault(require("../../experimental_agents/llm_agents/groq_agent"));
8
+ exports.gloqAgent = groq_agent_1.default;
9
+ const slashgpt_agent_1 = __importDefault(require("../../experimental_agents/llm_agents/slashgpt_agent"));
10
+ exports.slashGPTAgent = slashgpt_agent_1.default;
@@ -0,0 +1,27 @@
1
+ import { AgentFunction } from "../../graphai";
2
+ import { ManifestData, ChatData } from "slashgpt";
3
+ export declare const slashGPTAgent: AgentFunction<{
4
+ manifest: ManifestData;
5
+ query?: string;
6
+ function_result?: boolean;
7
+ }, ChatData[], string>;
8
+ declare const slashGPTAgentInfo: {
9
+ name: string;
10
+ agent: AgentFunction<{
11
+ manifest: ManifestData;
12
+ query?: string | undefined;
13
+ function_result?: boolean | undefined;
14
+ }, ChatData[], string>;
15
+ mock: AgentFunction<{
16
+ manifest: ManifestData;
17
+ query?: string | undefined;
18
+ function_result?: boolean | undefined;
19
+ }, ChatData[], string>;
20
+ samples: never[];
21
+ description: string;
22
+ category: string[];
23
+ author: string;
24
+ repository: string;
25
+ license: string;
26
+ };
27
+ export default slashGPTAgentInfo;