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
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ GraphAI is an asynchronous data flow execution engine, which allows developers t
|
|
|
6
6
|
|
|
7
7
|
As Andrew Ng has described in his article, "[The batch: Issue 242](https://www.deeplearning.ai/the-batch/issue-242/)", better results can often be achieved by making multiple calls to a Large Language Model (LLM) and allowing it to incrementally build towards a higher-quality output. Dr. Ng refers to this approach as 'agentic workflows.'
|
|
8
8
|
|
|
9
|
-
Such *agentic applications*
|
|
9
|
+
Such *agentic applications* require making multiple asynchronous API calls (e.g., OpenAI's chat-completion API, database queries, web searches) and managing data dependencies among them. As the complexity of the application increases, managing these dependencies in a traditional programming style becomes challenging due to the asynchronous nature of the APIs.
|
|
10
10
|
|
|
11
11
|
GraphAI allows developers to describe dependencies among those agents (asynchronous API calls) in a data flow graph in YAML or JSON, which is called *declarative data flow programming* . The GraphAI engine will take care of all the complexity of concurrent asynchronous calls, data dependency management, task priority management, map-reduce processing, error handling, retries and logging.
|
|
12
12
|
|
|
@@ -68,9 +68,9 @@ flowchart TD
|
|
|
68
68
|
chunkEmbeddings --> similarities(similarities)
|
|
69
69
|
topicEmbedding --> similarities
|
|
70
70
|
similarities --> sortedChunks(sortedChunks)
|
|
71
|
-
sortedChunks -->
|
|
71
|
+
sortedChunks --> referenceText(resourceText)
|
|
72
72
|
source -- query --> prompt(prompt)
|
|
73
|
-
|
|
73
|
+
referenceText --> prompt
|
|
74
74
|
prompt --> query(query)
|
|
75
75
|
```
|
|
76
76
|
|
|
@@ -120,7 +120,7 @@ An *agent function* is a TypeScript function, which implements a particular *age
|
|
|
120
120
|
There are additional optional parameters for developers of nested agents and agent filters.
|
|
121
121
|
|
|
122
122
|
- *graphData*: an optional GraphData (for nested agents)
|
|
123
|
-
- *agents*:
|
|
123
|
+
- *agents*: AgentFunctionInfoDictionary (for nested agents)
|
|
124
124
|
- *taskManager*: TaskManager (for nested agents)
|
|
125
125
|
- *log*: TransactionLog[] (for nested agents)
|
|
126
126
|
- *filterParams*: agent filter parameters (for agent filters)
|
|
@@ -377,77 +377,7 @@ By default, tasks are executed in a first-in, first-out (FIFO) order with a neut
|
|
|
377
377
|
|
|
378
378
|
Negative priority values are allowed, enabling you to fine-tune the execution order based on your application's requirements.
|
|
379
379
|
|
|
380
|
-
##
|
|
380
|
+
## References
|
|
381
381
|
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
- ```data: GraphData```: The graph data including nodes and optional concurrency limit.
|
|
386
|
-
- ```callbackDictonary: AgentFunctionInfoDictonary```: A dictionary mapping agent IDs to their respective callback functions info to be used for all nodes.
|
|
387
|
-
|
|
388
|
-
### ```async run(): Promise<ResultDataDictonary<ResultData>>```
|
|
389
|
-
Executes the graph asynchronously, starting with nodes that have no dependencies or whose dependencies have been met. The method continues to execute nodes as their dependencies are satisfied until all nodes have been executed or an error occurs.
|
|
390
|
-
|
|
391
|
-
Returns: A promise that resolves with the results of all executed nodes or rejects with the first encountered error.
|
|
392
|
-
|
|
393
|
-
### ```results(): ResultDataDictonary<ResultData>```
|
|
394
|
-
Compiles and returns the results of all executed nodes in the graph.
|
|
395
|
-
|
|
396
|
-
Returns: A dictionary mapping node IDs to their results. Only includes nodes that have completed execution and produced a result.
|
|
397
|
-
|
|
398
|
-
### ```errors(): Record<string, Error>```
|
|
399
|
-
Compiles and returns the errors from all nodes that encountered an error during execution.
|
|
400
|
-
|
|
401
|
-
Returns: A dictionary mapping node IDs to the errors they encountered. Only includes nodes that have executed and encountered an error. It does not include any errors which have been retried.
|
|
402
|
-
|
|
403
|
-
### ```transactionLogs(): Array<TransactionLog>```
|
|
404
|
-
Retrieves all transaction logs recorded during the execution of the graph.
|
|
405
|
-
|
|
406
|
-
Returns: An array of transaction logs detailing the execution states and outcomes of the nodes within the graph.
|
|
407
|
-
|
|
408
|
-
### ```injectValue(nodeId: string, result: ResultData): void```
|
|
409
|
-
Injects a result into a specified node. This is used to manually set the result of a static node, allowing dependent nodes to proceed with execution.
|
|
410
|
-
|
|
411
|
-
- ```nodeId: string```: The ID of the static node into which the result is to be injected.
|
|
412
|
-
- ```result: ResultData```: The result to be injected into the specified node.
|
|
413
|
-
|
|
414
|
-
## Collaboration
|
|
415
|
-
|
|
416
|
-
Step 1. Install git, node and yarn
|
|
417
|
-
|
|
418
|
-
Step 2. Clone the project and install necessary node modules
|
|
419
|
-
|
|
420
|
-
```
|
|
421
|
-
git clone git@github.com:snakajima/graphai.git
|
|
422
|
-
cd graphai
|
|
423
|
-
yarn install
|
|
424
|
-
```
|
|
425
|
-
|
|
426
|
-
Step 3. Set the environment variable OPENAI_API_KEY to your own key (=sk-...)
|
|
427
|
-
|
|
428
|
-
You need to set ANTHROPIC_API_KEY as well, if you want to use Claude.
|
|
429
|
-
|
|
430
|
-
Step 4. Run the test script
|
|
431
|
-
|
|
432
|
-
Run the test
|
|
433
|
-
|
|
434
|
-
```
|
|
435
|
-
npm run test
|
|
436
|
-
```
|
|
437
|
-
|
|
438
|
-
Step 5. Run one of sample scripts
|
|
439
|
-
|
|
440
|
-
```
|
|
441
|
-
npm run sample ./samples/home.ts
|
|
442
|
-
```
|
|
443
|
-
|
|
444
|
-
Step 6. Write some code and send pull requests
|
|
445
|
-
|
|
446
|
-
- Please run "yarn run format" before sending your pull request.
|
|
447
|
-
- Please do not include any build files (files under /lib) to your pull reuquest.
|
|
448
|
-
|
|
449
|
-
Key principles:
|
|
450
|
-
|
|
451
|
-
1. Keep the core (Node and GraphAI classes) small and simple.
|
|
452
|
-
2. Enhance the platform by adding 'agents' (plug ins).
|
|
453
|
-
3. Simple but effective test scripts make it easy to maintain.
|
|
382
|
+
- [Collaboration](./Collaboration.md)
|
|
383
|
+
- [API Document](./APIDocument.md)
|
|
@@ -1,16 +1,30 @@
|
|
|
1
|
-
import { AgentFunction } from "../../
|
|
1
|
+
import { AgentFunction } from "../../index";
|
|
2
2
|
export declare const pushAgent: AgentFunction<Record<string, any>, Record<string, any>, Array<any>>;
|
|
3
3
|
declare const pushAgentInfo: {
|
|
4
4
|
name: string;
|
|
5
5
|
agent: AgentFunction<Record<string, any>, Record<string, any>, any[]>;
|
|
6
6
|
mock: AgentFunction<Record<string, any>, Record<string, any>, any[]>;
|
|
7
|
-
samples: {
|
|
7
|
+
samples: ({
|
|
8
8
|
inputs: (number | number[])[];
|
|
9
9
|
params: {};
|
|
10
10
|
result: number[];
|
|
11
|
-
}
|
|
11
|
+
} | {
|
|
12
|
+
inputs: ({
|
|
13
|
+
apple: number;
|
|
14
|
+
}[] | {
|
|
15
|
+
lemon: number;
|
|
16
|
+
})[];
|
|
17
|
+
params: {};
|
|
18
|
+
result: ({
|
|
19
|
+
apple: number;
|
|
20
|
+
lemon?: undefined;
|
|
21
|
+
} | {
|
|
22
|
+
lemon: number;
|
|
23
|
+
apple?: undefined;
|
|
24
|
+
})[];
|
|
25
|
+
})[];
|
|
12
26
|
description: string;
|
|
13
|
-
category:
|
|
27
|
+
category: string[];
|
|
14
28
|
author: string;
|
|
15
29
|
repository: string;
|
|
16
30
|
license: string;
|
|
@@ -3,7 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.pushAgent = void 0;
|
|
4
4
|
const pushAgent = async ({ inputs }) => {
|
|
5
5
|
const array = inputs[0].map((item) => item); // shallow copy
|
|
6
|
-
|
|
6
|
+
inputs.forEach((input, index) => {
|
|
7
|
+
if (index > 0) {
|
|
8
|
+
array.push(input);
|
|
9
|
+
}
|
|
10
|
+
});
|
|
7
11
|
return array;
|
|
8
12
|
};
|
|
9
13
|
exports.pushAgent = pushAgent;
|
|
@@ -17,9 +21,19 @@ const pushAgentInfo = {
|
|
|
17
21
|
params: {},
|
|
18
22
|
result: [1, 2, 3],
|
|
19
23
|
},
|
|
24
|
+
{
|
|
25
|
+
inputs: [[1, 2], 3, 4, 5],
|
|
26
|
+
params: {},
|
|
27
|
+
result: [1, 2, 3, 4, 5],
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
inputs: [[{ apple: 1 }], { lemon: 2 }],
|
|
31
|
+
params: {},
|
|
32
|
+
result: [{ apple: 1 }, { lemon: 2 }],
|
|
33
|
+
},
|
|
20
34
|
],
|
|
21
35
|
description: "push Agent",
|
|
22
|
-
category: [],
|
|
36
|
+
category: ["array"],
|
|
23
37
|
author: "Receptron team",
|
|
24
38
|
repository: "https://github.com/receptron/graphai",
|
|
25
39
|
license: "MIT",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AgentFunction } from "../../
|
|
1
|
+
import { AgentFunction } from "../../index";
|
|
2
2
|
export declare const shiftAgent: AgentFunction<Record<string, any>, Record<string, any>, Array<any>>;
|
|
3
3
|
declare const shiftAgentInfo: {
|
|
4
4
|
name: string;
|
|
@@ -20,7 +20,7 @@ declare const shiftAgentInfo: {
|
|
|
20
20
|
};
|
|
21
21
|
})[];
|
|
22
22
|
description: string;
|
|
23
|
-
category:
|
|
23
|
+
category: string[];
|
|
24
24
|
author: string;
|
|
25
25
|
repository: string;
|
|
26
26
|
license: string;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { AgentFunction } from "../../
|
|
1
|
+
import { AgentFunction } from "../../index";
|
|
2
2
|
export declare const propertyFilterAgent: AgentFunction<{
|
|
3
3
|
include?: Array<string>;
|
|
4
4
|
exclude?: Array<string>;
|
|
5
5
|
alter?: Record<string, Record<string, string>>;
|
|
6
6
|
inject?: Array<Record<string, any>>;
|
|
7
|
+
inspect?: Array<Record<string, any>>;
|
|
7
8
|
swap?: Record<string, string>;
|
|
8
9
|
}>;
|
|
9
10
|
declare const propertyFilterAgentInfo: {
|
|
@@ -13,6 +14,7 @@ declare const propertyFilterAgentInfo: {
|
|
|
13
14
|
exclude?: string[] | undefined;
|
|
14
15
|
alter?: Record<string, Record<string, string>> | undefined;
|
|
15
16
|
inject?: Record<string, any>[] | undefined;
|
|
17
|
+
inspect?: Record<string, any>[] | undefined;
|
|
16
18
|
swap?: Record<string, string> | undefined;
|
|
17
19
|
}>;
|
|
18
20
|
mock: AgentFunction<{
|
|
@@ -20,6 +22,7 @@ declare const propertyFilterAgentInfo: {
|
|
|
20
22
|
exclude?: string[] | undefined;
|
|
21
23
|
alter?: Record<string, Record<string, string>> | undefined;
|
|
22
24
|
inject?: Record<string, any>[] | undefined;
|
|
25
|
+
inspect?: Record<string, any>[] | undefined;
|
|
23
26
|
swap?: Record<string, string> | undefined;
|
|
24
27
|
}>;
|
|
25
28
|
samples: ({
|
|
@@ -36,6 +39,7 @@ declare const propertyFilterAgentInfo: {
|
|
|
36
39
|
alter?: undefined;
|
|
37
40
|
inject?: undefined;
|
|
38
41
|
swap?: undefined;
|
|
42
|
+
inspect?: undefined;
|
|
39
43
|
};
|
|
40
44
|
result: {
|
|
41
45
|
color: string;
|
|
@@ -55,6 +59,7 @@ declare const propertyFilterAgentInfo: {
|
|
|
55
59
|
alter?: undefined;
|
|
56
60
|
inject?: undefined;
|
|
57
61
|
swap?: undefined;
|
|
62
|
+
inspect?: undefined;
|
|
58
63
|
};
|
|
59
64
|
result: {
|
|
60
65
|
color: string;
|
|
@@ -74,6 +79,7 @@ declare const propertyFilterAgentInfo: {
|
|
|
74
79
|
alter?: undefined;
|
|
75
80
|
inject?: undefined;
|
|
76
81
|
swap?: undefined;
|
|
82
|
+
inspect?: undefined;
|
|
77
83
|
};
|
|
78
84
|
result: {
|
|
79
85
|
type: string;
|
|
@@ -99,6 +105,7 @@ declare const propertyFilterAgentInfo: {
|
|
|
99
105
|
exclude?: undefined;
|
|
100
106
|
inject?: undefined;
|
|
101
107
|
swap?: undefined;
|
|
108
|
+
inspect?: undefined;
|
|
102
109
|
};
|
|
103
110
|
result: {
|
|
104
111
|
color: string;
|
|
@@ -124,6 +131,7 @@ declare const propertyFilterAgentInfo: {
|
|
|
124
131
|
exclude?: undefined;
|
|
125
132
|
alter?: undefined;
|
|
126
133
|
swap?: undefined;
|
|
134
|
+
inspect?: undefined;
|
|
127
135
|
};
|
|
128
136
|
result: {
|
|
129
137
|
color: string;
|
|
@@ -150,6 +158,7 @@ declare const propertyFilterAgentInfo: {
|
|
|
150
158
|
exclude?: undefined;
|
|
151
159
|
alter?: undefined;
|
|
152
160
|
swap?: undefined;
|
|
161
|
+
inspect?: undefined;
|
|
153
162
|
};
|
|
154
163
|
result: {
|
|
155
164
|
color: string;
|
|
@@ -174,6 +183,7 @@ declare const propertyFilterAgentInfo: {
|
|
|
174
183
|
exclude?: undefined;
|
|
175
184
|
alter?: undefined;
|
|
176
185
|
inject?: undefined;
|
|
186
|
+
inspect?: undefined;
|
|
177
187
|
};
|
|
178
188
|
result: {
|
|
179
189
|
color: string;
|
|
@@ -182,6 +192,41 @@ declare const propertyFilterAgentInfo: {
|
|
|
182
192
|
maker: string;
|
|
183
193
|
range: number;
|
|
184
194
|
}[];
|
|
195
|
+
} | {
|
|
196
|
+
inputs: (string | {
|
|
197
|
+
color: string;
|
|
198
|
+
model: string;
|
|
199
|
+
type: string;
|
|
200
|
+
maker: string;
|
|
201
|
+
range: number;
|
|
202
|
+
}[])[];
|
|
203
|
+
params: {
|
|
204
|
+
inspect: ({
|
|
205
|
+
propId: string;
|
|
206
|
+
equal: string;
|
|
207
|
+
notEqual?: undefined;
|
|
208
|
+
from?: undefined;
|
|
209
|
+
} | {
|
|
210
|
+
propId: string;
|
|
211
|
+
notEqual: string;
|
|
212
|
+
from: number;
|
|
213
|
+
equal?: undefined;
|
|
214
|
+
})[];
|
|
215
|
+
include?: undefined;
|
|
216
|
+
exclude?: undefined;
|
|
217
|
+
alter?: undefined;
|
|
218
|
+
inject?: undefined;
|
|
219
|
+
swap?: undefined;
|
|
220
|
+
};
|
|
221
|
+
result: {
|
|
222
|
+
color: string;
|
|
223
|
+
model: string;
|
|
224
|
+
type: string;
|
|
225
|
+
maker: string;
|
|
226
|
+
range: number;
|
|
227
|
+
isTesla: boolean;
|
|
228
|
+
isGM: boolean;
|
|
229
|
+
}[];
|
|
185
230
|
})[];
|
|
186
231
|
description: string;
|
|
187
232
|
category: string[];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.propertyFilterAgent = void 0;
|
|
4
|
-
const applyFilter = (input, index, inputs, include, exclude, alter, inject, swap) => {
|
|
4
|
+
const applyFilter = (input, index, inputs, include, exclude, alter, inject, swap, inspect) => {
|
|
5
5
|
const propIds = include ? include : Object.keys(input);
|
|
6
6
|
const excludeSet = new Set(exclude ?? []);
|
|
7
7
|
const result = propIds.reduce((tmp, propId) => {
|
|
@@ -23,6 +23,17 @@ const applyFilter = (input, index, inputs, include, exclude, alter, inject, swap
|
|
|
23
23
|
}
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
|
+
if (inspect) {
|
|
27
|
+
inspect.forEach((item) => {
|
|
28
|
+
const value = inputs[item.from ?? 1]; // default is inputs[1]
|
|
29
|
+
if (item.equal) {
|
|
30
|
+
result[item.propId] = item.equal === value;
|
|
31
|
+
}
|
|
32
|
+
else if (item.notEqual) {
|
|
33
|
+
result[item.propId] = item.notEqual !== value;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
26
37
|
if (swap) {
|
|
27
38
|
Object.keys(swap).forEach((key) => {
|
|
28
39
|
const tmp = result[key];
|
|
@@ -34,11 +45,11 @@ const applyFilter = (input, index, inputs, include, exclude, alter, inject, swap
|
|
|
34
45
|
};
|
|
35
46
|
const propertyFilterAgent = async ({ inputs, params }) => {
|
|
36
47
|
const [input] = inputs;
|
|
37
|
-
const { include, exclude, alter, inject, swap } = params;
|
|
48
|
+
const { include, exclude, alter, inject, swap, inspect } = params;
|
|
38
49
|
if (Array.isArray(input)) {
|
|
39
|
-
return input.map((item, index) => applyFilter(item, index, inputs, include, exclude, alter, inject, swap));
|
|
50
|
+
return input.map((item, index) => applyFilter(item, index, inputs, include, exclude, alter, inject, swap, inspect));
|
|
40
51
|
}
|
|
41
|
-
return applyFilter(input, 0, inputs, include, exclude, alter, inject, swap);
|
|
52
|
+
return applyFilter(input, 0, inputs, include, exclude, alter, inject, swap, inspect);
|
|
42
53
|
};
|
|
43
54
|
exports.propertyFilterAgent = propertyFilterAgent;
|
|
44
55
|
const testInputs = [
|
|
@@ -106,6 +117,19 @@ const propertyFilterAgentInfo = {
|
|
|
106
117
|
{ color: "blue", model: "Tesla", type: "EV", maker: "Model Y", range: 400 },
|
|
107
118
|
],
|
|
108
119
|
},
|
|
120
|
+
{
|
|
121
|
+
inputs: testInputs,
|
|
122
|
+
params: {
|
|
123
|
+
inspect: [
|
|
124
|
+
{ propId: "isTesla", equal: "Tesla Motors" }, // from: 1 is implied
|
|
125
|
+
{ propId: "isGM", notEqual: "Tesla Motors", from: 1 },
|
|
126
|
+
],
|
|
127
|
+
},
|
|
128
|
+
result: [
|
|
129
|
+
{ color: "red", model: "Model 3", type: "EV", maker: "Tesla", range: 300, isTesla: true, isGM: false },
|
|
130
|
+
{ color: "blue", model: "Model Y", type: "EV", maker: "Tesla", range: 400, isTesla: true, isGM: false },
|
|
131
|
+
],
|
|
132
|
+
},
|
|
109
133
|
],
|
|
110
134
|
description: "Filter properties based on property name either with 'include' or 'exclude'",
|
|
111
135
|
category: ["data"],
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AgentFunction } from "../
|
|
1
|
+
import { AgentFunction } from "../index";
|
|
2
2
|
export declare const stringEmbeddingsAgent: AgentFunction<{
|
|
3
3
|
model?: string;
|
|
4
4
|
}, any, Array<string> | string>;
|
|
@@ -12,7 +12,7 @@ declare const stringEmbeddingsAgentInfo: {
|
|
|
12
12
|
}, any, string | string[]>;
|
|
13
13
|
samples: never[];
|
|
14
14
|
description: string;
|
|
15
|
-
category:
|
|
15
|
+
category: string[];
|
|
16
16
|
author: string;
|
|
17
17
|
repository: string;
|
|
18
18
|
license: string;
|
|
@@ -47,7 +47,7 @@ const stringEmbeddingsAgentInfo = {
|
|
|
47
47
|
mock: exports.stringEmbeddingsAgent,
|
|
48
48
|
samples: [],
|
|
49
49
|
description: "Embeddings Agent",
|
|
50
|
-
category: [],
|
|
50
|
+
category: ["embedding"],
|
|
51
51
|
author: "Receptron team",
|
|
52
52
|
repository: "https://github.com/receptron/graphai",
|
|
53
53
|
license: "MIT",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AgentFunction } from "../../
|
|
1
|
+
import { AgentFunction } from "../../index";
|
|
2
2
|
export declare const mapAgent: AgentFunction<{
|
|
3
3
|
namedInputs?: Array<string>;
|
|
4
4
|
limit?: number;
|
|
@@ -15,7 +15,7 @@ declare const mapAgentInfo: {
|
|
|
15
15
|
}, Record<string, any[]>, any>;
|
|
16
16
|
samples: never[];
|
|
17
17
|
description: string;
|
|
18
|
-
category:
|
|
18
|
+
category: string[];
|
|
19
19
|
author: string;
|
|
20
20
|
repository: string;
|
|
21
21
|
license: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.mapAgent = void 0;
|
|
4
|
-
const
|
|
4
|
+
const index_1 = require("../../index");
|
|
5
5
|
const utils_1 = require("../../utils/utils");
|
|
6
6
|
const nested_agent_1 = require("./nested_agent");
|
|
7
7
|
const mapAgent = async ({ params, inputs, agents, log, taskManager, graphData, agentFilters }) => {
|
|
@@ -25,7 +25,7 @@ const mapAgent = async ({ params, inputs, agents, log, taskManager, graphData, a
|
|
|
25
25
|
}
|
|
26
26
|
});
|
|
27
27
|
const graphs = input.map((data) => {
|
|
28
|
-
const graphAI = new
|
|
28
|
+
const graphAI = new index_1.GraphAI(nestedGraphData, agents || {}, { taskManager, agentFilters: agentFilters || [] });
|
|
29
29
|
// Only the first input will be mapped
|
|
30
30
|
namedInputs.forEach((injectToNodeId, index) => {
|
|
31
31
|
graphAI.injectValue(injectToNodeId, index === 0 ? data : inputs[index], "__mapAgent_inputs__");
|
|
@@ -62,7 +62,7 @@ const mapAgentInfo = {
|
|
|
62
62
|
mock: exports.mapAgent,
|
|
63
63
|
samples: [],
|
|
64
64
|
description: "Map Agent",
|
|
65
|
-
category: [],
|
|
65
|
+
category: ["graph"],
|
|
66
66
|
author: "Receptron team",
|
|
67
67
|
repository: "https://github.com/receptron/graphai",
|
|
68
68
|
license: "MIT",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AgentFunction } from "../../
|
|
1
|
+
import { AgentFunction } from "../../index";
|
|
2
2
|
import { GraphData } from "../../type";
|
|
3
3
|
export declare const getNestedGraphData: (graphData: GraphData | string | undefined, inputs: Array<any>) => GraphData;
|
|
4
4
|
export declare const nestedAgent: AgentFunction<{
|
|
@@ -14,7 +14,7 @@ declare const nestedAgentInfo: {
|
|
|
14
14
|
}>;
|
|
15
15
|
samples: never[];
|
|
16
16
|
description: string;
|
|
17
|
-
category:
|
|
17
|
+
category: string[];
|
|
18
18
|
author: string;
|
|
19
19
|
repository: string;
|
|
20
20
|
license: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.nestedAgent = exports.getNestedGraphData = void 0;
|
|
4
|
-
const
|
|
4
|
+
const index_1 = require("../../index");
|
|
5
5
|
const utils_1 = require("../../utils/utils");
|
|
6
6
|
// This function allows us to use one of inputs as the graph data for this nested agent,
|
|
7
7
|
// which is equivalent to "eval" of JavaScript.
|
|
@@ -38,7 +38,7 @@ const nestedAgent = async ({ params, inputs, agents, log, taskManager, graphData
|
|
|
38
38
|
nestedGraphData.nodes[nodeId]["value"] = inputs[index];
|
|
39
39
|
}
|
|
40
40
|
});
|
|
41
|
-
const graphAI = new
|
|
41
|
+
const graphAI = new index_1.GraphAI(nestedGraphData, agents || {}, { taskManager, agentFilters });
|
|
42
42
|
const results = await graphAI.run(false);
|
|
43
43
|
log?.push(...graphAI.transactionLogs());
|
|
44
44
|
return results;
|
|
@@ -50,7 +50,7 @@ const nestedAgentInfo = {
|
|
|
50
50
|
mock: exports.nestedAgent,
|
|
51
51
|
samples: [],
|
|
52
52
|
description: "nested Agent",
|
|
53
|
-
category: [],
|
|
53
|
+
category: ["graph"],
|
|
54
54
|
author: "Receptron team",
|
|
55
55
|
repository: "https://github.com/receptron/graphai",
|
|
56
56
|
license: "MIT",
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import nestedAgent from "../../experimental_agents/graph_agents/nested_agent";
|
|
2
2
|
import mapAgent from "../../experimental_agents/graph_agents/map_agent";
|
|
3
|
-
|
|
3
|
+
import workerAgent from "../../experimental_agents/graph_agents/worker_agent";
|
|
4
|
+
export { nestedAgent, mapAgent, workerAgent };
|
|
@@ -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.mapAgent = exports.nestedAgent = void 0;
|
|
6
|
+
exports.workerAgent = exports.mapAgent = exports.nestedAgent = void 0;
|
|
7
7
|
const nested_agent_1 = __importDefault(require("../../experimental_agents/graph_agents/nested_agent"));
|
|
8
8
|
exports.nestedAgent = nested_agent_1.default;
|
|
9
9
|
const map_agent_1 = __importDefault(require("../../experimental_agents/graph_agents/map_agent"));
|
|
10
10
|
exports.mapAgent = map_agent_1.default;
|
|
11
|
+
const worker_agent_1 = __importDefault(require("../../experimental_agents/graph_agents/worker_agent"));
|
|
12
|
+
exports.workerAgent = worker_agent_1.default;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import nestedAgent from "../../experimental_agents/graph_agents/nested_agent";
|
|
2
2
|
import mapAgent from "../../experimental_agents/graph_agents/map_agent";
|
|
3
|
-
|
|
3
|
+
import workerAgent from "../../experimental_agents/graph_agents/worker_agent";
|
|
4
|
+
export { nestedAgent, mapAgent, workerAgent };
|
|
@@ -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.mapAgent = exports.nestedAgent = void 0;
|
|
6
|
+
exports.workerAgent = exports.mapAgent = exports.nestedAgent = void 0;
|
|
7
7
|
const nested_agent_1 = __importDefault(require("../../experimental_agents/graph_agents/nested_agent"));
|
|
8
8
|
exports.nestedAgent = nested_agent_1.default;
|
|
9
9
|
const map_agent_1 = __importDefault(require("../../experimental_agents/graph_agents/map_agent"));
|
|
10
10
|
exports.mapAgent = map_agent_1.default;
|
|
11
|
+
const worker_agent_1 = __importDefault(require("../../experimental_agents/graph_agents/worker_agent"));
|
|
12
|
+
exports.workerAgent = worker_agent_1.default;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { AgentFunction } from "../../index";
|
|
2
|
+
export declare const workerAgent: AgentFunction<{
|
|
3
|
+
namedInputs?: Array<string>;
|
|
4
|
+
}, any, any>;
|
|
5
|
+
declare const workerAgentInfo: {
|
|
6
|
+
name: string;
|
|
7
|
+
agent: AgentFunction<{
|
|
8
|
+
namedInputs?: string[] | undefined;
|
|
9
|
+
}, any, any>;
|
|
10
|
+
mock: AgentFunction<{
|
|
11
|
+
namedInputs?: string[] | undefined;
|
|
12
|
+
}, any, any>;
|
|
13
|
+
samples: {
|
|
14
|
+
inputs: string[];
|
|
15
|
+
params: {};
|
|
16
|
+
result: {
|
|
17
|
+
message: string;
|
|
18
|
+
};
|
|
19
|
+
graph: {
|
|
20
|
+
version: number;
|
|
21
|
+
nodes: {
|
|
22
|
+
source: {
|
|
23
|
+
value: string;
|
|
24
|
+
};
|
|
25
|
+
message: {
|
|
26
|
+
agent: string;
|
|
27
|
+
inputs: string[];
|
|
28
|
+
isResult: boolean;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
}[];
|
|
33
|
+
description: string;
|
|
34
|
+
category: string[];
|
|
35
|
+
author: string;
|
|
36
|
+
repository: string;
|
|
37
|
+
license: string;
|
|
38
|
+
};
|
|
39
|
+
export default workerAgentInfo;
|