graphai 0.0.12 → 0.1.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/README.md +14 -10
- package/lib/experimental_agents/array_agents/index.d.ts +3 -0
- package/lib/experimental_agents/array_agents/index.js +9 -0
- package/lib/experimental_agents/array_agents/pop_agent.d.ts +2 -0
- package/lib/experimental_agents/array_agents/pop_agent.js +15 -0
- package/lib/experimental_agents/array_agents/push_agent.d.ts +2 -0
- package/lib/experimental_agents/array_agents/push_agent.js +14 -0
- package/lib/experimental_agents/array_agents/shift_agent.d.ts +2 -0
- package/lib/experimental_agents/{array_agents.js → array_agents/shift_agent.js} +2 -17
- package/lib/experimental_agents/data_agents/data_object_merge_template_agent.d.ts +2 -0
- package/lib/experimental_agents/data_agents/data_object_merge_template_agent.js +13 -0
- package/lib/experimental_agents/data_agents/data_sum_template_agent.d.ts +17 -0
- package/lib/experimental_agents/data_agents/data_sum_template_agent.js +30 -0
- package/lib/experimental_agents/data_agents/index.d.ts +3 -0
- package/lib/experimental_agents/data_agents/index.js +9 -0
- package/lib/experimental_agents/data_agents/total_agent.d.ts +46 -0
- package/lib/experimental_agents/data_agents/total_agent.js +51 -0
- package/lib/experimental_agents/embedding_agent.d.ts +6 -0
- package/lib/experimental_agents/embedding_agent.js +43 -0
- package/lib/experimental_agents/index.d.ts +8 -3
- package/lib/experimental_agents/index.js +8 -3
- package/lib/experimental_agents/map_agent.d.ts +4 -0
- package/lib/experimental_agents/map_agent.js +46 -0
- package/lib/experimental_agents/matrix_agent.d.ts +9 -0
- package/lib/experimental_agents/matrix_agent.js +50 -0
- package/lib/experimental_agents/nested_agent.d.ts +2 -2
- package/lib/experimental_agents/nested_agent.js +14 -8
- package/lib/experimental_agents/slashgpt_agent.d.ts +1 -1
- package/lib/experimental_agents/slashgpt_agent.js +2 -7
- package/lib/experimental_agents/sleeper_agents/index.d.ts +2 -0
- package/lib/experimental_agents/sleeper_agents/index.js +7 -0
- package/lib/experimental_agents/sleeper_agents/sleeper_agent.d.ts +5 -0
- package/lib/experimental_agents/sleeper_agents/sleeper_agent.js +16 -0
- package/lib/experimental_agents/sleeper_agents/sleeper_agent_debug.d.ts +6 -0
- package/lib/experimental_agents/{sleeper_agent.js → sleeper_agents/sleeper_agent_debug.js} +4 -13
- package/lib/experimental_agents/string_agents/index.d.ts +2 -0
- package/lib/experimental_agents/string_agents/index.js +7 -0
- package/lib/experimental_agents/string_agents/string_splitter_agent.d.ts +7 -0
- package/lib/experimental_agents/string_agents/string_splitter_agent.js +24 -0
- package/lib/experimental_agents/string_agents/string_template_agent.d.ts +4 -0
- package/lib/experimental_agents/{string_agent.js → string_agents/string_template_agent.js} +2 -5
- package/lib/experimental_agents/test_agents/bypass_agent.d.ts +2 -0
- package/lib/experimental_agents/test_agents/bypass_agent.js +10 -0
- package/lib/experimental_agents/test_agents/copy_message_agent.d.ts +2 -0
- package/lib/experimental_agents/test_agents/copy_message_agent.js +11 -0
- package/lib/experimental_agents/test_agents/counting_agent.d.ts +2 -0
- package/lib/experimental_agents/test_agents/counting_agent.js +11 -0
- package/lib/experimental_agents/test_agents/echo_agent.d.ts +2 -0
- package/lib/experimental_agents/test_agents/echo_agent.js +7 -0
- package/lib/experimental_agents/test_agents/echo_fork_index_agent.d.ts +2 -0
- package/lib/experimental_agents/test_agents/echo_fork_index_agent.js +7 -0
- package/lib/experimental_agents/test_agents/index.d.ts +5 -0
- package/lib/experimental_agents/test_agents/index.js +13 -0
- package/lib/experimental_agents/test_agents/merge_node_id_agent.d.ts +2 -0
- package/lib/experimental_agents/test_agents/merge_node_id_agent.js +10 -0
- package/lib/experimental_agents/token_agent.d.ts +6 -0
- package/lib/experimental_agents/token_agent.js +33 -0
- package/lib/graphai.d.ts +28 -111
- package/lib/graphai.js +140 -322
- package/lib/index.d.ts +2 -0
- package/lib/log.d.ts +22 -0
- package/lib/log.js +49 -0
- package/lib/node.d.ts +50 -0
- package/lib/node.js +218 -0
- package/lib/task.d.ts +18 -0
- package/lib/task.js +63 -0
- package/lib/task_manager.d.ts +20 -0
- package/lib/task_manager.js +69 -0
- package/lib/transaction_log.d.ts +27 -0
- package/lib/transaction_log.js +56 -0
- package/lib/type.d.ts +77 -0
- package/lib/type.js +14 -0
- package/lib/utils/utils.d.ts +4 -0
- package/lib/utils/utils.js +22 -1
- package/lib/validator.d.ts +2 -0
- package/lib/validator.js +28 -0
- package/lib/validators/agent_validator.d.ts +1 -0
- package/lib/validators/agent_validator.js +12 -0
- package/lib/validators/common.d.ts +3 -0
- package/lib/validators/common.js +6 -0
- package/lib/validators/computed_node_validator.d.ts +2 -0
- package/lib/validators/computed_node_validator.js +13 -0
- package/lib/validators/graph_data_validator.d.ts +3 -0
- package/lib/validators/graph_data_validator.js +43 -0
- package/lib/validators/nodeValidator.d.ts +2 -0
- package/lib/validators/nodeValidator.js +13 -0
- package/lib/validators/relation_validator.d.ts +2 -0
- package/lib/validators/relation_validator.js +62 -0
- package/lib/validators/static_node_validator.d.ts +2 -0
- package/lib/validators/static_node_validator.js +13 -0
- package/package.json +3 -5
- package/lib/experimental_agents/array_agents.d.ts +0 -4
- package/lib/experimental_agents/data_agent.d.ts +0 -3
- package/lib/experimental_agents/data_agent.js +0 -25
- package/lib/experimental_agents/sleeper_agent.d.ts +0 -10
- package/lib/experimental_agents/string_agent.d.ts +0 -7
- package/lib/graphai_cli.d.ts +0 -2
- package/lib/graphai_cli.js +0 -37
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sleeperAgentDebug = exports.sleeperAgent = void 0;
|
|
4
|
+
var sleeper_agent_1 = require("../../experimental_agents/sleeper_agents/sleeper_agent");
|
|
5
|
+
Object.defineProperty(exports, "sleeperAgent", { enumerable: true, get: function () { return sleeper_agent_1.sleeperAgent; } });
|
|
6
|
+
var sleeper_agent_debug_1 = require("../../experimental_agents/sleeper_agents/sleeper_agent_debug");
|
|
7
|
+
Object.defineProperty(exports, "sleeperAgentDebug", { enumerable: true, get: function () { return sleeper_agent_debug_1.sleeperAgentDebug; } });
|
|
@@ -0,0 +1,16 @@
|
|
|
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.sleeperAgent = void 0;
|
|
7
|
+
const utils_1 = require("../../utils/utils");
|
|
8
|
+
const deepmerge_1 = __importDefault(require("deepmerge"));
|
|
9
|
+
const sleeperAgent = async (context) => {
|
|
10
|
+
const { params, inputs } = context;
|
|
11
|
+
await (0, utils_1.sleep)(params?.duration ?? 10);
|
|
12
|
+
return inputs.reduce((result, input) => {
|
|
13
|
+
return (0, deepmerge_1.default)(result, input);
|
|
14
|
+
}, params.value ?? {});
|
|
15
|
+
};
|
|
16
|
+
exports.sleeperAgent = sleeperAgent;
|
|
@@ -3,22 +3,13 @@ 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.sleeperAgentDebug =
|
|
7
|
-
const utils_1 = require("
|
|
6
|
+
exports.sleeperAgentDebug = void 0;
|
|
7
|
+
const utils_1 = require("../../utils/utils");
|
|
8
8
|
const deepmerge_1 = __importDefault(require("deepmerge"));
|
|
9
|
-
const
|
|
10
|
-
const { params, inputs } = context;
|
|
11
|
-
await (0, utils_1.sleep)(params.duration);
|
|
12
|
-
return inputs.reduce((result, input) => {
|
|
13
|
-
return (0, deepmerge_1.default)(result, input);
|
|
14
|
-
}, params.value ?? {});
|
|
15
|
-
};
|
|
16
|
-
exports.sleeperAgent = sleeperAgent;
|
|
17
|
-
const sleeperAgentDebug = async (context) => {
|
|
18
|
-
const { nodeId, params, inputs, retry } = context;
|
|
9
|
+
const sleeperAgentDebug = async ({ params, inputs, debugInfo: { retry }, }) => {
|
|
19
10
|
await (0, utils_1.sleep)(params.duration / (retry + 1));
|
|
20
11
|
if (params.fail && retry < 2) {
|
|
21
|
-
console.log("failed (intentional)", nodeId, retry);
|
|
12
|
+
// console.log("failed (intentional)", nodeId, retry);
|
|
22
13
|
throw new Error("Intentional Failure");
|
|
23
14
|
}
|
|
24
15
|
return inputs.reduce((result, input) => {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.stringTemplateAgent = exports.stringSplitterAgent = void 0;
|
|
4
|
+
var string_splitter_agent_1 = require("../../experimental_agents/string_agents/string_splitter_agent");
|
|
5
|
+
Object.defineProperty(exports, "stringSplitterAgent", { enumerable: true, get: function () { return string_splitter_agent_1.stringSplitterAgent; } });
|
|
6
|
+
var string_template_agent_1 = require("../../experimental_agents/string_agents/string_template_agent");
|
|
7
|
+
Object.defineProperty(exports, "stringTemplateAgent", { enumerable: true, get: function () { return string_template_agent_1.stringTemplateAgent; } });
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.stringSplitterAgent = void 0;
|
|
4
|
+
// This agent strip one long string into chunks using following parameters
|
|
5
|
+
//
|
|
6
|
+
// chunkSize: number; // default is 2048
|
|
7
|
+
// overlap: number; // default is 1/8th of chunkSize.
|
|
8
|
+
//
|
|
9
|
+
// see example
|
|
10
|
+
// tests/agents/test_string_agent.ts
|
|
11
|
+
//
|
|
12
|
+
const defaultChunkSize = 2048;
|
|
13
|
+
const stringSplitterAgent = async ({ params, inputs }) => {
|
|
14
|
+
const source = inputs[0];
|
|
15
|
+
const chunkSize = params.chunkSize ?? defaultChunkSize;
|
|
16
|
+
const overlap = params.overlap ?? Math.floor(chunkSize / 8);
|
|
17
|
+
const count = Math.floor(source.length / (chunkSize - overlap)) + 1;
|
|
18
|
+
const contents = new Array(count).fill(undefined).map((_, i) => {
|
|
19
|
+
const startIndex = i * (chunkSize - overlap);
|
|
20
|
+
return source.substring(startIndex, startIndex + chunkSize);
|
|
21
|
+
});
|
|
22
|
+
return { contents, count, chunkSize, overlap };
|
|
23
|
+
};
|
|
24
|
+
exports.stringSplitterAgent = stringSplitterAgent;
|
|
@@ -3,12 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.stringTemplateAgent = void 0;
|
|
4
4
|
// see example
|
|
5
5
|
// tests/agents/test_string_agent.ts
|
|
6
|
-
const stringTemplateAgent = async ({
|
|
7
|
-
if (verbose) {
|
|
8
|
-
console.log("executing", nodeId, params);
|
|
9
|
-
}
|
|
6
|
+
const stringTemplateAgent = async ({ params, inputs }) => {
|
|
10
7
|
const content = inputs.reduce((template, input, index) => {
|
|
11
|
-
return template.replace("${" + index + "}", input
|
|
8
|
+
return template.replace("${" + index + "}", input);
|
|
12
9
|
}, params.template);
|
|
13
10
|
return { content };
|
|
14
11
|
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.bypassAgent = void 0;
|
|
4
|
+
const bypassAgent = async (context) => {
|
|
5
|
+
if (context.inputs.length === 1) {
|
|
6
|
+
return context.inputs[0];
|
|
7
|
+
}
|
|
8
|
+
return context.inputs;
|
|
9
|
+
};
|
|
10
|
+
exports.bypassAgent = bypassAgent;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.copyMessageAgent = void 0;
|
|
4
|
+
const copyMessageAgent = async ({ params }) => {
|
|
5
|
+
return {
|
|
6
|
+
messages: new Array(params.count).fill(undefined).map(() => {
|
|
7
|
+
return params.message;
|
|
8
|
+
}),
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
exports.copyMessageAgent = copyMessageAgent;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.countingAgent = void 0;
|
|
4
|
+
const countingAgent = async ({ params }) => {
|
|
5
|
+
return {
|
|
6
|
+
list: new Array(params.count).fill(undefined).map((_, i) => {
|
|
7
|
+
return i;
|
|
8
|
+
}),
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
exports.countingAgent = countingAgent;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.echoForkIndexAgent = void 0;
|
|
4
|
+
const echoForkIndexAgent = async ({ debugInfo: { forkIndex } }) => {
|
|
5
|
+
return { forkIndex };
|
|
6
|
+
};
|
|
7
|
+
exports.echoForkIndexAgent = echoForkIndexAgent;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { bypassAgent } from "../../experimental_agents/test_agents/bypass_agent";
|
|
2
|
+
export { echoAgent } from "../../experimental_agents/test_agents/echo_agent";
|
|
3
|
+
export { copyMessageAgent } from "../../experimental_agents/test_agents/copy_message_agent";
|
|
4
|
+
export { mergeNodeIdAgent } from "../../experimental_agents/test_agents/merge_node_id_agent";
|
|
5
|
+
export { countingAgent } from "../../experimental_agents/test_agents/counting_agent";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.countingAgent = exports.mergeNodeIdAgent = exports.copyMessageAgent = exports.echoAgent = exports.bypassAgent = void 0;
|
|
4
|
+
var bypass_agent_1 = require("../../experimental_agents/test_agents/bypass_agent");
|
|
5
|
+
Object.defineProperty(exports, "bypassAgent", { enumerable: true, get: function () { return bypass_agent_1.bypassAgent; } });
|
|
6
|
+
var echo_agent_1 = require("../../experimental_agents/test_agents/echo_agent");
|
|
7
|
+
Object.defineProperty(exports, "echoAgent", { enumerable: true, get: function () { return echo_agent_1.echoAgent; } });
|
|
8
|
+
var copy_message_agent_1 = require("../../experimental_agents/test_agents/copy_message_agent");
|
|
9
|
+
Object.defineProperty(exports, "copyMessageAgent", { enumerable: true, get: function () { return copy_message_agent_1.copyMessageAgent; } });
|
|
10
|
+
var merge_node_id_agent_1 = require("../../experimental_agents/test_agents/merge_node_id_agent");
|
|
11
|
+
Object.defineProperty(exports, "mergeNodeIdAgent", { enumerable: true, get: function () { return merge_node_id_agent_1.mergeNodeIdAgent; } });
|
|
12
|
+
var counting_agent_1 = require("../../experimental_agents/test_agents/counting_agent");
|
|
13
|
+
Object.defineProperty(exports, "countingAgent", { enumerable: true, get: function () { return counting_agent_1.countingAgent; } });
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mergeNodeIdAgent = void 0;
|
|
4
|
+
const mergeNodeIdAgent = async ({ debugInfo: { nodeId }, inputs }) => {
|
|
5
|
+
// console.log("executing", nodeId);
|
|
6
|
+
return inputs.reduce((tmp, input) => {
|
|
7
|
+
return { ...tmp, ...input };
|
|
8
|
+
}, { [nodeId]: "hello" });
|
|
9
|
+
};
|
|
10
|
+
exports.mergeNodeIdAgent = mergeNodeIdAgent;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.tokenBoundStringsAgent = void 0;
|
|
4
|
+
const tiktoken_1 = require("tiktoken");
|
|
5
|
+
const defaultMaxToken = 5000;
|
|
6
|
+
const encoder = (0, tiktoken_1.get_encoding)("cl100k_base");
|
|
7
|
+
// This agent generate a reference string from a sorted array of strings,
|
|
8
|
+
// adding one by one until the token count exceeds the specified limit.
|
|
9
|
+
// Parameters:
|
|
10
|
+
// limit?: number; // specifies the maximum token count. The default is 5000.
|
|
11
|
+
// Inputs:
|
|
12
|
+
// inputs[0]: Array<string>; // array of string sorted by relevance.
|
|
13
|
+
// Returns:
|
|
14
|
+
// { content: string } // reference text
|
|
15
|
+
const tokenBoundStringsAgent = async ({ params, inputs }) => {
|
|
16
|
+
const contents = inputs[0];
|
|
17
|
+
const limit = params?.limit ?? defaultMaxToken;
|
|
18
|
+
const addNext = (total, index) => {
|
|
19
|
+
const length = encoder.encode(contents[index] + "\n").length;
|
|
20
|
+
if (total + length < limit && index + 1 < contents.length) {
|
|
21
|
+
return addNext(total + length, index + 1);
|
|
22
|
+
}
|
|
23
|
+
return { endIndex: index + 1, tokenCount: total };
|
|
24
|
+
};
|
|
25
|
+
const { endIndex, tokenCount } = addNext(0, 0);
|
|
26
|
+
const content = contents
|
|
27
|
+
.filter((value, index) => {
|
|
28
|
+
return index < endIndex;
|
|
29
|
+
})
|
|
30
|
+
.join("\n");
|
|
31
|
+
return { content, tokenCount, endIndex };
|
|
32
|
+
};
|
|
33
|
+
exports.tokenBoundStringsAgent = tokenBoundStringsAgent;
|
package/lib/graphai.d.ts
CHANGED
|
@@ -1,124 +1,41 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Injected = "injected",
|
|
8
|
-
Dispatched = "dispatched"
|
|
9
|
-
}
|
|
10
|
-
type ResultData<ResultType = Record<string, any>> = ResultType | undefined;
|
|
11
|
-
type ResultDataDictonary<ResultType = Record<string, any>> = Record<string, ResultData<ResultType>>;
|
|
12
|
-
export type NodeDataParams<ParamsType = Record<string, any>> = ParamsType;
|
|
13
|
-
type NodeData = {
|
|
14
|
-
inputs?: Array<string>;
|
|
15
|
-
params?: NodeDataParams;
|
|
16
|
-
retry?: number;
|
|
17
|
-
timeout?: number;
|
|
18
|
-
agentId?: string;
|
|
19
|
-
fork?: number;
|
|
20
|
-
source?: boolean;
|
|
21
|
-
value?: ResultData;
|
|
22
|
-
next?: string;
|
|
23
|
-
outputs?: Record<string, string>;
|
|
24
|
-
};
|
|
25
|
-
type LoopData = {
|
|
26
|
-
count?: number;
|
|
27
|
-
while?: string;
|
|
28
|
-
};
|
|
29
|
-
export type GraphData = {
|
|
30
|
-
agentId?: string;
|
|
31
|
-
nodes: Record<string, NodeData>;
|
|
32
|
-
concurrency?: number;
|
|
33
|
-
loop?: LoopData;
|
|
34
|
-
verbose?: boolean;
|
|
35
|
-
};
|
|
36
|
-
export type TransactionLog = {
|
|
37
|
-
nodeId: string;
|
|
38
|
-
state: NodeState;
|
|
39
|
-
startTime: number;
|
|
40
|
-
endTime?: number;
|
|
41
|
-
retryCount?: number;
|
|
42
|
-
agentId?: string;
|
|
43
|
-
params?: NodeDataParams;
|
|
44
|
-
inputs?: Array<ResultData>;
|
|
45
|
-
errorMessage?: string;
|
|
46
|
-
result?: ResultData;
|
|
47
|
-
log?: TransactionLog[];
|
|
48
|
-
};
|
|
49
|
-
export type AgentFunctionContext<ParamsType, PreviousResultType> = {
|
|
50
|
-
nodeId: string;
|
|
51
|
-
forkIndex?: number;
|
|
52
|
-
retry: number;
|
|
53
|
-
params: NodeDataParams<ParamsType>;
|
|
54
|
-
inputs: Array<PreviousResultType>;
|
|
55
|
-
verbose: boolean;
|
|
56
|
-
agents: CallbackDictonaryArgs;
|
|
57
|
-
log: TransactionLog[];
|
|
58
|
-
};
|
|
59
|
-
export type AgentFunction<ParamsType = Record<string, any>, ResultType = Record<string, any>, PreviousResultType = Record<string, any>> = (context: AgentFunctionContext<ParamsType, PreviousResultType>) => Promise<ResultData<ResultType>>;
|
|
60
|
-
export type AgentFunctionDictonary = Record<string, AgentFunction<any, any, any>>;
|
|
61
|
-
declare class Node {
|
|
62
|
-
nodeId: string;
|
|
63
|
-
params: NodeDataParams;
|
|
64
|
-
inputs: Array<string>;
|
|
65
|
-
inputProps: Record<string, string>;
|
|
66
|
-
pendings: Set<string>;
|
|
67
|
-
waitlist: Set<string>;
|
|
68
|
-
state: NodeState;
|
|
69
|
-
agentId?: string;
|
|
70
|
-
fork?: number;
|
|
71
|
-
forkIndex?: number;
|
|
72
|
-
result: ResultData;
|
|
73
|
-
retryLimit: number;
|
|
74
|
-
retryCount: number;
|
|
75
|
-
transactionId: undefined | number;
|
|
76
|
-
timeout?: number;
|
|
77
|
-
error?: Error;
|
|
78
|
-
source: boolean;
|
|
79
|
-
outputs?: Record<string, string>;
|
|
80
|
-
private graph;
|
|
81
|
-
constructor(nodeId: string, forkIndex: number | undefined, data: NodeData, graph: GraphAI);
|
|
82
|
-
asString(): string;
|
|
83
|
-
private retry;
|
|
84
|
-
removePending(nodeId: string): void;
|
|
85
|
-
pushQueueIfReady(): void;
|
|
86
|
-
injectValue(value: ResultData): void;
|
|
87
|
-
private setResult;
|
|
88
|
-
execute(): Promise<void>;
|
|
89
|
-
}
|
|
90
|
-
type GraphNodes = Record<string, Node>;
|
|
91
|
-
export type CallbackDictonaryArgs = AgentFunctionDictonary;
|
|
1
|
+
export { AgentFunction, AgentFunctionDictonary, GraphData } from "./type";
|
|
2
|
+
import { AgentFunctionDictonary, GraphData, DataSource, ResultDataDictonary, ResultData, DefaultResultData } from "./type";
|
|
3
|
+
import { TransactionLog } from "./transaction_log";
|
|
4
|
+
import { ComputedNode, StaticNode } from "./node";
|
|
5
|
+
import { TaskManager } from "./task_manager";
|
|
6
|
+
type GraphNodes = Record<string, ComputedNode | StaticNode>;
|
|
92
7
|
export declare class GraphAI {
|
|
93
|
-
private
|
|
8
|
+
private readonly graphId;
|
|
9
|
+
private readonly data;
|
|
10
|
+
private readonly loop?;
|
|
11
|
+
private readonly logs;
|
|
12
|
+
readonly callbackDictonary: AgentFunctionDictonary;
|
|
13
|
+
readonly taskManager: TaskManager;
|
|
94
14
|
nodes: GraphNodes;
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
isRunning: boolean;
|
|
98
|
-
private runningNodes;
|
|
99
|
-
private nodeQueue;
|
|
15
|
+
onLogCallback: (__log: TransactionLog, __isUpdate: boolean) => void;
|
|
16
|
+
verbose: boolean;
|
|
100
17
|
private onComplete;
|
|
101
|
-
private concurrency;
|
|
102
|
-
private loop?;
|
|
103
18
|
private repeatCount;
|
|
104
|
-
verbose: boolean;
|
|
105
|
-
private logs;
|
|
106
19
|
private createNodes;
|
|
107
20
|
private getValueFromResults;
|
|
108
21
|
private initializeNodes;
|
|
109
|
-
constructor(data: GraphData, callbackDictonary:
|
|
110
|
-
getCallback(agentId?: string): AgentFunction<any, any, any>;
|
|
22
|
+
constructor(data: GraphData, callbackDictonary: AgentFunctionDictonary, taskManager?: TaskManager | undefined);
|
|
23
|
+
getCallback(agentId?: string): import("./type").AgentFunction<any, any, any>;
|
|
111
24
|
asString(): string;
|
|
112
|
-
results(): ResultDataDictonary<
|
|
25
|
+
results<T = DefaultResultData>(all: boolean): ResultDataDictonary<T>;
|
|
113
26
|
errors(): Record<string, Error>;
|
|
114
27
|
private pushReadyNodesIntoQueue;
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
pushQueue(node:
|
|
118
|
-
|
|
28
|
+
private pushQueueIfReady;
|
|
29
|
+
pushQueueIfReadyAndRunning(node: ComputedNode): void;
|
|
30
|
+
pushQueue(node: ComputedNode): void;
|
|
31
|
+
run<T = DefaultResultData>(all?: boolean): Promise<ResultDataDictonary<T>>;
|
|
32
|
+
isRunning(): boolean;
|
|
33
|
+
onExecutionComplete(node: ComputedNode): void;
|
|
34
|
+
private processLoopIfNecessary;
|
|
35
|
+
setLoopLog(log: TransactionLog): void;
|
|
119
36
|
appendLog(log: TransactionLog): void;
|
|
37
|
+
updateLog(log: TransactionLog): void;
|
|
120
38
|
transactionLogs(): TransactionLog[];
|
|
121
|
-
injectValue(nodeId: string, value: ResultData): void;
|
|
122
|
-
resultsOf(
|
|
39
|
+
injectValue(nodeId: string, value: ResultData, injectFrom?: string): void;
|
|
40
|
+
resultsOf(sources: Array<DataSource>, anyInput?: boolean): any[];
|
|
123
41
|
}
|
|
124
|
-
export {};
|