graphai 0.2.0 → 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.
- package/lib/experimental_agents/array_agents/pop_agent.d.ts +3 -3
- package/lib/experimental_agents/array_agents/pop_agent.js +1 -6
- package/lib/experimental_agents/array_agents/push_agent.d.ts +3 -3
- package/lib/experimental_agents/array_agents/push_agent.js +2 -7
- package/lib/experimental_agents/array_agents/shift_agent.d.ts +3 -3
- package/lib/experimental_agents/array_agents/shift_agent.js +1 -6
- package/lib/experimental_agents/data_agents/data_object_merge_template_agent.d.ts +1 -1
- package/lib/experimental_agents/data_agents/data_object_merge_template_agent.js +1 -1
- package/lib/experimental_agents/data_agents/data_sum_template_agent.d.ts +1 -1
- package/lib/experimental_agents/data_agents/data_sum_template_agent.js +1 -1
- package/lib/experimental_agents/data_agents/index.d.ts +1 -0
- package/lib/experimental_agents/data_agents/index.js +3 -1
- package/lib/experimental_agents/data_agents/packages.d.ts +2 -1
- package/lib/experimental_agents/data_agents/packages.js +3 -1
- package/lib/experimental_agents/data_agents/property_filter_agent.d.ts +61 -0
- package/lib/experimental_agents/data_agents/property_filter_agent.js +40 -0
- package/lib/experimental_agents/data_agents/total_agent.d.ts +1 -1
- package/lib/experimental_agents/data_agents/total_agent.js +1 -1
- package/lib/experimental_agents/function_agent.d.ts +42 -0
- package/lib/experimental_agents/function_agent.js +40 -0
- package/lib/experimental_agents/index.d.ts +2 -1
- package/lib/experimental_agents/index.js +2 -1
- package/lib/experimental_agents/llm_agents/groq_agent.d.ts +26 -0
- package/lib/experimental_agents/llm_agents/groq_agent.js +39 -0
- package/lib/experimental_agents/llm_agents/index.d.ts +2 -0
- package/lib/experimental_agents/llm_agents/index.js +18 -0
- package/lib/experimental_agents/llm_agents/packages.d.ts +3 -0
- package/lib/experimental_agents/llm_agents/packages.js +10 -0
- package/lib/experimental_agents/{slashgpt_agent.d.ts → llm_agents/slashgpt_agent.d.ts} +6 -12
- package/lib/experimental_agents/{slashgpt_agent.js → llm_agents/slashgpt_agent.js} +2 -11
- package/lib/experimental_agents/packages.d.ts +3 -2
- package/lib/experimental_agents/packages.js +4 -3
- package/lib/experimental_agents/string_agents/string_template_agent.d.ts +4 -6
- package/lib/experimental_agents/string_agents/string_template_agent.js +2 -2
- package/lib/experimental_agents/test_agents/bypass_agent.d.ts +4 -1
- package/lib/experimental_agents/test_agents/bypass_agent.js +31 -6
- package/lib/graphai.d.ts +1 -0
- package/lib/graphai.js +7 -3
- package/lib/node.js +2 -2
- package/lib/transaction_log.js +1 -1
- package/lib/type.d.ts +4 -2
- package/lib/utils/test_agents.js +1 -0
- package/lib/utils/test_utils.js +15 -10
- package/lib/utils/utils.d.ts +2 -2
- package/lib/utils/utils.js +20 -6
- package/lib/validators/relation_validator.js +11 -6
- package/package.json +2 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { AgentFunction } from "../../graphai";
|
|
2
|
-
export declare const popAgent: AgentFunction<Record<string, any>, Record<string, any>,
|
|
2
|
+
export declare const popAgent: AgentFunction<Record<string, any>, Record<string, any>, Array<any>>;
|
|
3
3
|
declare const popAgentInfo: {
|
|
4
4
|
name: string;
|
|
5
|
-
agent: AgentFunction<Record<string, any>, Record<string, any>,
|
|
6
|
-
mock: AgentFunction<Record<string, any>, Record<string, any>,
|
|
5
|
+
agent: AgentFunction<Record<string, any>, Record<string, any>, any[]>;
|
|
6
|
+
mock: AgentFunction<Record<string, any>, Record<string, any>, any[]>;
|
|
7
7
|
samples: ({
|
|
8
8
|
inputs: string[][];
|
|
9
9
|
params: {};
|
|
@@ -1,14 +1,9 @@
|
|
|
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.popAgent = void 0;
|
|
7
|
-
const deepmerge_1 = __importDefault(require("deepmerge"));
|
|
8
4
|
const popAgent = async (context) => {
|
|
9
5
|
const { inputs } = context;
|
|
10
|
-
const
|
|
11
|
-
// TODO: Validation
|
|
6
|
+
const array = inputs[0].map((item) => item); // shallow copy
|
|
12
7
|
const item = array.pop();
|
|
13
8
|
return { array, item };
|
|
14
9
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { AgentFunction } from "../../graphai";
|
|
2
|
-
export declare const pushAgent: AgentFunction<Record<string, any>, Record<string, any>,
|
|
2
|
+
export declare const pushAgent: AgentFunction<Record<string, any>, Record<string, any>, Array<any>>;
|
|
3
3
|
declare const pushAgentInfo: {
|
|
4
4
|
name: string;
|
|
5
|
-
agent: AgentFunction<Record<string, any>, Record<string, any>,
|
|
6
|
-
mock: AgentFunction<Record<string, any>, Record<string, any>,
|
|
5
|
+
agent: AgentFunction<Record<string, any>, Record<string, any>, any[]>;
|
|
6
|
+
mock: AgentFunction<Record<string, any>, Record<string, any>, any[]>;
|
|
7
7
|
samples: {
|
|
8
8
|
inputs: (number | number[])[];
|
|
9
9
|
params: {};
|
|
@@ -1,14 +1,9 @@
|
|
|
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.pushAgent = void 0;
|
|
7
|
-
const deepmerge_1 = __importDefault(require("deepmerge"));
|
|
8
4
|
const pushAgent = async ({ inputs }) => {
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
array.push(item);
|
|
5
|
+
const array = inputs[0].map((item) => item); // shallow copy
|
|
6
|
+
array.push(inputs[1]);
|
|
12
7
|
return array;
|
|
13
8
|
};
|
|
14
9
|
exports.pushAgent = pushAgent;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { AgentFunction } from "../../graphai";
|
|
2
|
-
export declare const shiftAgent: AgentFunction<Record<string, any>, Record<string, any>,
|
|
2
|
+
export declare const shiftAgent: AgentFunction<Record<string, any>, Record<string, any>, Array<any>>;
|
|
3
3
|
declare const shiftAgentInfo: {
|
|
4
4
|
name: string;
|
|
5
|
-
agent: AgentFunction<Record<string, any>, Record<string, any>,
|
|
6
|
-
mock: AgentFunction<Record<string, any>, Record<string, any>,
|
|
5
|
+
agent: AgentFunction<Record<string, any>, Record<string, any>, any[]>;
|
|
6
|
+
mock: AgentFunction<Record<string, any>, Record<string, any>, any[]>;
|
|
7
7
|
samples: ({
|
|
8
8
|
inputs: number[][];
|
|
9
9
|
params: {};
|
|
@@ -1,14 +1,9 @@
|
|
|
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.shiftAgent = void 0;
|
|
7
|
-
const deepmerge_1 = __importDefault(require("deepmerge"));
|
|
8
4
|
const shiftAgent = async (context) => {
|
|
9
5
|
const { inputs } = context;
|
|
10
|
-
const
|
|
11
|
-
// TODO: Validation
|
|
6
|
+
const array = inputs[0].map((item) => item); // shallow copy
|
|
12
7
|
const item = array.shift();
|
|
13
8
|
return { array, item };
|
|
14
9
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { totalAgent } from "../../experimental_agents/data_agents/total_agent";
|
|
2
2
|
export { dataObjectMergeTemplateAgent } from "../../experimental_agents/data_agents/data_object_merge_template_agent";
|
|
3
3
|
export { dataSumTemplateAgent } from "../../experimental_agents/data_agents/data_sum_template_agent";
|
|
4
|
+
export { propertyFilterAgent } from "../../experimental_agents/data_agents/property_filter_agent";
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.dataSumTemplateAgent = exports.dataObjectMergeTemplateAgent = exports.totalAgent = void 0;
|
|
3
|
+
exports.propertyFilterAgent = exports.dataSumTemplateAgent = exports.dataObjectMergeTemplateAgent = exports.totalAgent = void 0;
|
|
4
4
|
var total_agent_1 = require("../../experimental_agents/data_agents/total_agent");
|
|
5
5
|
Object.defineProperty(exports, "totalAgent", { enumerable: true, get: function () { return total_agent_1.totalAgent; } });
|
|
6
6
|
var data_object_merge_template_agent_1 = require("../../experimental_agents/data_agents/data_object_merge_template_agent");
|
|
7
7
|
Object.defineProperty(exports, "dataObjectMergeTemplateAgent", { enumerable: true, get: function () { return data_object_merge_template_agent_1.dataObjectMergeTemplateAgent; } });
|
|
8
8
|
var data_sum_template_agent_1 = require("../../experimental_agents/data_agents/data_sum_template_agent");
|
|
9
9
|
Object.defineProperty(exports, "dataSumTemplateAgent", { enumerable: true, get: function () { return data_sum_template_agent_1.dataSumTemplateAgent; } });
|
|
10
|
+
var property_filter_agent_1 = require("../../experimental_agents/data_agents/property_filter_agent");
|
|
11
|
+
Object.defineProperty(exports, "propertyFilterAgent", { enumerable: true, get: function () { return property_filter_agent_1.propertyFilterAgent; } });
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import totalAgent from "../../experimental_agents/data_agents/total_agent";
|
|
2
2
|
import dataObjectMergeTemplateAgent from "../../experimental_agents/data_agents/data_object_merge_template_agent";
|
|
3
3
|
import dataSumTemplateAgent from "../../experimental_agents/data_agents/data_sum_template_agent";
|
|
4
|
-
|
|
4
|
+
import propertyFilterAgent from "../../experimental_agents/data_agents/property_filter_agent";
|
|
5
|
+
export { totalAgent, dataObjectMergeTemplateAgent, dataSumTemplateAgent, propertyFilterAgent };
|
|
@@ -3,10 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.dataSumTemplateAgent = exports.dataObjectMergeTemplateAgent = exports.totalAgent = void 0;
|
|
6
|
+
exports.propertyFilterAgent = exports.dataSumTemplateAgent = exports.dataObjectMergeTemplateAgent = exports.totalAgent = void 0;
|
|
7
7
|
const total_agent_1 = __importDefault(require("../../experimental_agents/data_agents/total_agent"));
|
|
8
8
|
exports.totalAgent = total_agent_1.default;
|
|
9
9
|
const data_object_merge_template_agent_1 = __importDefault(require("../../experimental_agents/data_agents/data_object_merge_template_agent"));
|
|
10
10
|
exports.dataObjectMergeTemplateAgent = data_object_merge_template_agent_1.default;
|
|
11
11
|
const data_sum_template_agent_1 = __importDefault(require("../../experimental_agents/data_agents/data_sum_template_agent"));
|
|
12
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;
|
|
@@ -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;
|
|
@@ -5,6 +5,7 @@ export * from "./array_agents";
|
|
|
5
5
|
export * from "./matrix_agents";
|
|
6
6
|
export * from "./test_agents";
|
|
7
7
|
export * from "./graph_agents";
|
|
8
|
-
export * from "./
|
|
8
|
+
export * from "./llm_agents";
|
|
9
9
|
export * from "./embedding_agent";
|
|
10
10
|
export * from "./token_agent";
|
|
11
|
+
export * from "./function_agent";
|
|
@@ -21,6 +21,7 @@ __exportStar(require("./array_agents"), exports);
|
|
|
21
21
|
__exportStar(require("./matrix_agents"), exports);
|
|
22
22
|
__exportStar(require("./test_agents"), exports);
|
|
23
23
|
__exportStar(require("./graph_agents"), exports);
|
|
24
|
-
__exportStar(require("./
|
|
24
|
+
__exportStar(require("./llm_agents"), exports);
|
|
25
25
|
__exportStar(require("./embedding_agent"), exports);
|
|
26
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,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,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;
|
|
@@ -1,31 +1,25 @@
|
|
|
1
|
-
import { AgentFunction } from "
|
|
2
|
-
import { ManifestData } from "slashgpt";
|
|
1
|
+
import { AgentFunction } from "../../graphai";
|
|
2
|
+
import { ManifestData, ChatData } from "slashgpt";
|
|
3
3
|
export declare const slashGPTAgent: AgentFunction<{
|
|
4
4
|
manifest: ManifestData;
|
|
5
5
|
query?: string;
|
|
6
6
|
function_result?: boolean;
|
|
7
|
-
},
|
|
8
|
-
content: string;
|
|
9
|
-
}, string>;
|
|
7
|
+
}, ChatData[], string>;
|
|
10
8
|
declare const slashGPTAgentInfo: {
|
|
11
9
|
name: string;
|
|
12
10
|
agent: AgentFunction<{
|
|
13
11
|
manifest: ManifestData;
|
|
14
12
|
query?: string | undefined;
|
|
15
13
|
function_result?: boolean | undefined;
|
|
16
|
-
},
|
|
17
|
-
content: string;
|
|
18
|
-
}, string>;
|
|
14
|
+
}, ChatData[], string>;
|
|
19
15
|
mock: AgentFunction<{
|
|
20
16
|
manifest: ManifestData;
|
|
21
17
|
query?: string | undefined;
|
|
22
18
|
function_result?: boolean | undefined;
|
|
23
|
-
},
|
|
24
|
-
content: string;
|
|
25
|
-
}, string>;
|
|
19
|
+
}, ChatData[], string>;
|
|
26
20
|
samples: never[];
|
|
27
21
|
description: string;
|
|
28
|
-
category:
|
|
22
|
+
category: string[];
|
|
29
23
|
author: string;
|
|
30
24
|
repository: string;
|
|
31
25
|
license: string;
|
|
@@ -16,16 +16,7 @@ const slashGPTAgent = async ({ params, inputs, debugInfo: { verbose, nodeId } })
|
|
|
16
16
|
const contents = query.concat(inputs);
|
|
17
17
|
session.append_user_question(contents.join("\n"));
|
|
18
18
|
await session.call_loop(() => { });
|
|
19
|
-
|
|
20
|
-
if (params?.function_result) {
|
|
21
|
-
return session.history.messages().find((m) => m.role === "function_result");
|
|
22
|
-
}
|
|
23
|
-
return session.history.last_message();
|
|
24
|
-
})();
|
|
25
|
-
if (message === undefined) {
|
|
26
|
-
throw new Error("No message in the history");
|
|
27
|
-
}
|
|
28
|
-
return message;
|
|
19
|
+
return session.history.messages();
|
|
29
20
|
};
|
|
30
21
|
exports.slashGPTAgent = slashGPTAgent;
|
|
31
22
|
const slashGPTAgentInfo = {
|
|
@@ -34,7 +25,7 @@ const slashGPTAgentInfo = {
|
|
|
34
25
|
mock: exports.slashGPTAgent,
|
|
35
26
|
samples: [],
|
|
36
27
|
description: "Slash GPT Agent",
|
|
37
|
-
category: [],
|
|
28
|
+
category: ["llm"],
|
|
38
29
|
author: "Receptron team",
|
|
39
30
|
repository: "https://github.com/receptron/graphai",
|
|
40
31
|
license: "MIT",
|
|
@@ -5,7 +5,8 @@ export * from "./array_agents/packages";
|
|
|
5
5
|
export * from "./matrix_agents/packages";
|
|
6
6
|
export * from "./test_agents/packages";
|
|
7
7
|
export * from "./graph_agents/packages";
|
|
8
|
-
|
|
8
|
+
export * from "./llm_agents/packages";
|
|
9
9
|
import stringEmbeddingsAgent from "./embedding_agent";
|
|
10
10
|
import tokenBoundStringsAgent from "./token_agent";
|
|
11
|
-
|
|
11
|
+
import functionAgentInfo from "./function_agent";
|
|
12
|
+
export { stringEmbeddingsAgent, tokenBoundStringsAgent, functionAgentInfo };
|
|
@@ -17,7 +17,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.
|
|
20
|
+
exports.functionAgentInfo = exports.tokenBoundStringsAgent = exports.stringEmbeddingsAgent = void 0;
|
|
21
21
|
__exportStar(require("./string_agents/packages"), exports);
|
|
22
22
|
__exportStar(require("./sleeper_agents/packages"), exports);
|
|
23
23
|
__exportStar(require("./data_agents/packages"), exports);
|
|
@@ -25,9 +25,10 @@ __exportStar(require("./array_agents/packages"), exports);
|
|
|
25
25
|
__exportStar(require("./matrix_agents/packages"), exports);
|
|
26
26
|
__exportStar(require("./test_agents/packages"), exports);
|
|
27
27
|
__exportStar(require("./graph_agents/packages"), exports);
|
|
28
|
-
|
|
29
|
-
exports.slashGPTAgent = slashgpt_agent_1.default;
|
|
28
|
+
__exportStar(require("./llm_agents/packages"), exports);
|
|
30
29
|
const embedding_agent_1 = __importDefault(require("./embedding_agent"));
|
|
31
30
|
exports.stringEmbeddingsAgent = embedding_agent_1.default;
|
|
32
31
|
const token_agent_1 = __importDefault(require("./token_agent"));
|
|
33
32
|
exports.tokenBoundStringsAgent = token_agent_1.default;
|
|
33
|
+
const function_agent_1 = __importDefault(require("./function_agent"));
|
|
34
|
+
exports.functionAgentInfo = function_agent_1.default;
|
|
@@ -1,23 +1,21 @@
|
|
|
1
1
|
import { AgentFunction } from "../../graphai";
|
|
2
2
|
export declare const stringTemplateAgent: AgentFunction<{
|
|
3
3
|
template: string;
|
|
4
|
-
},
|
|
4
|
+
}, string, string>;
|
|
5
5
|
declare const stringTemplateAgentInfo: {
|
|
6
6
|
name: string;
|
|
7
7
|
agent: AgentFunction<{
|
|
8
8
|
template: string;
|
|
9
|
-
}, string
|
|
9
|
+
}, string, string>;
|
|
10
10
|
mock: AgentFunction<{
|
|
11
11
|
template: string;
|
|
12
|
-
}, string
|
|
12
|
+
}, string, string>;
|
|
13
13
|
samples: {
|
|
14
14
|
inputs: string[];
|
|
15
15
|
params: {
|
|
16
16
|
template: string;
|
|
17
17
|
};
|
|
18
|
-
result:
|
|
19
|
-
content: string;
|
|
20
|
-
};
|
|
18
|
+
result: string;
|
|
21
19
|
}[];
|
|
22
20
|
description: string;
|
|
23
21
|
category: never[];
|
|
@@ -7,12 +7,12 @@ const stringTemplateAgent = async ({ params, inputs }) => {
|
|
|
7
7
|
const content = inputs.reduce((template, input, index) => {
|
|
8
8
|
return template.replace("${" + index + "}", input);
|
|
9
9
|
}, params.template);
|
|
10
|
-
return
|
|
10
|
+
return content;
|
|
11
11
|
};
|
|
12
12
|
exports.stringTemplateAgent = stringTemplateAgent;
|
|
13
13
|
const sampleInput = ["hello", "test"];
|
|
14
14
|
const sampleParams = { template: "${0}: ${1}" };
|
|
15
|
-
const sampleResult =
|
|
15
|
+
const sampleResult = "hello: test";
|
|
16
16
|
// for test and document
|
|
17
17
|
const stringTemplateAgentInfo = {
|
|
18
18
|
name: "stringTemplateAgent",
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { AgentFunction } from "../../graphai";
|
|
2
2
|
import { AgentFunctionInfo } from "../../type";
|
|
3
|
-
export declare const bypassAgent: AgentFunction
|
|
3
|
+
export declare const bypassAgent: AgentFunction<{
|
|
4
|
+
flat?: number;
|
|
5
|
+
firstElement?: boolean;
|
|
6
|
+
}>;
|
|
4
7
|
declare const bypassAgentInfo: AgentFunctionInfo;
|
|
5
8
|
export default bypassAgentInfo;
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.bypassAgent = void 0;
|
|
4
|
-
const bypassAgent = async (
|
|
5
|
-
if (
|
|
6
|
-
return
|
|
4
|
+
const bypassAgent = async ({ params, inputs }) => {
|
|
5
|
+
if (params && params.firstElement) {
|
|
6
|
+
return inputs[0];
|
|
7
7
|
}
|
|
8
|
-
|
|
8
|
+
if (params && params.flat) {
|
|
9
|
+
return inputs.flat(params.flat || 1);
|
|
10
|
+
}
|
|
11
|
+
return inputs;
|
|
9
12
|
};
|
|
10
13
|
exports.bypassAgent = bypassAgent;
|
|
11
14
|
// for test and document
|
|
@@ -17,13 +20,35 @@ const bypassAgentInfo = {
|
|
|
17
20
|
{
|
|
18
21
|
inputs: [{ a: "123" }],
|
|
19
22
|
params: {},
|
|
20
|
-
result: { a: "123" },
|
|
23
|
+
result: [{ a: "123" }],
|
|
21
24
|
},
|
|
22
25
|
{
|
|
23
|
-
inputs: [
|
|
26
|
+
inputs: [
|
|
27
|
+
[{ a: "123" }, { b: "abc" }],
|
|
28
|
+
[{ c: "987" }, { d: "xyz" }],
|
|
29
|
+
],
|
|
24
30
|
params: {},
|
|
31
|
+
result: [
|
|
32
|
+
[{ a: "123" }, { b: "abc" }],
|
|
33
|
+
[{ c: "987" }, { d: "xyz" }],
|
|
34
|
+
],
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
inputs: [
|
|
38
|
+
[{ a: "123" }, { b: "abc" }],
|
|
39
|
+
[{ c: "987" }, { d: "xyz" }],
|
|
40
|
+
],
|
|
41
|
+
params: { firstElement: true },
|
|
25
42
|
result: [{ a: "123" }, { b: "abc" }],
|
|
26
43
|
},
|
|
44
|
+
{
|
|
45
|
+
inputs: [
|
|
46
|
+
[{ a: "123" }, { b: "abc" }],
|
|
47
|
+
[{ c: "987" }, { d: "xyz" }],
|
|
48
|
+
],
|
|
49
|
+
params: { flat: 1 },
|
|
50
|
+
result: [{ a: "123" }, { b: "abc" }, { c: "987" }, { d: "xyz" }],
|
|
51
|
+
},
|
|
27
52
|
],
|
|
28
53
|
description: "bypass agent",
|
|
29
54
|
category: [],
|
package/lib/graphai.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { ComputedNode, StaticNode } from "./node";
|
|
|
5
5
|
import { TaskManager } from "./task_manager";
|
|
6
6
|
type GraphNodes = Record<string, ComputedNode | StaticNode>;
|
|
7
7
|
export declare class GraphAI {
|
|
8
|
+
private readonly version;
|
|
8
9
|
private readonly graphId;
|
|
9
10
|
private readonly data;
|
|
10
11
|
private readonly loop?;
|
package/lib/graphai.js
CHANGED
|
@@ -40,7 +40,7 @@ class GraphAI {
|
|
|
40
40
|
}
|
|
41
41
|
getValueFromResults(key, results) {
|
|
42
42
|
const source = (0, utils_1.parseNodeName)(key);
|
|
43
|
-
return (0, utils_1.getDataFromSource)(results[source.nodeId], source
|
|
43
|
+
return (0, utils_1.getDataFromSource)(source.nodeId ? results[source.nodeId] : undefined, source);
|
|
44
44
|
}
|
|
45
45
|
// for static
|
|
46
46
|
initializeNodes(previousResults) {
|
|
@@ -68,6 +68,10 @@ class GraphAI {
|
|
|
68
68
|
this.logs = [];
|
|
69
69
|
this.onLogCallback = (__log, __isUpdate) => { };
|
|
70
70
|
this.repeatCount = 0;
|
|
71
|
+
if (!data.version) {
|
|
72
|
+
console.log("------------ no version");
|
|
73
|
+
}
|
|
74
|
+
this.version = data.version ?? 0.2;
|
|
71
75
|
this.graphId = URL.createObjectURL(new Blob()).slice(-36);
|
|
72
76
|
this.data = data;
|
|
73
77
|
this.callbackDictonary = callbackDictonary;
|
|
@@ -229,8 +233,8 @@ class GraphAI {
|
|
|
229
233
|
}
|
|
230
234
|
resultsOf(sources) {
|
|
231
235
|
return sources.map((source) => {
|
|
232
|
-
const { result } = this.nodes[source.nodeId];
|
|
233
|
-
return (0, utils_1.getDataFromSource)(result, source
|
|
236
|
+
const { result } = source.nodeId ? this.nodes[source.nodeId] : { result: undefined };
|
|
237
|
+
return (0, utils_1.getDataFromSource)(result, source);
|
|
234
238
|
});
|
|
235
239
|
}
|
|
236
240
|
}
|
package/lib/node.js
CHANGED
|
@@ -44,8 +44,8 @@ class ComputedNode extends Node {
|
|
|
44
44
|
this.timeout = data.timeout;
|
|
45
45
|
this.isResult = data.isResult ?? false;
|
|
46
46
|
this.anyInput = data.anyInput ?? false;
|
|
47
|
-
this.dataSources = (data.inputs ?? []).map(utils_2.parseNodeName);
|
|
48
|
-
this.pendings = new Set(this.dataSources.map((source) => source.nodeId));
|
|
47
|
+
this.dataSources = (data.inputs ?? []).map((input) => (0, utils_2.parseNodeName)(input));
|
|
48
|
+
this.pendings = new Set(this.dataSources.filter((source) => source.nodeId).map((source) => source.nodeId));
|
|
49
49
|
this.log.initForComputedNode(this);
|
|
50
50
|
}
|
|
51
51
|
isReadyNode() {
|
package/lib/transaction_log.js
CHANGED
|
@@ -40,7 +40,7 @@ class TransactionLog {
|
|
|
40
40
|
this.state = node.state;
|
|
41
41
|
this.retryCount = node.retryCount > 0 ? node.retryCount : undefined;
|
|
42
42
|
this.startTime = transactionId;
|
|
43
|
-
this.inputs = node.dataSources.map((source) => source.nodeId);
|
|
43
|
+
this.inputs = node.dataSources.filter((source) => source.nodeId).map((source) => source.nodeId);
|
|
44
44
|
this.inputsData = inputs.length > 0 ? inputs : undefined;
|
|
45
45
|
graph.setLoopLog(this);
|
|
46
46
|
graph.appendLog(this);
|
package/lib/type.d.ts
CHANGED
|
@@ -17,7 +17,8 @@ export type ResultDataDictonary<ResultType = DefaultResultData> = Record<string,
|
|
|
17
17
|
export type DefaultParamsType = Record<string, any>;
|
|
18
18
|
export type NodeDataParams<ParamsType = DefaultParamsType> = ParamsType;
|
|
19
19
|
export type DataSource = {
|
|
20
|
-
nodeId
|
|
20
|
+
nodeId?: string;
|
|
21
|
+
value?: any;
|
|
21
22
|
propIds?: string[];
|
|
22
23
|
};
|
|
23
24
|
export type StaticNodeData = {
|
|
@@ -27,7 +28,7 @@ export type StaticNodeData = {
|
|
|
27
28
|
};
|
|
28
29
|
export type ComputedNodeData = {
|
|
29
30
|
agentId: string;
|
|
30
|
-
inputs?: Array<
|
|
31
|
+
inputs?: Array<any>;
|
|
31
32
|
anyInput?: boolean;
|
|
32
33
|
params?: NodeDataParams;
|
|
33
34
|
retry?: number;
|
|
@@ -41,6 +42,7 @@ export type LoopData = {
|
|
|
41
42
|
while?: string;
|
|
42
43
|
};
|
|
43
44
|
export type GraphData = {
|
|
45
|
+
version?: number;
|
|
44
46
|
nodes: Record<string, NodeData>;
|
|
45
47
|
concurrency?: number;
|
|
46
48
|
loop?: LoopData;
|
package/lib/utils/test_agents.js
CHANGED
package/lib/utils/test_utils.js
CHANGED
|
@@ -18,17 +18,22 @@ exports.defaultTestContext = {
|
|
|
18
18
|
};
|
|
19
19
|
// for agent
|
|
20
20
|
const agentTestRunner = async (agentInfo) => {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
inputs,
|
|
21
|
+
const { agent, samples } = agentInfo;
|
|
22
|
+
if (samples.length === 0) {
|
|
23
|
+
console.log(`test ${agentInfo.name}: No test`);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
for await (const sampleKey of samples.keys()) {
|
|
27
|
+
(0, node_test_1.default)(`test ${agentInfo.name} ${sampleKey}`, async () => {
|
|
28
|
+
const { params, inputs, result } = samples[sampleKey];
|
|
29
|
+
const actual = await agent({
|
|
30
|
+
...exports.defaultTestContext,
|
|
31
|
+
params,
|
|
32
|
+
inputs,
|
|
33
|
+
});
|
|
34
|
+
node_assert_1.default.deepStrictEqual(actual, result);
|
|
29
35
|
});
|
|
30
|
-
node_assert_1.default.deepStrictEqual(actual, result);
|
|
31
36
|
}
|
|
32
|
-
}
|
|
37
|
+
}
|
|
33
38
|
};
|
|
34
39
|
exports.agentTestRunner = agentTestRunner;
|
package/lib/utils/utils.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DataSource, ResultData } from "../type";
|
|
2
2
|
export declare const sleep: (milliseconds: number) => Promise<unknown>;
|
|
3
|
-
export declare const parseNodeName: (inputNodeId:
|
|
3
|
+
export declare const parseNodeName: (inputNodeId: any) => DataSource;
|
|
4
4
|
export declare function assert(condition: boolean, message: string, isWarn?: boolean): asserts condition;
|
|
5
5
|
export declare const isObject: (x: unknown) => boolean;
|
|
6
|
-
export declare const getDataFromSource: (result: ResultData,
|
|
6
|
+
export declare const getDataFromSource: (result: ResultData | undefined, source: DataSource) => ResultData | undefined;
|
|
7
7
|
export declare const strIntentionalError = "Intentional Error for Debugging";
|
package/lib/utils/utils.js
CHANGED
|
@@ -6,11 +6,19 @@ const sleep = async (milliseconds) => {
|
|
|
6
6
|
};
|
|
7
7
|
exports.sleep = sleep;
|
|
8
8
|
const parseNodeName = (inputNodeId) => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
if (typeof inputNodeId === "string") {
|
|
10
|
+
const regex = /^"(.*)"$/;
|
|
11
|
+
const match = inputNodeId.match(regex);
|
|
12
|
+
if (match) {
|
|
13
|
+
return { value: match[1] }; // string literal
|
|
14
|
+
}
|
|
15
|
+
const parts = inputNodeId.split(".");
|
|
16
|
+
if (parts.length == 1) {
|
|
17
|
+
return { nodeId: parts[0] };
|
|
18
|
+
}
|
|
19
|
+
return { nodeId: parts[0], propIds: parts.slice(1) };
|
|
12
20
|
}
|
|
13
|
-
return {
|
|
21
|
+
return { value: inputNodeId }; // non-string literal
|
|
14
22
|
};
|
|
15
23
|
exports.parseNodeName = parseNodeName;
|
|
16
24
|
function assert(condition, message, isWarn = false) {
|
|
@@ -41,16 +49,22 @@ const getNestedData = (result, propId) => {
|
|
|
41
49
|
assert((0, exports.isObject)(result), "result is not object.");
|
|
42
50
|
return result[propId];
|
|
43
51
|
};
|
|
44
|
-
const
|
|
52
|
+
const innerGetDataFromSource = (result, propIds) => {
|
|
45
53
|
if (result && propIds && propIds.length > 0) {
|
|
46
54
|
const propId = propIds[0];
|
|
47
55
|
const ret = getNestedData(result, propId);
|
|
48
56
|
if (propIds.length > 1) {
|
|
49
|
-
return (
|
|
57
|
+
return innerGetDataFromSource(ret, propIds.slice(1));
|
|
50
58
|
}
|
|
51
59
|
return ret;
|
|
52
60
|
}
|
|
53
61
|
return result;
|
|
54
62
|
};
|
|
63
|
+
const getDataFromSource = (result, source) => {
|
|
64
|
+
if (!source.nodeId) {
|
|
65
|
+
return source.value;
|
|
66
|
+
}
|
|
67
|
+
return innerGetDataFromSource(result, source.propIds);
|
|
68
|
+
};
|
|
55
69
|
exports.getDataFromSource = getDataFromSource;
|
|
56
70
|
exports.strIntentionalError = "Intentional Error for Debugging";
|
|
@@ -12,13 +12,15 @@ const relationValidator = (data, staticNodeIds, computedNodeIds) => {
|
|
|
12
12
|
pendings[computedNodeId] = new Set();
|
|
13
13
|
if (nodeData.inputs) {
|
|
14
14
|
nodeData.inputs.forEach((inputNodeId) => {
|
|
15
|
-
const
|
|
16
|
-
if (
|
|
17
|
-
|
|
15
|
+
const sourceNodeId = (0, utils_1.parseNodeName)(inputNodeId).nodeId;
|
|
16
|
+
if (sourceNodeId) {
|
|
17
|
+
if (!nodeIds.has(sourceNodeId)) {
|
|
18
|
+
throw new Error(`Inputs not match: NodeId ${computedNodeId}, Inputs: ${sourceNodeId}`);
|
|
19
|
+
}
|
|
20
|
+
waitlist[sourceNodeId] === undefined && (waitlist[sourceNodeId] = new Set());
|
|
21
|
+
pendings[computedNodeId].add(sourceNodeId);
|
|
22
|
+
waitlist[sourceNodeId].add(computedNodeId);
|
|
18
23
|
}
|
|
19
|
-
waitlist[input] === undefined && (waitlist[input] = new Set());
|
|
20
|
-
pendings[computedNodeId].add(input);
|
|
21
|
-
waitlist[input].add(computedNodeId);
|
|
22
24
|
});
|
|
23
25
|
}
|
|
24
26
|
});
|
|
@@ -28,6 +30,9 @@ const relationValidator = (data, staticNodeIds, computedNodeIds) => {
|
|
|
28
30
|
const update = nodeData.update;
|
|
29
31
|
if (update) {
|
|
30
32
|
const updateNodeId = (0, utils_1.parseNodeName)(update).nodeId;
|
|
33
|
+
if (!updateNodeId) {
|
|
34
|
+
throw new Error("Update it a literal");
|
|
35
|
+
}
|
|
31
36
|
if (!nodeIds.has(updateNodeId)) {
|
|
32
37
|
throw new Error(`Update not match: NodeId ${staticNodeId}, update: ${update}`);
|
|
33
38
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "graphai",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Asynchronous data flow execution engine for agentic AI apps.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"files": [
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"eslint": "^7.32.0 || ^8.2.0",
|
|
39
39
|
"eslint-plugin-import": "^2.25.2",
|
|
40
40
|
"express": "^4.19.2",
|
|
41
|
+
"groq-sdk": "^0.3.3",
|
|
41
42
|
"openai": "^4.12.4",
|
|
42
43
|
"prettier": "^3.0.3",
|
|
43
44
|
"slashgpt": "^0.0.8",
|