graphai 0.4.1 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -77
- package/lib/experimental_agents/array_agents/pop_agent.d.ts +1 -1
- package/lib/experimental_agents/array_agents/push_agent.d.ts +18 -4
- package/lib/experimental_agents/array_agents/push_agent.js +16 -2
- package/lib/experimental_agents/array_agents/shift_agent.d.ts +2 -2
- package/lib/experimental_agents/array_agents/shift_agent.js +1 -1
- package/lib/experimental_agents/data_agents/copy_agent.d.ts +1 -1
- package/lib/experimental_agents/data_agents/data_object_merge_template_agent.d.ts +1 -1
- package/lib/experimental_agents/data_agents/data_sum_template_agent.d.ts +1 -1
- package/lib/experimental_agents/data_agents/property_filter_agent.d.ts +46 -1
- package/lib/experimental_agents/data_agents/property_filter_agent.js +28 -4
- package/lib/experimental_agents/data_agents/total_agent.d.ts +1 -1
- package/lib/experimental_agents/embedding_agent.d.ts +2 -2
- package/lib/experimental_agents/embedding_agent.js +1 -1
- package/lib/experimental_agents/graph_agents/map_agent.d.ts +2 -2
- package/lib/experimental_agents/graph_agents/map_agent.js +3 -3
- package/lib/experimental_agents/graph_agents/nested_agent.d.ts +2 -2
- package/lib/experimental_agents/graph_agents/nested_agent.js +3 -3
- package/lib/experimental_agents/graph_agents/packages.d.ts +2 -1
- package/lib/experimental_agents/graph_agents/packages.js +3 -1
- package/lib/experimental_agents/graph_agents/vanilla.d.ts +2 -1
- package/lib/experimental_agents/graph_agents/vanilla.js +3 -1
- package/lib/experimental_agents/graph_agents/worker_agent.d.ts +39 -0
- package/lib/experimental_agents/graph_agents/worker_agent.js +111 -0
- package/lib/experimental_agents/index.d.ts +2 -2
- package/lib/experimental_agents/index.js +2 -3
- package/lib/experimental_agents/input_agents/index.d.ts +2 -0
- package/lib/experimental_agents/input_agents/index.js +8 -0
- package/lib/experimental_agents/input_agents/packages.d.ts +2 -0
- package/lib/experimental_agents/input_agents/packages.js +8 -0
- package/lib/experimental_agents/input_agents/text_input_agent.d.ts +33 -0
- package/lib/experimental_agents/input_agents/text_input_agent.js +30 -0
- package/lib/experimental_agents/llm_agents/anthropic_agent.d.ts +34 -0
- package/lib/experimental_agents/llm_agents/anthropic_agent.js +47 -0
- package/lib/experimental_agents/llm_agents/groq_agent.d.ts +15 -10
- package/lib/experimental_agents/llm_agents/groq_agent.js +34 -5
- package/lib/experimental_agents/llm_agents/index.d.ts +2 -2
- package/lib/experimental_agents/llm_agents/index.js +3 -3
- package/lib/experimental_agents/llm_agents/openai_agent.d.ts +13 -1
- package/lib/experimental_agents/llm_agents/openai_agent.js +15 -2
- package/lib/experimental_agents/llm_agents/packages.d.ts +2 -2
- package/lib/experimental_agents/llm_agents/packages.js +3 -3
- package/lib/experimental_agents/llm_agents/slashgpt_agent.d.ts +3 -1
- package/lib/experimental_agents/llm_agents/slashgpt_agent.js +2 -0
- package/lib/experimental_agents/matrix_agents/dot_product_agent.d.ts +2 -2
- package/lib/experimental_agents/matrix_agents/dot_product_agent.js +1 -1
- package/lib/experimental_agents/matrix_agents/sort_by_values_agent.d.ts +2 -2
- package/lib/experimental_agents/matrix_agents/sort_by_values_agent.js +1 -1
- package/lib/experimental_agents/service_agents/fetch_agent.d.ts +1 -1
- package/lib/experimental_agents/service_agents/fetch_agent.js +1 -1
- package/lib/experimental_agents/service_agents/wikipedia.d.ts +1 -1
- package/lib/experimental_agents/service_agents/wikipedia.js +1 -1
- package/lib/experimental_agents/sleeper_agents/sleeper_agent.d.ts +2 -2
- package/lib/experimental_agents/sleeper_agents/sleeper_agent.js +1 -1
- package/lib/experimental_agents/sleeper_agents/sleeper_agent_debug.d.ts +2 -2
- package/lib/experimental_agents/sleeper_agents/sleeper_agent_debug.js +1 -1
- package/lib/experimental_agents/string_agents/json_parser_agent.d.ts +38 -0
- package/lib/experimental_agents/string_agents/json_parser_agent.js +39 -0
- package/lib/experimental_agents/string_agents/packages.d.ts +2 -1
- package/lib/experimental_agents/string_agents/packages.js +3 -1
- package/lib/experimental_agents/string_agents/string_splitter_agent.d.ts +2 -33
- package/lib/experimental_agents/string_agents/string_splitter_agent.js +1 -1
- package/lib/experimental_agents/string_agents/string_template_agent.d.ts +54 -10
- package/lib/experimental_agents/string_agents/string_template_agent.js +40 -10
- package/lib/experimental_agents/string_agents/vanilla.d.ts +2 -1
- package/lib/experimental_agents/string_agents/vanilla.js +3 -1
- package/lib/experimental_agents/test_agents/bypass_agent.d.ts +1 -1
- package/lib/experimental_agents/test_agents/bypass_agent.js +1 -1
- package/lib/experimental_agents/test_agents/copy2array_agent.d.ts +1 -1
- package/lib/experimental_agents/test_agents/copy2array_agent.js +1 -1
- package/lib/experimental_agents/test_agents/copy_message_agent.d.ts +1 -2
- package/lib/experimental_agents/test_agents/copy_message_agent.js +1 -1
- package/lib/experimental_agents/test_agents/counting_agent.d.ts +1 -2
- package/lib/experimental_agents/test_agents/counting_agent.js +1 -1
- package/lib/experimental_agents/test_agents/echo_agent.d.ts +1 -2
- package/lib/experimental_agents/test_agents/echo_agent.js +13 -2
- package/lib/experimental_agents/test_agents/merge_node_id_agent.d.ts +1 -2
- package/lib/experimental_agents/test_agents/merge_node_id_agent.js +1 -1
- package/lib/experimental_agents/test_agents/stream_mock_agent.d.ts +1 -2
- package/lib/experimental_agents/test_agents/stream_mock_agent.js +9 -2
- package/lib/experimental_agents/token_agent.d.ts +1 -1
- package/lib/experimental_agents/vanilla.d.ts +1 -2
- package/lib/experimental_agents/vanilla.js +1 -3
- package/lib/graphai.d.ts +6 -6
- package/lib/graphai.js +9 -9
- package/lib/index.d.ts +3 -3
- package/lib/index.js +4 -2
- package/lib/node.d.ts +4 -2
- package/lib/node.js +44 -11
- package/lib/transaction_log.d.ts +1 -0
- package/lib/transaction_log.js +2 -0
- package/lib/type.d.ts +12 -6
- package/lib/utils/runner.d.ts +2 -0
- package/lib/utils/runner.js +20 -0
- package/lib/utils/test_agents.d.ts +2 -2
- package/lib/utils/test_utils.d.ts +1 -17
- package/lib/utils/test_utils.js +3 -21
- package/lib/utils/utils.d.ts +2 -0
- package/lib/utils/utils.js +45 -1
- package/lib/validators/agent_validator.js +2 -1
- package/lib/validators/common.d.ts +3 -0
- package/lib/validators/common.js +24 -2
- package/lib/validators/computed_node_validator.js +1 -1
- package/lib/validators/graph_data_validator.js +9 -9
- package/lib/validators/nodeValidator.js +3 -2
- package/lib/validators/relation_validator.js +6 -5
- package/lib/validators/static_node_validator.js +1 -1
- package/package.json +4 -1
- package/lib/experimental_agents/function_agent.d.ts +0 -42
- package/lib/experimental_agents/function_agent.js +0 -40
- package/lib/experimental_agents/llm_agents/groq_stream_agent.d.ts +0 -42
- package/lib/experimental_agents/llm_agents/groq_stream_agent.js +0 -84
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.workerAgent = void 0;
|
|
4
|
+
const index_1 = require("../../index");
|
|
5
|
+
const worker_threads_1 = require("worker_threads");
|
|
6
|
+
const experimental_agents_1 = require("../../experimental_agents");
|
|
7
|
+
const utils_1 = require("../../utils/utils");
|
|
8
|
+
const vanillaAgents = {
|
|
9
|
+
totalAgent: experimental_agents_1.totalAgent,
|
|
10
|
+
dataSumTemplateAgent: experimental_agents_1.dataSumTemplateAgent,
|
|
11
|
+
propertyFilterAgent: experimental_agents_1.propertyFilterAgent,
|
|
12
|
+
copyAgent: experimental_agents_1.copyAgent,
|
|
13
|
+
pushAgent: experimental_agents_1.pushAgent,
|
|
14
|
+
popAgent: experimental_agents_1.popAgent,
|
|
15
|
+
shiftAgent: experimental_agents_1.shiftAgent,
|
|
16
|
+
nestedAgent: experimental_agents_1.nestedAgent,
|
|
17
|
+
mapAgent: experimental_agents_1.mapAgent,
|
|
18
|
+
dotProductAgent: experimental_agents_1.dotProductAgent,
|
|
19
|
+
sortByValuesAgent: experimental_agents_1.sortByValuesAgent,
|
|
20
|
+
stringSplitterAgent: experimental_agents_1.stringSplitterAgent,
|
|
21
|
+
stringTemplateAgent: experimental_agents_1.stringTemplateAgent,
|
|
22
|
+
jsonParserAgent: experimental_agents_1.jsonParserAgent,
|
|
23
|
+
};
|
|
24
|
+
if (!worker_threads_1.isMainThread && worker_threads_1.parentPort) {
|
|
25
|
+
const port = worker_threads_1.parentPort;
|
|
26
|
+
port.on("message", async (data) => {
|
|
27
|
+
const { graphData } = data;
|
|
28
|
+
const graphAI = new index_1.GraphAI(graphData, vanillaAgents);
|
|
29
|
+
const result = await graphAI.run();
|
|
30
|
+
port.postMessage(result);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
const workerAgent = async ({ inputs, params, /* agents, log, */ graphData }) => {
|
|
34
|
+
const namedInputs = params.namedInputs ?? inputs.map((__input, index) => `$${index}`);
|
|
35
|
+
(0, utils_1.assert)(!!graphData, "required");
|
|
36
|
+
(0, utils_1.assert)(typeof graphData === "object", "required");
|
|
37
|
+
namedInputs.forEach((nodeId, index) => {
|
|
38
|
+
if (graphData.nodes[nodeId] === undefined) {
|
|
39
|
+
// If the input node does not exist, automatically create a static node
|
|
40
|
+
graphData.nodes[nodeId] = { value: inputs[index] };
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
// Otherwise, inject the proper data here (instead of calling injectTo method later)
|
|
44
|
+
graphData.nodes[nodeId]["value"] = inputs[index];
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
return new Promise((resolve, reject) => {
|
|
48
|
+
const worker = new worker_threads_1.Worker("./lib/experimental_agents/graph_agents/worker_agent.js");
|
|
49
|
+
worker.on("message", (result) => {
|
|
50
|
+
worker.terminate();
|
|
51
|
+
resolve(result);
|
|
52
|
+
});
|
|
53
|
+
worker.on("error", reject);
|
|
54
|
+
worker.on("exit", (code) => {
|
|
55
|
+
if (code !== 0)
|
|
56
|
+
reject(new Error(`Worker stopped with exit code ${code}`));
|
|
57
|
+
});
|
|
58
|
+
// copyAgent is required for test case
|
|
59
|
+
worker.postMessage({ graphData });
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
exports.workerAgent = workerAgent;
|
|
63
|
+
const workerAgentInfo = {
|
|
64
|
+
name: "workerAgent",
|
|
65
|
+
agent: exports.workerAgent,
|
|
66
|
+
mock: exports.workerAgent,
|
|
67
|
+
samples: [
|
|
68
|
+
{
|
|
69
|
+
inputs: [],
|
|
70
|
+
params: {},
|
|
71
|
+
result: { message: "May the force be with you" },
|
|
72
|
+
graph: {
|
|
73
|
+
version: 0.3,
|
|
74
|
+
nodes: {
|
|
75
|
+
source: {
|
|
76
|
+
value: "May the force be with you",
|
|
77
|
+
},
|
|
78
|
+
message: {
|
|
79
|
+
agent: "copyAgent",
|
|
80
|
+
inputs: [":source"],
|
|
81
|
+
isResult: true,
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
inputs: ["May the force be with you"],
|
|
88
|
+
params: {},
|
|
89
|
+
result: { message: "May the force be with you" },
|
|
90
|
+
graph: {
|
|
91
|
+
version: 0.3,
|
|
92
|
+
nodes: {
|
|
93
|
+
source: {
|
|
94
|
+
value: "TypeScript compiler fails without this node for some reason.",
|
|
95
|
+
},
|
|
96
|
+
message: {
|
|
97
|
+
agent: "copyAgent",
|
|
98
|
+
inputs: [":$0"],
|
|
99
|
+
isResult: true,
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
],
|
|
105
|
+
description: "Map Agent",
|
|
106
|
+
category: ["graph"],
|
|
107
|
+
author: "Receptron team",
|
|
108
|
+
repository: "https://github.com/receptron/graphai",
|
|
109
|
+
license: "MIT",
|
|
110
|
+
};
|
|
111
|
+
exports.default = workerAgentInfo;
|
|
@@ -7,7 +7,7 @@ export * from "./data_agents";
|
|
|
7
7
|
export * from "./sleeper_agents";
|
|
8
8
|
export * from "./llm_agents";
|
|
9
9
|
export * from "./service_agents";
|
|
10
|
-
|
|
10
|
+
export * from "./input_agents";
|
|
11
11
|
import stringEmbeddingsAgent from "./embedding_agent";
|
|
12
12
|
import tokenBoundStringsAgent from "./token_agent";
|
|
13
|
-
export {
|
|
13
|
+
export { stringEmbeddingsAgent, tokenBoundStringsAgent };
|
|
@@ -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.tokenBoundStringsAgent = exports.stringEmbeddingsAgent =
|
|
20
|
+
exports.tokenBoundStringsAgent = exports.stringEmbeddingsAgent = void 0;
|
|
21
21
|
__exportStar(require("./string_agents"), exports);
|
|
22
22
|
__exportStar(require("./array_agents"), exports);
|
|
23
23
|
__exportStar(require("./matrix_agents"), exports);
|
|
@@ -28,9 +28,8 @@ __exportStar(require("./data_agents"), exports);
|
|
|
28
28
|
__exportStar(require("./sleeper_agents"), exports);
|
|
29
29
|
__exportStar(require("./llm_agents"), exports);
|
|
30
30
|
__exportStar(require("./service_agents"), exports);
|
|
31
|
+
__exportStar(require("./input_agents"), exports);
|
|
31
32
|
// TODO sub folder
|
|
32
|
-
const function_agent_1 = __importDefault(require("./function_agent"));
|
|
33
|
-
exports.functionAgent = function_agent_1.default;
|
|
34
33
|
const embedding_agent_1 = __importDefault(require("./embedding_agent"));
|
|
35
34
|
exports.stringEmbeddingsAgent = embedding_agent_1.default;
|
|
36
35
|
const token_agent_1 = __importDefault(require("./token_agent"));
|
|
@@ -0,0 +1,8 @@
|
|
|
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.textInputAgent = void 0;
|
|
7
|
+
const text_input_agent_1 = __importDefault(require("../../experimental_agents/input_agents/text_input_agent"));
|
|
8
|
+
exports.textInputAgent = text_input_agent_1.default;
|
|
@@ -0,0 +1,8 @@
|
|
|
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.textInputAgent = void 0;
|
|
7
|
+
const text_input_agent_1 = __importDefault(require("../../experimental_agents/input_agents/text_input_agent"));
|
|
8
|
+
exports.textInputAgent = text_input_agent_1.default;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { AgentFunction } from "../../index";
|
|
2
|
+
export declare const textInputAgent: AgentFunction<{
|
|
3
|
+
message?: string;
|
|
4
|
+
}, string | {
|
|
5
|
+
[x: string]: string;
|
|
6
|
+
}>;
|
|
7
|
+
declare const textInputAgentInfo: {
|
|
8
|
+
name: string;
|
|
9
|
+
agent: AgentFunction<{
|
|
10
|
+
message?: string | undefined;
|
|
11
|
+
}, string | {
|
|
12
|
+
[x: string]: string;
|
|
13
|
+
}>;
|
|
14
|
+
mock: AgentFunction<{
|
|
15
|
+
message?: string | undefined;
|
|
16
|
+
}, string | {
|
|
17
|
+
[x: string]: string;
|
|
18
|
+
}>;
|
|
19
|
+
samples: {
|
|
20
|
+
inputs: never[];
|
|
21
|
+
params: {
|
|
22
|
+
message: string;
|
|
23
|
+
};
|
|
24
|
+
result: string;
|
|
25
|
+
}[];
|
|
26
|
+
skipTest: boolean;
|
|
27
|
+
description: string;
|
|
28
|
+
category: string[];
|
|
29
|
+
author: string;
|
|
30
|
+
repository: string;
|
|
31
|
+
license: string;
|
|
32
|
+
};
|
|
33
|
+
export default textInputAgentInfo;
|
|
@@ -0,0 +1,30 @@
|
|
|
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.textInputAgent = void 0;
|
|
7
|
+
const input_1 = __importDefault(require("@inquirer/input"));
|
|
8
|
+
const textInputAgent = async ({ params }) => {
|
|
9
|
+
return await (0, input_1.default)({ message: params.message ?? "Enter" });
|
|
10
|
+
};
|
|
11
|
+
exports.textInputAgent = textInputAgent;
|
|
12
|
+
const textInputAgentInfo = {
|
|
13
|
+
name: "textInputAgent",
|
|
14
|
+
agent: exports.textInputAgent,
|
|
15
|
+
mock: exports.textInputAgent,
|
|
16
|
+
samples: [
|
|
17
|
+
{
|
|
18
|
+
inputs: [],
|
|
19
|
+
params: { message: "Enter your message to AI." },
|
|
20
|
+
result: "message from the user",
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
skipTest: true,
|
|
24
|
+
description: "Text Input Agent",
|
|
25
|
+
category: ["input"],
|
|
26
|
+
author: "Receptron team",
|
|
27
|
+
repository: "https://github.com/receptron/graphai",
|
|
28
|
+
license: "MIT",
|
|
29
|
+
};
|
|
30
|
+
exports.default = textInputAgentInfo;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { AgentFunction } from "../../index";
|
|
2
|
+
export declare const anthropicAgent: AgentFunction<{
|
|
3
|
+
model?: string;
|
|
4
|
+
query?: string;
|
|
5
|
+
system?: string;
|
|
6
|
+
temperature?: number;
|
|
7
|
+
max_tokens?: number;
|
|
8
|
+
}, Record<string, any> | string, string | Array<any>>;
|
|
9
|
+
declare const anthropicAgentInfo: {
|
|
10
|
+
name: string;
|
|
11
|
+
agent: AgentFunction<{
|
|
12
|
+
model?: string | undefined;
|
|
13
|
+
query?: string | undefined;
|
|
14
|
+
system?: string | undefined;
|
|
15
|
+
temperature?: number | undefined;
|
|
16
|
+
max_tokens?: number | undefined;
|
|
17
|
+
}, string | Record<string, any>, string | any[]>;
|
|
18
|
+
mock: AgentFunction<{
|
|
19
|
+
model?: string | undefined;
|
|
20
|
+
query?: string | undefined;
|
|
21
|
+
system?: string | undefined;
|
|
22
|
+
temperature?: number | undefined;
|
|
23
|
+
max_tokens?: number | undefined;
|
|
24
|
+
}, string | Record<string, any>, string | any[]>;
|
|
25
|
+
samples: never[];
|
|
26
|
+
skipTest: boolean;
|
|
27
|
+
description: string;
|
|
28
|
+
category: string[];
|
|
29
|
+
author: string;
|
|
30
|
+
repository: string;
|
|
31
|
+
license: string;
|
|
32
|
+
npms: string[];
|
|
33
|
+
};
|
|
34
|
+
export default anthropicAgentInfo;
|
|
@@ -0,0 +1,47 @@
|
|
|
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.anthropicAgent = void 0;
|
|
7
|
+
const sdk_1 = __importDefault(require("@anthropic-ai/sdk"));
|
|
8
|
+
const anthropicAgent = async ({ params, inputs }) => {
|
|
9
|
+
const { query, system, temperature, max_tokens } = params;
|
|
10
|
+
const [input_query, previous_messages] = inputs;
|
|
11
|
+
// Notice that we ignore params.system if previous_message exists.
|
|
12
|
+
const messages = previous_messages && Array.isArray(previous_messages) ? previous_messages : system ? [{ role: "system", content: system }] : [];
|
|
13
|
+
const content = (query ? [query] : []).concat(input_query ? [input_query] : []).join("\n");
|
|
14
|
+
if (content) {
|
|
15
|
+
messages.push({
|
|
16
|
+
role: "user",
|
|
17
|
+
content,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
const anthropic = new sdk_1.default({
|
|
21
|
+
apiKey: process.env["ANTHROPIC_API_KEY"], // This is the default and can be omitted
|
|
22
|
+
});
|
|
23
|
+
return await anthropic.messages.create({
|
|
24
|
+
model: params.model || "claude-3-haiku-20240307", // "claude-3-opus-20240229",
|
|
25
|
+
messages,
|
|
26
|
+
temperature: temperature ?? 0.7,
|
|
27
|
+
max_tokens: max_tokens ?? 1024,
|
|
28
|
+
// tools: params.tools,
|
|
29
|
+
// tool_choice: params.tool_choice,
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
exports.anthropicAgent = anthropicAgent;
|
|
33
|
+
const anthropicAgentInfo = {
|
|
34
|
+
name: "anthropicAgent",
|
|
35
|
+
agent: exports.anthropicAgent,
|
|
36
|
+
mock: exports.anthropicAgent,
|
|
37
|
+
samples: [],
|
|
38
|
+
skipTest: true,
|
|
39
|
+
description: "Anthropic Agent",
|
|
40
|
+
category: ["llm"],
|
|
41
|
+
author: "Receptron team",
|
|
42
|
+
repository: "https://github.com/receptron/graphai",
|
|
43
|
+
license: "MIT",
|
|
44
|
+
// stream: true,
|
|
45
|
+
npms: ["@anthropic-ai/sdk"],
|
|
46
|
+
};
|
|
47
|
+
exports.default = anthropicAgentInfo;
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { AgentFunction } from "../../
|
|
1
|
+
import { AgentFunction } from "../../index";
|
|
2
2
|
import { Groq } from "groq-sdk";
|
|
3
3
|
export declare const groqAgent: AgentFunction<{
|
|
4
4
|
model: string;
|
|
5
5
|
query?: string;
|
|
6
6
|
system?: string;
|
|
7
7
|
verbose?: boolean;
|
|
8
|
-
tools?:
|
|
8
|
+
tools?: Groq.Chat.CompletionCreateParams.Tool[];
|
|
9
9
|
temperature?: number;
|
|
10
10
|
max_tokens?: number;
|
|
11
|
-
tool_choice?:
|
|
12
|
-
|
|
11
|
+
tool_choice?: Groq.Chat.CompletionCreateParams.ToolChoice;
|
|
12
|
+
stream?: boolean;
|
|
13
|
+
}, any, string | Array<Groq.Chat.CompletionCreateParams.Message>>;
|
|
13
14
|
declare const groqAgentInfo: {
|
|
14
15
|
name: string;
|
|
15
16
|
agent: AgentFunction<{
|
|
@@ -17,26 +18,30 @@ declare const groqAgentInfo: {
|
|
|
17
18
|
query?: string | undefined;
|
|
18
19
|
system?: string | undefined;
|
|
19
20
|
verbose?: boolean | undefined;
|
|
20
|
-
tools?:
|
|
21
|
+
tools?: Groq.Chat.Completions.CompletionCreateParams.Tool[] | undefined;
|
|
21
22
|
temperature?: number | undefined;
|
|
22
23
|
max_tokens?: number | undefined;
|
|
23
|
-
tool_choice?:
|
|
24
|
-
|
|
24
|
+
tool_choice?: Groq.Chat.Completions.CompletionCreateParams.ToolChoice | undefined;
|
|
25
|
+
stream?: boolean | undefined;
|
|
26
|
+
}, any, string | Groq.Chat.Completions.CompletionCreateParams.Message[]>;
|
|
25
27
|
mock: AgentFunction<{
|
|
26
28
|
model: string;
|
|
27
29
|
query?: string | undefined;
|
|
28
30
|
system?: string | undefined;
|
|
29
31
|
verbose?: boolean | undefined;
|
|
30
|
-
tools?:
|
|
32
|
+
tools?: Groq.Chat.Completions.CompletionCreateParams.Tool[] | undefined;
|
|
31
33
|
temperature?: number | undefined;
|
|
32
34
|
max_tokens?: number | undefined;
|
|
33
|
-
tool_choice?:
|
|
34
|
-
|
|
35
|
+
tool_choice?: Groq.Chat.Completions.CompletionCreateParams.ToolChoice | undefined;
|
|
36
|
+
stream?: boolean | undefined;
|
|
37
|
+
}, any, string | Groq.Chat.Completions.CompletionCreateParams.Message[]>;
|
|
35
38
|
samples: never[];
|
|
36
39
|
description: string;
|
|
37
40
|
category: string[];
|
|
38
41
|
author: string;
|
|
39
42
|
repository: string;
|
|
40
43
|
license: string;
|
|
44
|
+
stream: boolean;
|
|
45
|
+
npms: string[];
|
|
41
46
|
};
|
|
42
47
|
export default groqAgentInfo;
|
|
@@ -22,9 +22,9 @@ const groq = process.env.GROQ_API_KEY ? new groq_sdk_1.Groq({ apiKey: process.en
|
|
|
22
22
|
//
|
|
23
23
|
// https://console.groq.com/docs/quickstart
|
|
24
24
|
//
|
|
25
|
-
const groqAgent = async ({ params, inputs }) => {
|
|
25
|
+
const groqAgent = async ({ params, inputs, filterParams }) => {
|
|
26
26
|
(0, utils_1.assert)(groq !== undefined, "The GROQ_API_KEY environment variable is missing.");
|
|
27
|
-
const { verbose, query, system, tools, tool_choice, max_tokens, temperature } = params;
|
|
27
|
+
const { verbose, query, system, tools, tool_choice, max_tokens, temperature, stream } = params;
|
|
28
28
|
const [input_query, previous_messages] = inputs;
|
|
29
29
|
// Notice that we ignore params.system if previous_message exists.
|
|
30
30
|
const messages = previous_messages && Array.isArray(previous_messages) ? previous_messages : system ? [{ role: "system", content: system }] : [];
|
|
@@ -38,11 +38,18 @@ const groqAgent = async ({ params, inputs }) => {
|
|
|
38
38
|
if (verbose) {
|
|
39
39
|
console.log(messages);
|
|
40
40
|
}
|
|
41
|
-
const
|
|
41
|
+
const streamOption = {
|
|
42
42
|
messages,
|
|
43
43
|
model: params.model,
|
|
44
44
|
temperature: temperature ?? 0.7,
|
|
45
|
+
stream: true,
|
|
45
46
|
};
|
|
47
|
+
const nonStreamOption = {
|
|
48
|
+
messages,
|
|
49
|
+
model: params.model,
|
|
50
|
+
temperature: temperature ?? 0.7,
|
|
51
|
+
};
|
|
52
|
+
const options = stream ? streamOption : nonStreamOption;
|
|
46
53
|
if (max_tokens) {
|
|
47
54
|
options.max_tokens = max_tokens;
|
|
48
55
|
}
|
|
@@ -50,8 +57,28 @@ const groqAgent = async ({ params, inputs }) => {
|
|
|
50
57
|
options.tools = tools;
|
|
51
58
|
options.tool_choice = tool_choice ?? "auto";
|
|
52
59
|
}
|
|
53
|
-
|
|
54
|
-
|
|
60
|
+
if (!options.stream) {
|
|
61
|
+
const result = await groq.chat.completions.create(options);
|
|
62
|
+
return result;
|
|
63
|
+
}
|
|
64
|
+
// streaming
|
|
65
|
+
const pipe = await groq.chat.completions.create(options);
|
|
66
|
+
let lastMessage = null;
|
|
67
|
+
const contents = [];
|
|
68
|
+
for await (const message of pipe) {
|
|
69
|
+
const token = message.choices[0].delta.content;
|
|
70
|
+
if (token) {
|
|
71
|
+
if (filterParams && filterParams.streamTokenCallback) {
|
|
72
|
+
filterParams.streamTokenCallback(token);
|
|
73
|
+
}
|
|
74
|
+
contents.push(token);
|
|
75
|
+
}
|
|
76
|
+
lastMessage = message;
|
|
77
|
+
}
|
|
78
|
+
if (lastMessage) {
|
|
79
|
+
lastMessage.choices[0]["message"] = [{ role: "assistant", content: contents.join("") }];
|
|
80
|
+
}
|
|
81
|
+
return lastMessage;
|
|
55
82
|
};
|
|
56
83
|
exports.groqAgent = groqAgent;
|
|
57
84
|
const groqAgentInfo = {
|
|
@@ -64,5 +91,7 @@ const groqAgentInfo = {
|
|
|
64
91
|
author: "Receptron team",
|
|
65
92
|
repository: "https://github.com/receptron/graphai",
|
|
66
93
|
license: "MIT",
|
|
94
|
+
stream: true,
|
|
95
|
+
npms: ["groq-sdk"],
|
|
67
96
|
};
|
|
68
97
|
exports.default = groqAgentInfo;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import groqAgent from "../../experimental_agents/llm_agents/groq_agent";
|
|
2
|
-
import groqStreamAgent from "../../experimental_agents/llm_agents/groq_stream_agent";
|
|
3
2
|
import slashGPTAgent from "../../experimental_agents/llm_agents/slashgpt_agent";
|
|
4
3
|
import openAIAgent from "../../experimental_agents/llm_agents/openai_agent";
|
|
5
|
-
|
|
4
|
+
import anthropicAgent from "../../experimental_agents/llm_agents/anthropic_agent";
|
|
5
|
+
export { groqAgent, slashGPTAgent, openAIAgent, anthropicAgent };
|
|
@@ -3,12 +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.
|
|
6
|
+
exports.anthropicAgent = exports.openAIAgent = exports.slashGPTAgent = exports.groqAgent = void 0;
|
|
7
7
|
const groq_agent_1 = __importDefault(require("../../experimental_agents/llm_agents/groq_agent"));
|
|
8
8
|
exports.groqAgent = groq_agent_1.default;
|
|
9
|
-
const groq_stream_agent_1 = __importDefault(require("../../experimental_agents/llm_agents/groq_stream_agent"));
|
|
10
|
-
exports.groqStreamAgent = groq_stream_agent_1.default;
|
|
11
9
|
const slashgpt_agent_1 = __importDefault(require("../../experimental_agents/llm_agents/slashgpt_agent"));
|
|
12
10
|
exports.slashGPTAgent = slashgpt_agent_1.default;
|
|
13
11
|
const openai_agent_1 = __importDefault(require("../../experimental_agents/llm_agents/openai_agent"));
|
|
14
12
|
exports.openAIAgent = openai_agent_1.default;
|
|
13
|
+
const anthropic_agent_1 = __importDefault(require("../../experimental_agents/llm_agents/anthropic_agent"));
|
|
14
|
+
exports.anthropicAgent = anthropic_agent_1.default;
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import { AgentFunction } from "../../
|
|
1
|
+
import { AgentFunction } from "../../index";
|
|
2
2
|
export declare const openAIAgent: AgentFunction<{
|
|
3
3
|
model?: string;
|
|
4
4
|
query?: string;
|
|
5
5
|
system?: string;
|
|
6
|
+
tools?: any;
|
|
7
|
+
tool_choice?: any;
|
|
6
8
|
verbose?: boolean;
|
|
7
9
|
temperature?: number;
|
|
10
|
+
baseURL?: string;
|
|
11
|
+
apiKey?: string;
|
|
12
|
+
stream?: boolean;
|
|
8
13
|
}, Record<string, any> | string, string | Array<any>>;
|
|
9
14
|
export declare const openAIMockAgent: AgentFunction<{
|
|
10
15
|
model?: string;
|
|
@@ -19,8 +24,13 @@ declare const openaiAgentInfo: {
|
|
|
19
24
|
model?: string | undefined;
|
|
20
25
|
query?: string | undefined;
|
|
21
26
|
system?: string | undefined;
|
|
27
|
+
tools?: any;
|
|
28
|
+
tool_choice?: any;
|
|
22
29
|
verbose?: boolean | undefined;
|
|
23
30
|
temperature?: number | undefined;
|
|
31
|
+
baseURL?: string | undefined;
|
|
32
|
+
apiKey?: string | undefined;
|
|
33
|
+
stream?: boolean | undefined;
|
|
24
34
|
}, string | Record<string, any>, string | any[]>;
|
|
25
35
|
mock: AgentFunction<{
|
|
26
36
|
model?: string | undefined;
|
|
@@ -54,5 +64,7 @@ declare const openaiAgentInfo: {
|
|
|
54
64
|
author: string;
|
|
55
65
|
repository: string;
|
|
56
66
|
license: string;
|
|
67
|
+
stream: boolean;
|
|
68
|
+
npms: string[];
|
|
57
69
|
};
|
|
58
70
|
export default openaiAgentInfo;
|
|
@@ -7,7 +7,7 @@ exports.openAIMockAgent = exports.openAIAgent = void 0;
|
|
|
7
7
|
const openai_1 = __importDefault(require("openai"));
|
|
8
8
|
const utils_1 = require("../../utils/utils");
|
|
9
9
|
const openAIAgent = async ({ filterParams, params, inputs }) => {
|
|
10
|
-
const { verbose, query, system, temperature } = params;
|
|
10
|
+
const { verbose, query, system, temperature, baseURL, apiKey, stream } = params;
|
|
11
11
|
const [input_query, previous_messages] = inputs;
|
|
12
12
|
// Notice that we ignore params.system if previous_message exists.
|
|
13
13
|
const messages = previous_messages && Array.isArray(previous_messages) ? previous_messages : system ? [{ role: "system", content: system }] : [];
|
|
@@ -21,10 +21,21 @@ const openAIAgent = async ({ filterParams, params, inputs }) => {
|
|
|
21
21
|
if (verbose) {
|
|
22
22
|
console.log(messages);
|
|
23
23
|
}
|
|
24
|
-
const openai = new openai_1.default();
|
|
24
|
+
const openai = apiKey && baseURL ? new openai_1.default({ apiKey, baseURL }) : new openai_1.default();
|
|
25
|
+
if (!stream) {
|
|
26
|
+
return await openai.chat.completions.create({
|
|
27
|
+
model: params.model || "gpt-3.5-turbo",
|
|
28
|
+
messages,
|
|
29
|
+
tools: params.tools,
|
|
30
|
+
tool_choice: params.tool_choice,
|
|
31
|
+
temperature: temperature ?? 0.7,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
25
34
|
const chatStream = await openai.beta.chat.completions.stream({
|
|
26
35
|
model: params.model || "gpt-3.5-turbo",
|
|
27
36
|
messages,
|
|
37
|
+
tools: params.tools,
|
|
38
|
+
tool_choice: params.tool_choice,
|
|
28
39
|
temperature: temperature ?? 0.7,
|
|
29
40
|
stream: true,
|
|
30
41
|
});
|
|
@@ -83,5 +94,7 @@ const openaiAgentInfo = {
|
|
|
83
94
|
author: "Receptron team",
|
|
84
95
|
repository: "https://github.com/receptron/graphai",
|
|
85
96
|
license: "MIT",
|
|
97
|
+
stream: true,
|
|
98
|
+
npms: ["openai"],
|
|
86
99
|
};
|
|
87
100
|
exports.default = openaiAgentInfo;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import groqAgent from "../../experimental_agents/llm_agents/groq_agent";
|
|
2
|
-
import groqStreamAgent from "../../experimental_agents/llm_agents/groq_stream_agent";
|
|
3
2
|
import slashGPTAgent from "../../experimental_agents/llm_agents/slashgpt_agent";
|
|
4
3
|
import openAIAgent from "../../experimental_agents/llm_agents/openai_agent";
|
|
5
|
-
|
|
4
|
+
import anthropicAgent from "../../experimental_agents/llm_agents/openai_agent";
|
|
5
|
+
export { groqAgent, slashGPTAgent, openAIAgent, anthropicAgent };
|
|
@@ -3,12 +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.
|
|
6
|
+
exports.anthropicAgent = exports.openAIAgent = exports.slashGPTAgent = exports.groqAgent = void 0;
|
|
7
7
|
const groq_agent_1 = __importDefault(require("../../experimental_agents/llm_agents/groq_agent"));
|
|
8
8
|
exports.groqAgent = groq_agent_1.default;
|
|
9
|
-
const groq_stream_agent_1 = __importDefault(require("../../experimental_agents/llm_agents/groq_stream_agent"));
|
|
10
|
-
exports.groqStreamAgent = groq_stream_agent_1.default;
|
|
11
9
|
const slashgpt_agent_1 = __importDefault(require("../../experimental_agents/llm_agents/slashgpt_agent"));
|
|
12
10
|
exports.slashGPTAgent = slashgpt_agent_1.default;
|
|
13
11
|
const openai_agent_1 = __importDefault(require("../../experimental_agents/llm_agents/openai_agent"));
|
|
14
12
|
exports.openAIAgent = openai_agent_1.default;
|
|
13
|
+
const openai_agent_2 = __importDefault(require("../../experimental_agents/llm_agents/openai_agent"));
|
|
14
|
+
exports.anthropicAgent = openai_agent_2.default;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AgentFunction } from "../../
|
|
1
|
+
import { AgentFunction } from "../../index";
|
|
2
2
|
import { ManifestData, ChatData } from "slashgpt";
|
|
3
3
|
export declare const slashGPTAgent: AgentFunction<{
|
|
4
4
|
manifest: ManifestData;
|
|
@@ -23,5 +23,7 @@ declare const slashGPTAgentInfo: {
|
|
|
23
23
|
author: string;
|
|
24
24
|
repository: string;
|
|
25
25
|
license: string;
|
|
26
|
+
stream: boolean;
|
|
27
|
+
npms: string[];
|
|
26
28
|
};
|
|
27
29
|
export default slashGPTAgentInfo;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AgentFunction } from "../../
|
|
1
|
+
import { AgentFunction } from "../../index";
|
|
2
2
|
export declare const dotProductAgent: AgentFunction<Record<never, never>, Array<number>, Array<Array<number>> | Array<number>>;
|
|
3
3
|
declare const dotProductAgentInfo: {
|
|
4
4
|
name: string;
|
|
@@ -10,7 +10,7 @@ declare const dotProductAgentInfo: {
|
|
|
10
10
|
result: number[];
|
|
11
11
|
}[];
|
|
12
12
|
description: string;
|
|
13
|
-
category:
|
|
13
|
+
category: string[];
|
|
14
14
|
author: string;
|
|
15
15
|
repository: string;
|
|
16
16
|
license: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AgentFunction } from "../../
|
|
1
|
+
import { AgentFunction } from "../../index";
|
|
2
2
|
export declare const sortByValuesAgent: AgentFunction<{
|
|
3
3
|
assendant?: boolean;
|
|
4
4
|
}, Array<any>, Array<any>>;
|
|
@@ -24,7 +24,7 @@ declare const sortByValuesAgentInfo: {
|
|
|
24
24
|
result: string[];
|
|
25
25
|
})[];
|
|
26
26
|
description: string;
|
|
27
|
-
category:
|
|
27
|
+
category: string[];
|
|
28
28
|
author: string;
|
|
29
29
|
repository: string;
|
|
30
30
|
license: string;
|