graphai 0.4.2 → 0.4.4
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 +15 -80
- package/lib/experimental_agents/array_agents/push_agent.d.ts +1 -1
- package/lib/experimental_agents/array_agents/push_agent.js +1 -1
- package/lib/experimental_agents/array_agents/shift_agent.d.ts +1 -1
- package/lib/experimental_agents/array_agents/shift_agent.js +1 -1
- package/lib/experimental_agents/data_agents/property_filter_agent.d.ts +45 -0
- package/lib/experimental_agents/data_agents/property_filter_agent.js +28 -4
- package/lib/experimental_agents/embedding_agent.d.ts +1 -1
- package/lib/experimental_agents/embedding_agent.js +1 -1
- package/lib/experimental_agents/graph_agents/map_agent.d.ts +1 -1
- package/lib/experimental_agents/graph_agents/map_agent.js +1 -1
- package/lib/experimental_agents/graph_agents/nested_agent.d.ts +1 -1
- package/lib/experimental_agents/graph_agents/nested_agent.js +1 -1
- 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 +1 -2
- package/lib/experimental_agents/index.js +1 -3
- package/lib/experimental_agents/input_agents/text_input_agent.d.ts +8 -1
- package/lib/experimental_agents/input_agents/text_input_agent.js +9 -2
- 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 +5 -3
- package/lib/experimental_agents/llm_agents/groq_agent.js +6 -4
- 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 +8 -0
- package/lib/experimental_agents/llm_agents/openai_agent.js +13 -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 +2 -0
- package/lib/experimental_agents/llm_agents/slashgpt_agent.js +2 -0
- package/lib/experimental_agents/matrix_agents/dot_product_agent.d.ts +1 -1
- package/lib/experimental_agents/matrix_agents/dot_product_agent.js +1 -1
- package/lib/experimental_agents/matrix_agents/sort_by_values_agent.d.ts +1 -1
- package/lib/experimental_agents/matrix_agents/sort_by_values_agent.js +1 -1
- package/lib/experimental_agents/service_agents/fetch_agent.js +3 -2
- package/lib/experimental_agents/service_agents/wikipedia.js +1 -1
- package/lib/experimental_agents/sleeper_agents/sleeper_agent.d.ts +1 -1
- package/lib/experimental_agents/sleeper_agents/sleeper_agent.js +1 -1
- package/lib/experimental_agents/sleeper_agents/sleeper_agent_debug.d.ts +1 -1
- 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.js +1 -1
- package/lib/experimental_agents/string_agents/string_template_agent.d.ts +9 -7
- package/lib/experimental_agents/string_agents/string_template_agent.js +4 -1
- 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.js +1 -1
- package/lib/experimental_agents/test_agents/copy2array_agent.js +1 -1
- package/lib/experimental_agents/test_agents/copy_message_agent.js +1 -1
- package/lib/experimental_agents/test_agents/counting_agent.js +1 -1
- package/lib/experimental_agents/test_agents/echo_agent.js +13 -2
- package/lib/experimental_agents/test_agents/merge_node_id_agent.js +1 -1
- package/lib/experimental_agents/test_agents/stream_mock_agent.js +9 -2
- package/lib/experimental_agents/vanilla.d.ts +1 -2
- package/lib/experimental_agents/vanilla.js +1 -3
- package/lib/graphai.d.ts +5 -5
- package/lib/graphai.js +9 -9
- package/lib/index.d.ts +2 -1
- package/lib/index.js +3 -1
- package/lib/node.d.ts +2 -1
- package/lib/node.js +37 -11
- package/lib/transaction_log.d.ts +1 -0
- package/lib/transaction_log.js +2 -0
- package/lib/type.d.ts +11 -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 +10 -1
- 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 +3 -4
- 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
|
@@ -13,9 +13,16 @@ const textInputAgentInfo = {
|
|
|
13
13
|
name: "textInputAgent",
|
|
14
14
|
agent: exports.textInputAgent,
|
|
15
15
|
mock: exports.textInputAgent,
|
|
16
|
-
samples: [
|
|
16
|
+
samples: [
|
|
17
|
+
{
|
|
18
|
+
inputs: [],
|
|
19
|
+
params: { message: "Enter your message to AI." },
|
|
20
|
+
result: "message from the user",
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
skipTest: true,
|
|
17
24
|
description: "Text Input Agent",
|
|
18
|
-
category: ["
|
|
25
|
+
category: ["input"],
|
|
19
26
|
author: "Receptron team",
|
|
20
27
|
repository: "https://github.com/receptron/graphai",
|
|
21
28
|
license: "MIT",
|
|
@@ -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;
|
|
@@ -9,7 +9,7 @@ export declare const groqAgent: AgentFunction<{
|
|
|
9
9
|
temperature?: number;
|
|
10
10
|
max_tokens?: number;
|
|
11
11
|
tool_choice?: Groq.Chat.CompletionCreateParams.ToolChoice;
|
|
12
|
-
|
|
12
|
+
stream?: boolean;
|
|
13
13
|
}, any, string | Array<Groq.Chat.CompletionCreateParams.Message>>;
|
|
14
14
|
declare const groqAgentInfo: {
|
|
15
15
|
name: string;
|
|
@@ -22,7 +22,7 @@ declare const groqAgentInfo: {
|
|
|
22
22
|
temperature?: number | undefined;
|
|
23
23
|
max_tokens?: number | undefined;
|
|
24
24
|
tool_choice?: Groq.Chat.Completions.CompletionCreateParams.ToolChoice | undefined;
|
|
25
|
-
|
|
25
|
+
stream?: boolean | undefined;
|
|
26
26
|
}, any, string | Groq.Chat.Completions.CompletionCreateParams.Message[]>;
|
|
27
27
|
mock: AgentFunction<{
|
|
28
28
|
model: string;
|
|
@@ -33,7 +33,7 @@ declare const groqAgentInfo: {
|
|
|
33
33
|
temperature?: number | undefined;
|
|
34
34
|
max_tokens?: number | undefined;
|
|
35
35
|
tool_choice?: Groq.Chat.Completions.CompletionCreateParams.ToolChoice | undefined;
|
|
36
|
-
|
|
36
|
+
stream?: boolean | undefined;
|
|
37
37
|
}, any, string | Groq.Chat.Completions.CompletionCreateParams.Message[]>;
|
|
38
38
|
samples: never[];
|
|
39
39
|
description: string;
|
|
@@ -41,5 +41,7 @@ declare const groqAgentInfo: {
|
|
|
41
41
|
author: string;
|
|
42
42
|
repository: string;
|
|
43
43
|
license: string;
|
|
44
|
+
stream: boolean;
|
|
45
|
+
npms: string[];
|
|
44
46
|
};
|
|
45
47
|
export default groqAgentInfo;
|
|
@@ -24,7 +24,7 @@ const groq = process.env.GROQ_API_KEY ? new groq_sdk_1.Groq({ apiKey: process.en
|
|
|
24
24
|
//
|
|
25
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,
|
|
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 }] : [];
|
|
@@ -49,7 +49,7 @@ const groqAgent = async ({ params, inputs, filterParams }) => {
|
|
|
49
49
|
model: params.model,
|
|
50
50
|
temperature: temperature ?? 0.7,
|
|
51
51
|
};
|
|
52
|
-
const options =
|
|
52
|
+
const options = stream ? streamOption : nonStreamOption;
|
|
53
53
|
if (max_tokens) {
|
|
54
54
|
options.max_tokens = max_tokens;
|
|
55
55
|
}
|
|
@@ -62,10 +62,10 @@ const groqAgent = async ({ params, inputs, filterParams }) => {
|
|
|
62
62
|
return result;
|
|
63
63
|
}
|
|
64
64
|
// streaming
|
|
65
|
-
const
|
|
65
|
+
const pipe = await groq.chat.completions.create(options);
|
|
66
66
|
let lastMessage = null;
|
|
67
67
|
const contents = [];
|
|
68
|
-
for await (const message of
|
|
68
|
+
for await (const message of pipe) {
|
|
69
69
|
const token = message.choices[0].delta.content;
|
|
70
70
|
if (token) {
|
|
71
71
|
if (filterParams && filterParams.streamTokenCallback) {
|
|
@@ -91,5 +91,7 @@ const groqAgentInfo = {
|
|
|
91
91
|
author: "Receptron team",
|
|
92
92
|
repository: "https://github.com/receptron/graphai",
|
|
93
93
|
license: "MIT",
|
|
94
|
+
stream: true,
|
|
95
|
+
npms: ["groq-sdk"],
|
|
94
96
|
};
|
|
95
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;
|
|
@@ -7,6 +7,9 @@ export declare const openAIAgent: AgentFunction<{
|
|
|
7
7
|
tool_choice?: any;
|
|
8
8
|
verbose?: boolean;
|
|
9
9
|
temperature?: number;
|
|
10
|
+
baseURL?: string;
|
|
11
|
+
apiKey?: string;
|
|
12
|
+
stream?: boolean;
|
|
10
13
|
}, Record<string, any> | string, string | Array<any>>;
|
|
11
14
|
export declare const openAIMockAgent: AgentFunction<{
|
|
12
15
|
model?: string;
|
|
@@ -25,6 +28,9 @@ declare const openaiAgentInfo: {
|
|
|
25
28
|
tool_choice?: any;
|
|
26
29
|
verbose?: boolean | undefined;
|
|
27
30
|
temperature?: number | undefined;
|
|
31
|
+
baseURL?: string | undefined;
|
|
32
|
+
apiKey?: string | undefined;
|
|
33
|
+
stream?: boolean | undefined;
|
|
28
34
|
}, string | Record<string, any>, string | any[]>;
|
|
29
35
|
mock: AgentFunction<{
|
|
30
36
|
model?: string | undefined;
|
|
@@ -58,5 +64,7 @@ declare const openaiAgentInfo: {
|
|
|
58
64
|
author: string;
|
|
59
65
|
repository: string;
|
|
60
66
|
license: string;
|
|
67
|
+
stream: boolean;
|
|
68
|
+
npms: string[];
|
|
61
69
|
};
|
|
62
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,7 +21,16 @@ 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,
|
|
@@ -85,5 +94,7 @@ const openaiAgentInfo = {
|
|
|
85
94
|
author: "Receptron team",
|
|
86
95
|
repository: "https://github.com/receptron/graphai",
|
|
87
96
|
license: "MIT",
|
|
97
|
+
stream: true,
|
|
98
|
+
npms: ["openai"],
|
|
88
99
|
};
|
|
89
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;
|
|
@@ -29,7 +29,8 @@ const fetchAgent = async ({ inputs, params }) => {
|
|
|
29
29
|
const response = await fetch(url.toString(), fetchOptions);
|
|
30
30
|
if (!response.ok) {
|
|
31
31
|
const status = response.status;
|
|
32
|
-
const
|
|
32
|
+
const type = params?.type ?? "json";
|
|
33
|
+
const error = type === "json" ? await response.json() : await response.text();
|
|
33
34
|
if (params?.returnErrorResult) {
|
|
34
35
|
return { status, error };
|
|
35
36
|
}
|
|
@@ -87,7 +88,7 @@ const fetchAgentInfo = {
|
|
|
87
88
|
},
|
|
88
89
|
],
|
|
89
90
|
description: "Retrieves JSON data from the specified URL",
|
|
90
|
-
category: ["
|
|
91
|
+
category: ["service"],
|
|
91
92
|
author: "Receptron",
|
|
92
93
|
repository: "https://github.com/receptron/graphai",
|
|
93
94
|
license: "MIT",
|
|
@@ -30,7 +30,7 @@ const wikipediaAgentInfo = {
|
|
|
30
30
|
agent: exports.wikipediaAgent,
|
|
31
31
|
mock: exports.wikipediaAgent,
|
|
32
32
|
description: "Retrieves data from wikipedia",
|
|
33
|
-
category: ["
|
|
33
|
+
category: ["service"],
|
|
34
34
|
samples: [],
|
|
35
35
|
author: "Receptron",
|
|
36
36
|
repository: "https://github.com/receptron/graphai",
|
|
@@ -23,7 +23,7 @@ const sleeperAgentDebugInfo = {
|
|
|
23
23
|
mock: exports.sleeperAgentDebug,
|
|
24
24
|
samples: [],
|
|
25
25
|
description: "sleeper debug Agent",
|
|
26
|
-
category: [],
|
|
26
|
+
category: ["sleeper"],
|
|
27
27
|
author: "Receptron team",
|
|
28
28
|
repository: "https://github.com/receptron/graphai",
|
|
29
29
|
license: "MIT",
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { AgentFunction } from "../../index";
|
|
2
|
+
export declare const jsonParserAgent: AgentFunction<{
|
|
3
|
+
stringify: boolean;
|
|
4
|
+
}, any, any>;
|
|
5
|
+
declare const jsonParserAgentInfo: {
|
|
6
|
+
name: string;
|
|
7
|
+
agent: AgentFunction<{
|
|
8
|
+
stringify: boolean;
|
|
9
|
+
}, any, any>;
|
|
10
|
+
mock: AgentFunction<{
|
|
11
|
+
stringify: boolean;
|
|
12
|
+
}, any, any>;
|
|
13
|
+
samples: ({
|
|
14
|
+
inputs: {
|
|
15
|
+
apple: string;
|
|
16
|
+
lemon: string;
|
|
17
|
+
}[];
|
|
18
|
+
params: {
|
|
19
|
+
stringify: boolean;
|
|
20
|
+
};
|
|
21
|
+
result: string;
|
|
22
|
+
} | {
|
|
23
|
+
inputs: string[];
|
|
24
|
+
params: {
|
|
25
|
+
stringify?: undefined;
|
|
26
|
+
};
|
|
27
|
+
result: {
|
|
28
|
+
apple: string;
|
|
29
|
+
lemon: string;
|
|
30
|
+
};
|
|
31
|
+
})[];
|
|
32
|
+
description: string;
|
|
33
|
+
category: string[];
|
|
34
|
+
author: string;
|
|
35
|
+
repository: string;
|
|
36
|
+
license: string;
|
|
37
|
+
};
|
|
38
|
+
export default jsonParserAgentInfo;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.jsonParserAgent = void 0;
|
|
4
|
+
const jsonParserAgent = async ({ params, inputs }) => {
|
|
5
|
+
if (params.stringify) {
|
|
6
|
+
return JSON.stringify(inputs[0], null, 2);
|
|
7
|
+
}
|
|
8
|
+
const match = ("\n" + inputs[0]).match(/\n```[a-zA-z]*([\s\S]*?)\n```/);
|
|
9
|
+
if (match) {
|
|
10
|
+
return JSON.parse(match[1]);
|
|
11
|
+
}
|
|
12
|
+
return JSON.parse(inputs[0]);
|
|
13
|
+
};
|
|
14
|
+
exports.jsonParserAgent = jsonParserAgent;
|
|
15
|
+
const sample_object = { apple: "red", lemon: "yellow" };
|
|
16
|
+
// for test and document
|
|
17
|
+
const jsonParserAgentInfo = {
|
|
18
|
+
name: "jsonParserAgent",
|
|
19
|
+
agent: exports.jsonParserAgent,
|
|
20
|
+
mock: exports.jsonParserAgent,
|
|
21
|
+
samples: [
|
|
22
|
+
{
|
|
23
|
+
inputs: [sample_object],
|
|
24
|
+
params: { stringify: true },
|
|
25
|
+
result: JSON.stringify(sample_object, null, 2),
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
inputs: [JSON.stringify(sample_object, null, 2)],
|
|
29
|
+
params: {},
|
|
30
|
+
result: sample_object,
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
description: "Template agent",
|
|
34
|
+
category: ["string"],
|
|
35
|
+
author: "Satoshi Nakajima",
|
|
36
|
+
repository: "https://github.com/receptron/graphai",
|
|
37
|
+
license: "MIT",
|
|
38
|
+
};
|
|
39
|
+
exports.default = jsonParserAgentInfo;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import stringSplitterAgent from "../../experimental_agents/string_agents/string_splitter_agent";
|
|
2
2
|
import stringTemplateAgent from "../../experimental_agents/string_agents/string_template_agent";
|
|
3
|
-
|
|
3
|
+
import jsonParserAgent from "../../experimental_agents/string_agents/json_parser_agent";
|
|
4
|
+
export { stringSplitterAgent, stringTemplateAgent, jsonParserAgent };
|
|
@@ -3,8 +3,10 @@ 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.stringTemplateAgent = exports.stringSplitterAgent = void 0;
|
|
6
|
+
exports.jsonParserAgent = exports.stringTemplateAgent = exports.stringSplitterAgent = void 0;
|
|
7
7
|
const string_splitter_agent_1 = __importDefault(require("../../experimental_agents/string_agents/string_splitter_agent"));
|
|
8
8
|
exports.stringSplitterAgent = string_splitter_agent_1.default;
|
|
9
9
|
const string_template_agent_1 = __importDefault(require("../../experimental_agents/string_agents/string_template_agent"));
|
|
10
10
|
exports.stringTemplateAgent = string_template_agent_1.default;
|
|
11
|
+
const json_parser_agent_1 = __importDefault(require("../../experimental_agents/string_agents/json_parser_agent"));
|
|
12
|
+
exports.jsonParserAgent = json_parser_agent_1.default;
|
|
@@ -57,7 +57,7 @@ const stringSplitterAgentInfo = {
|
|
|
57
57
|
},
|
|
58
58
|
],
|
|
59
59
|
description: "This agent strip one long string into chunks using following parameters",
|
|
60
|
-
category: [],
|
|
60
|
+
category: ["string"],
|
|
61
61
|
author: "Satoshi Nakajima",
|
|
62
62
|
repository: "https://github.com/receptron/graphai",
|
|
63
63
|
license: "MIT",
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { AgentFunction } from "../../index";
|
|
2
|
+
type StringTemplate = string | Record<string, string>;
|
|
3
|
+
type StringTemplateObject = StringTemplate | StringTemplate[] | Record<string, StringTemplate>;
|
|
2
4
|
export declare const stringTemplateAgent: AgentFunction<{
|
|
3
|
-
template:
|
|
4
|
-
},
|
|
5
|
+
template: StringTemplateObject;
|
|
6
|
+
}, StringTemplateObject, string>;
|
|
5
7
|
declare const stringTemplateAgentInfo: {
|
|
6
8
|
name: string;
|
|
7
9
|
agent: AgentFunction<{
|
|
8
|
-
template:
|
|
9
|
-
},
|
|
10
|
+
template: StringTemplateObject;
|
|
11
|
+
}, StringTemplateObject, string>;
|
|
10
12
|
mock: AgentFunction<{
|
|
11
|
-
template:
|
|
12
|
-
},
|
|
13
|
+
template: StringTemplateObject;
|
|
14
|
+
}, StringTemplateObject, string>;
|
|
13
15
|
samples: ({
|
|
14
16
|
inputs: string[];
|
|
15
17
|
params: {
|
|
@@ -60,7 +62,7 @@ declare const stringTemplateAgentInfo: {
|
|
|
60
62
|
};
|
|
61
63
|
})[];
|
|
62
64
|
description: string;
|
|
63
|
-
category:
|
|
65
|
+
category: string[];
|
|
64
66
|
author: string;
|
|
65
67
|
repository: string;
|
|
66
68
|
license: string;
|
|
@@ -14,6 +14,9 @@ const processTemplate = (template, match, input) => {
|
|
|
14
14
|
}, {});
|
|
15
15
|
};
|
|
16
16
|
const stringTemplateAgent = async ({ params, inputs }) => {
|
|
17
|
+
if (params.template === undefined) {
|
|
18
|
+
console.warn("warning: stringTemplateAgent no template");
|
|
19
|
+
}
|
|
17
20
|
return inputs.reduce((template, input, index) => {
|
|
18
21
|
return processTemplate(template, "${" + index + "}", input);
|
|
19
22
|
}, params.template);
|
|
@@ -53,7 +56,7 @@ const stringTemplateAgentInfo = {
|
|
|
53
56
|
},
|
|
54
57
|
],
|
|
55
58
|
description: "Template agent",
|
|
56
|
-
category: [],
|
|
59
|
+
category: ["string"],
|
|
57
60
|
author: "Satoshi Nakajima",
|
|
58
61
|
repository: "https://github.com/receptron/graphai",
|
|
59
62
|
license: "MIT",
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import stringSplitterAgent from "../../experimental_agents/string_agents/string_splitter_agent";
|
|
2
2
|
import stringTemplateAgent from "../../experimental_agents/string_agents/string_template_agent";
|
|
3
|
-
|
|
3
|
+
import jsonParserAgent from "../../experimental_agents/string_agents/json_parser_agent";
|
|
4
|
+
export { stringSplitterAgent, stringTemplateAgent, jsonParserAgent };
|
|
@@ -3,8 +3,10 @@ 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.stringTemplateAgent = exports.stringSplitterAgent = void 0;
|
|
6
|
+
exports.jsonParserAgent = exports.stringTemplateAgent = exports.stringSplitterAgent = void 0;
|
|
7
7
|
const string_splitter_agent_1 = __importDefault(require("../../experimental_agents/string_agents/string_splitter_agent"));
|
|
8
8
|
exports.stringSplitterAgent = string_splitter_agent_1.default;
|
|
9
9
|
const string_template_agent_1 = __importDefault(require("../../experimental_agents/string_agents/string_template_agent"));
|
|
10
10
|
exports.stringTemplateAgent = string_template_agent_1.default;
|
|
11
|
+
const json_parser_agent_1 = __importDefault(require("../../experimental_agents/string_agents/json_parser_agent"));
|
|
12
|
+
exports.jsonParserAgent = json_parser_agent_1.default;
|