graphai 0.1.2 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +107 -78
- package/lib/experimental_agents/array_agents/packages.d.ts +4 -0
- package/lib/experimental_agents/array_agents/packages.js +12 -0
- package/lib/experimental_agents/array_agents/pop_agent.d.ts +27 -1
- package/lib/experimental_agents/array_agents/pop_agent.js +41 -6
- package/lib/experimental_agents/array_agents/push_agent.d.ts +17 -1
- package/lib/experimental_agents/array_agents/push_agent.js +20 -7
- package/lib/experimental_agents/array_agents/shift_agent.d.ts +27 -1
- package/lib/experimental_agents/array_agents/shift_agent.js +30 -6
- package/lib/experimental_agents/data_agents/data_object_merge_template_agent.d.ts +57 -2
- package/lib/experimental_agents/data_agents/data_object_merge_template_agent.js +13 -1
- package/lib/experimental_agents/data_agents/data_sum_template_agent.d.ts +1 -0
- package/lib/experimental_agents/data_agents/data_sum_template_agent.js +1 -0
- package/lib/experimental_agents/data_agents/index.d.ts +1 -0
- package/lib/experimental_agents/data_agents/index.js +3 -1
- package/lib/experimental_agents/data_agents/packages.d.ts +5 -0
- package/lib/experimental_agents/data_agents/packages.js +14 -0
- package/lib/experimental_agents/data_agents/property_filter_agent.d.ts +61 -0
- package/lib/experimental_agents/data_agents/property_filter_agent.js +40 -0
- package/lib/experimental_agents/data_agents/total_agent.d.ts +1 -0
- package/lib/experimental_agents/data_agents/total_agent.js +1 -0
- package/lib/experimental_agents/embedding_agent.d.ts +17 -3
- package/lib/experimental_agents/embedding_agent.js +13 -1
- package/lib/experimental_agents/function_agent.d.ts +42 -0
- package/lib/experimental_agents/function_agent.js +40 -0
- package/lib/experimental_agents/graph_agents/index.d.ts +2 -0
- package/lib/experimental_agents/graph_agents/index.js +7 -0
- package/lib/experimental_agents/graph_agents/map_agent.d.ts +20 -0
- package/lib/experimental_agents/{map_agent.js → graph_agents/map_agent.js} +31 -10
- package/lib/experimental_agents/graph_agents/nested_agent.d.ts +22 -0
- package/lib/experimental_agents/graph_agents/nested_agent.js +70 -0
- package/lib/experimental_agents/graph_agents/packages.d.ts +3 -0
- package/lib/experimental_agents/graph_agents/packages.js +10 -0
- package/lib/experimental_agents/index.d.ts +5 -5
- package/lib/experimental_agents/index.js +5 -5
- package/lib/experimental_agents/llm_agents/groq_agent.d.ts +26 -0
- package/lib/experimental_agents/llm_agents/groq_agent.js +39 -0
- package/lib/experimental_agents/llm_agents/index.d.ts +2 -0
- package/lib/experimental_agents/llm_agents/index.js +18 -0
- package/lib/experimental_agents/llm_agents/packages.d.ts +3 -0
- package/lib/experimental_agents/llm_agents/packages.js +10 -0
- package/lib/experimental_agents/llm_agents/slashgpt_agent.d.ts +27 -0
- package/lib/experimental_agents/{slashgpt_agent.js → llm_agents/slashgpt_agent.js} +13 -10
- package/lib/experimental_agents/matrix_agents/dot_product_agent.d.ts +17 -3
- package/lib/experimental_agents/matrix_agents/dot_product_agent.js +26 -1
- package/lib/experimental_agents/matrix_agents/packages.d.ts +3 -0
- package/lib/experimental_agents/matrix_agents/packages.js +10 -0
- package/lib/experimental_agents/matrix_agents/sort_by_values_agent.d.ts +17 -3
- package/lib/experimental_agents/matrix_agents/sort_by_values_agent.js +13 -1
- package/lib/experimental_agents/packages.d.ts +12 -0
- package/lib/experimental_agents/packages.js +34 -0
- package/lib/experimental_agents/sleeper_agents/packages.d.ts +3 -0
- package/lib/experimental_agents/sleeper_agents/packages.js +10 -0
- package/lib/experimental_agents/sleeper_agents/sleeper_agent.d.ts +18 -0
- package/lib/experimental_agents/sleeper_agents/sleeper_agent.js +12 -0
- package/lib/experimental_agents/sleeper_agents/sleeper_agent_debug.d.ts +20 -0
- package/lib/experimental_agents/sleeper_agents/sleeper_agent_debug.js +13 -1
- package/lib/experimental_agents/string_agents/packages.d.ts +3 -0
- package/lib/experimental_agents/string_agents/packages.js +10 -0
- package/lib/experimental_agents/string_agents/string_splitter_agent.d.ts +1 -0
- package/lib/experimental_agents/string_agents/string_splitter_agent.js +1 -0
- package/lib/experimental_agents/string_agents/string_template_agent.d.ts +5 -6
- package/lib/experimental_agents/string_agents/string_template_agent.js +3 -2
- package/lib/experimental_agents/test_agents/bypass_agent.d.ts +7 -1
- package/lib/experimental_agents/test_agents/bypass_agent.js +53 -4
- package/lib/experimental_agents/test_agents/copy2array_agent.d.ts +6 -1
- package/lib/experimental_agents/test_agents/copy2array_agent.js +32 -2
- package/lib/experimental_agents/test_agents/copy_message_agent.d.ts +9 -1
- package/lib/experimental_agents/test_agents/copy_message_agent.js +19 -0
- package/lib/experimental_agents/test_agents/counting_agent.d.ts +8 -1
- package/lib/experimental_agents/test_agents/counting_agent.js +19 -0
- package/lib/experimental_agents/test_agents/echo_agent.d.ts +3 -0
- package/lib/experimental_agents/test_agents/echo_agent.js +13 -0
- package/lib/experimental_agents/test_agents/merge_node_id_agent.d.ts +3 -0
- package/lib/experimental_agents/test_agents/merge_node_id_agent.js +22 -0
- package/lib/experimental_agents/test_agents/packages.d.ts +7 -0
- package/lib/experimental_agents/test_agents/packages.js +18 -0
- package/lib/experimental_agents/token_agent.d.ts +20 -0
- package/lib/experimental_agents/token_agent.js +12 -0
- package/lib/graphai.d.ts +2 -1
- package/lib/graphai.js +13 -12
- package/lib/node.d.ts +1 -0
- package/lib/node.js +18 -11
- package/lib/transaction_log.js +1 -1
- package/lib/type.d.ts +8 -5
- package/lib/utils/test_agents.js +1 -0
- package/lib/utils/test_utils.js +15 -10
- package/lib/utils/utils.d.ts +4 -2
- package/lib/utils/utils.js +47 -5
- package/lib/validators/relation_validator.js +11 -6
- package/package.json +4 -2
- package/lib/experimental_agents/map_agent.d.ts +0 -4
- package/lib/experimental_agents/nested_agent.d.ts +0 -5
- package/lib/experimental_agents/nested_agent.js +0 -40
- package/lib/experimental_agents/slashgpt_agent.d.ts +0 -9
package/README.md
CHANGED
|
@@ -2,13 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
## Overview
|
|
4
4
|
|
|
5
|
-
GraphAI is an asynchronous data flow execution engine, which
|
|
5
|
+
GraphAI is an asynchronous data flow execution engine, which allows developers to build *agentic applications* by describing *agent workflows* as declarative data flow graphs in YAML or JSON.
|
|
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
|
+
|
|
9
|
+
Such *agentic applications* need to make multiple asynchronous API calls (such as OpenAI's chat-completion API, database query, web search, and etc.) and manage data dependencies among them, such as giving the answer from one LLM call to another -- which will become quite difficult to manage in a traditional programing style as the complexity of the application increases, because of the asynchronous nature of those APIs.
|
|
8
10
|
|
|
9
|
-
GraphAI allows developers to describe dependencies among those API calls in a
|
|
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, error handling, retries and logging.
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
## Declarative Data Flow Programming
|
|
14
|
+
|
|
15
|
+
Here is a simple example, which uses the Wikipedia as the data source and perform an in-memory RAG (Retrieval-Augmented Generation).
|
|
12
16
|
|
|
13
17
|
```YAML
|
|
14
18
|
nodes:
|
|
@@ -55,15 +59,22 @@ nodes:
|
|
|
55
59
|
inputs: [prompt]
|
|
56
60
|
```
|
|
57
61
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
```mermaid
|
|
63
|
+
flowchart TD
|
|
64
|
+
source(source) -- name --> wikipedia
|
|
65
|
+
source -- query --> topicEmbedding
|
|
66
|
+
wikipedia --> chunks
|
|
67
|
+
chunks --> chunksEmbeddings
|
|
68
|
+
chunksEmbeddings --> similarities
|
|
69
|
+
topicEmbedding --> similarities
|
|
70
|
+
similarities --> sortedChunks
|
|
71
|
+
sortedChunks --> resourceText
|
|
72
|
+
source -- query --> prompt
|
|
73
|
+
resourceText --> prompt
|
|
74
|
+
prompt --> query
|
|
75
|
+
```
|
|
65
76
|
|
|
66
|
-
|
|
77
|
+
Notice that the conversion of the querty text into an embedding vector and text chunks into an array of embedding vectors can be done concurrently because there is no dependency between them. GraphAI will automatically recognize it and execute them concurrently. This kind of *concurrent programing* is very difficult in traditional programming style, and GraphAI's *data flow programming* style is much better alternative.
|
|
67
78
|
|
|
68
79
|
## Quick Install
|
|
69
80
|
|
|
@@ -77,75 +88,71 @@ or
|
|
|
77
88
|
yarn add graphai
|
|
78
89
|
```
|
|
79
90
|
|
|
80
|
-
##
|
|
91
|
+
## Data Flow Graph
|
|
81
92
|
|
|
82
|
-
|
|
93
|
+
A Data Flow Graph (DFG) is a JavaScript object, which defines the flow of data. It is typically described in YAML file and loaded at runtime.
|
|
83
94
|
|
|
84
|
-
|
|
95
|
+
A DFG consists of a collection of [nodes](#node), which contains a series of nested properties representing individual nodes in the data flow. Each node is identified by a unique key, *nodeId* (e.g., node1, node2) and can contain several predefined properties (such as params, inputs, and value) that dictate the node's behavior and its relationship with other nodes. There are two types of nodes, [computed nodes](#computed-node) and [static nodes](#static-node), which are described below.
|
|
85
96
|
|
|
86
|
-
|
|
87
|
-
git clone git@github.com:snakajima/graphai.git
|
|
88
|
-
cd graphai
|
|
89
|
-
yarn install
|
|
90
|
-
```
|
|
97
|
+
Connections between nodes will be established by references from one not to another, using either its "inputs" or "update" property. The values of those properties are *data sources*. A *data souce* is specified by either the nodeId (e.g., "node1"), or nodeId + propertyId ("node1.item").
|
|
91
98
|
|
|
92
|
-
|
|
99
|
+
### DFG Structure
|
|
93
100
|
|
|
94
|
-
|
|
101
|
+
- 'nodes': A list of node. Required.
|
|
102
|
+
- 'concurrency': An optional property, which specifies the maximum number of concurrent operations (agent functions to be executed at the same time). The default is 8.
|
|
103
|
+
- 'loop': An optional property, which specifies if the graph needs to be executed multiple times. See the [Loop section below](#loop) for details.
|
|
95
104
|
|
|
96
|
-
|
|
105
|
+
## Agent
|
|
97
106
|
|
|
98
|
-
|
|
107
|
+
An *agent* is an abstract object which takes some inputs and generates an output asynchronously. It could be an LLM (such as GPT-4), a media generator, a database, or a REST API over HTTP. A node associated with an agent (specified by 'agentId' property) is called [computed node](#computed-node), which takes a set of inputs from other nodes, lets the agent to process it, and pushes the returned value to other nodes.
|
|
99
108
|
|
|
100
|
-
|
|
101
|
-
cd tests/http-server/docs/
|
|
102
|
-
npx http-server
|
|
103
|
-
```
|
|
109
|
+
### Agent function
|
|
104
110
|
|
|
105
|
-
|
|
111
|
+
An agent function is a TypeScript function, which implements a particular *agent*. An *agent function* receives two set of parameters via AgentFunctionContext:
|
|
106
112
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
```
|
|
113
|
+
- params: agent specific parameters specified in the DFG (specified by the "params" property of the node)
|
|
114
|
+
- inputs: a set of inputs came from other nodes (specified by "inputs" property of the node).
|
|
110
115
|
|
|
111
|
-
|
|
116
|
+
## Node
|
|
112
117
|
|
|
113
|
-
|
|
114
|
-
npm run sample ./samples/home.ts
|
|
115
|
-
```
|
|
118
|
+
There are two types of Node, *computed nodes* and *static nodes*. A *computed node* is associated with an *agent function*, which receives some inputs, performs some computations asynchronously then returns the result (output). A *static node* is a placeholder of a value (just like a variable in programming language), which is specified by the *value* property, injected by an external program, or is updated at the end of iteration (see the [loop](#loop)).
|
|
116
119
|
|
|
117
|
-
|
|
120
|
+
### Computed Node
|
|
118
121
|
|
|
119
|
-
|
|
122
|
+
A *computed node* have following properties.
|
|
120
123
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
124
|
+
- 'agentId': An **required** property, which specifies the id of the *agent function*.
|
|
125
|
+
- 'params': An optional agent-specific property to control the behavior of the associated agent function.
|
|
126
|
+
- 'inputs': An optional list of *data sources* that the current node receives the data from. This establishes a data flow where the current node can only be executed after the completion of the nodes listed under 'inputs'. If this list is empty, the associated *agent function* will be immediatley executed.
|
|
127
|
+
- 'anyInput': An optiona boolean flag, which indicates that the associated *agent function* will be called when at least one of input data became available. Otherwise, it will wait until all the data became available.
|
|
128
|
+
- 'retry': An optional number, which specifies the maximum number of retries to be made. If the last attempt fails, the error will be recorded.
|
|
129
|
+
- 'timeout': An optional number, which specifies the maximum waittime in msec. If the associated agent function does not return the value in time, the "Timeout" error will be recorded. The returned value received after the time out will be discarded.
|
|
125
130
|
|
|
126
|
-
|
|
131
|
+
### Static Node
|
|
127
132
|
|
|
128
|
-
A
|
|
133
|
+
A *static* node have following properties.
|
|
129
134
|
|
|
130
|
-
|
|
135
|
+
- 'value': An **required** property, which specifies the initial value of this static node (equivalent to calling the injectValue method from outside).
|
|
136
|
+
- 'update': An optional property, which specifies the *data source* after each iteration. See the [loop](#loop) for details.
|
|
131
137
|
|
|
132
|
-
|
|
138
|
+
## Flow Control
|
|
133
139
|
|
|
134
|
-
|
|
140
|
+
Since the data-flow graph must be asyclic by design, we added a few mechanism to control data flows, [loop](#loop), [nesting](#nesting), [mapping](#mapping) and [condtional flow](#conditional-flow).
|
|
135
141
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
142
|
+
### Loop
|
|
143
|
+
|
|
144
|
+
The loop is an optioal property of a graph, which has two optional properties. The *count* property specifies the number of times the graph needs to be executed and the *while* property specifies the condition required to contineu the loop in the form of node name (nodeId) or its property (nodeId.propId). Unlike JavaScript, an empty array will be treated as false.
|
|
145
|
+
|
|
146
|
+
Here is an example, which performs an LLM query for each person in the list and create the list of answers. The "people" node (static), is initialized with an array of names, and the "retriever" node (computed) retrieves one name at a time, and send it to the "query" node (computed) to perform an LLM query. The "reducer" append it the array retrieved form the "result" node (static node, which is initialized as an empty array).
|
|
147
|
+
|
|
148
|
+
The "update" property of two static nodes ("people" and "result"), updates those properties based on the results from the previous itelation. This loop continues until the value of "people" node become an empty array.
|
|
139
149
|
|
|
140
150
|
```
|
|
141
151
|
loop:
|
|
142
152
|
while: people
|
|
143
153
|
nodes:
|
|
144
154
|
people:
|
|
145
|
-
value:
|
|
146
|
-
- Steve Jobs
|
|
147
|
-
- Elon Musk
|
|
148
|
-
- Nikola Tesla
|
|
155
|
+
value: [Steve Jobs, Elon Musk, Nikola Tesla]
|
|
149
156
|
update: retriever.array
|
|
150
157
|
result:
|
|
151
158
|
value: []
|
|
@@ -157,41 +164,24 @@ nodes:
|
|
|
157
164
|
agentId: slashgpt
|
|
158
165
|
params:
|
|
159
166
|
manifest:
|
|
160
|
-
prompt:
|
|
167
|
+
prompt: Describe about the person in less than 100 words
|
|
161
168
|
inputs: [retriever.item]
|
|
162
169
|
reducer:
|
|
163
170
|
agentId: push
|
|
164
171
|
inputs: [result, query.content]
|
|
165
172
|
```
|
|
166
173
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
An agent is an abstract object, which takes some inputs and generates an output asynchronously. It could be an LLM (such as GPT-4), an image/video/music generator, a database, or a REST API over HTTP. Each node (except 'source node') is associated with an agent function, which takes data flow into the node as inputs, and generates an output.
|
|
170
|
-
|
|
171
|
-
## Agent function
|
|
172
|
-
|
|
173
|
-
An agent function is a TypeScript function, which implements an agent. A DFG is associated one or more agent functions. If the DFG is associated with multiple agent functions, each node needs to be associated only one of them (either explicitly with 'agentId' or implicitly to the default Agent function).
|
|
174
|
+
### Nesting
|
|
174
175
|
|
|
175
|
-
|
|
176
|
+
To be filled.
|
|
176
177
|
|
|
177
|
-
|
|
178
|
+
### Mapping
|
|
178
179
|
|
|
179
|
-
|
|
180
|
+
To be filled.
|
|
180
181
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
- 'agentId': An **required** property, which specifies the id of the *agent function*.
|
|
184
|
-
- 'inputs': An optional list of *data sources* that the current node depends on. This establishes a flow where the current node can only be executed after the completion of the nodes listed under 'inputs'. If this list is empty, the associated *agent function* will be immediatley executed.
|
|
185
|
-
- 'anyInput': An optiona boolean flag, which indicates that the associated *agent function* will be called when at least one of input data became available. Otherwise, it will wait until all the data became available.
|
|
186
|
-
- 'retry': An optional number, which specifies the maximum number of retries to be made. If the last attempt fails, that return value will be recorded.
|
|
187
|
-
- 'timeout': An optional number, which specifies the maximum waittime in msec. If the associated agent function does not return the value in time, the "Timeout" error will be recorded and the returned value will be discarded.
|
|
188
|
-
- 'params': An optional property to the associated agent function, which are agent specific.
|
|
189
|
-
- 'fork': An optional paramter, which specifies the number of concurrent transactions to be created for the current node.
|
|
190
|
-
|
|
191
|
-
A *static* node have following properties.
|
|
182
|
+
### Conditional Flow
|
|
192
183
|
|
|
193
|
-
|
|
194
|
-
- 'update': An optional property, which specifies the *data source* after each iteration.
|
|
184
|
+
To be filled.
|
|
195
185
|
|
|
196
186
|
## GraphAI class
|
|
197
187
|
|
|
@@ -226,3 +216,42 @@ Injects a result into a specified node. This is used to manually set the result
|
|
|
226
216
|
|
|
227
217
|
- ```nodeId: string```: The ID of the static node into which the result is to be injected.
|
|
228
218
|
- ```result: ResultData```: The result to be injected into the specified node.
|
|
219
|
+
|
|
220
|
+
## Collaboration
|
|
221
|
+
|
|
222
|
+
Step 1. Install git, node and yarn
|
|
223
|
+
|
|
224
|
+
Step 2. Clone the project and install necessary node modules
|
|
225
|
+
|
|
226
|
+
```
|
|
227
|
+
git clone git@github.com:snakajima/graphai.git
|
|
228
|
+
cd graphai
|
|
229
|
+
yarn install
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
Step 3. Set the environment variable OPENAI_API_KEY to your own key (=sk-...)
|
|
233
|
+
|
|
234
|
+
You need to set ANTHROPIC_API_KEY as well, if you want to use Claude.
|
|
235
|
+
|
|
236
|
+
Step 4. Run the test script
|
|
237
|
+
|
|
238
|
+
Run the test
|
|
239
|
+
|
|
240
|
+
```
|
|
241
|
+
npm run test
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
Step 5. Run one of sample scripts
|
|
245
|
+
|
|
246
|
+
```
|
|
247
|
+
npm run sample ./samples/home.ts
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
Step 6. Write some code and send pull requests
|
|
251
|
+
|
|
252
|
+
Key principles:
|
|
253
|
+
|
|
254
|
+
1. Keep the core (Node and GraphAI classes) small and simple.
|
|
255
|
+
2. Enhance the platform by adding 'agents' (plug ins).
|
|
256
|
+
3. Simple but effective test scripts make it easy to maintain.
|
|
257
|
+
4. Run "npm run format" before submitting pull requests.
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import pushAgent from "../../experimental_agents/array_agents/push_agent";
|
|
2
|
+
import popAgent from "../../experimental_agents/array_agents/pop_agent";
|
|
3
|
+
import shiftAgent from "../../experimental_agents/array_agents/shift_agent";
|
|
4
|
+
export { pushAgent, popAgent, shiftAgent };
|
|
@@ -0,0 +1,12 @@
|
|
|
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.shiftAgent = exports.popAgent = exports.pushAgent = void 0;
|
|
7
|
+
const push_agent_1 = __importDefault(require("../../experimental_agents/array_agents/push_agent"));
|
|
8
|
+
exports.pushAgent = push_agent_1.default;
|
|
9
|
+
const pop_agent_1 = __importDefault(require("../../experimental_agents/array_agents/pop_agent"));
|
|
10
|
+
exports.popAgent = pop_agent_1.default;
|
|
11
|
+
const shift_agent_1 = __importDefault(require("../../experimental_agents/array_agents/shift_agent"));
|
|
12
|
+
exports.shiftAgent = shift_agent_1.default;
|
|
@@ -1,2 +1,28 @@
|
|
|
1
1
|
import { AgentFunction } from "../../graphai";
|
|
2
|
-
export declare const popAgent: AgentFunction<Record<string, any>, Record<string, any>,
|
|
2
|
+
export declare const popAgent: AgentFunction<Record<string, any>, Record<string, any>, Array<any>>;
|
|
3
|
+
declare const popAgentInfo: {
|
|
4
|
+
name: string;
|
|
5
|
+
agent: AgentFunction<Record<string, any>, Record<string, any>, any[]>;
|
|
6
|
+
mock: AgentFunction<Record<string, any>, Record<string, any>, any[]>;
|
|
7
|
+
samples: ({
|
|
8
|
+
inputs: string[][];
|
|
9
|
+
params: {};
|
|
10
|
+
result: {
|
|
11
|
+
array: string[];
|
|
12
|
+
item: string;
|
|
13
|
+
};
|
|
14
|
+
} | {
|
|
15
|
+
inputs: (string[] | number[])[];
|
|
16
|
+
params: {};
|
|
17
|
+
result: {
|
|
18
|
+
array: number[];
|
|
19
|
+
item: number;
|
|
20
|
+
};
|
|
21
|
+
})[];
|
|
22
|
+
description: string;
|
|
23
|
+
category: string[];
|
|
24
|
+
author: string;
|
|
25
|
+
repository: string;
|
|
26
|
+
license: string;
|
|
27
|
+
};
|
|
28
|
+
export default popAgentInfo;
|
|
@@ -1,15 +1,50 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.popAgent = void 0;
|
|
7
|
-
const deepmerge_1 = __importDefault(require("deepmerge"));
|
|
8
4
|
const popAgent = async (context) => {
|
|
9
5
|
const { inputs } = context;
|
|
10
|
-
const
|
|
11
|
-
// TODO: Validation
|
|
6
|
+
const array = inputs[0].map((item) => item); // shallow copy
|
|
12
7
|
const item = array.pop();
|
|
13
8
|
return { array, item };
|
|
14
9
|
};
|
|
15
10
|
exports.popAgent = popAgent;
|
|
11
|
+
const popAgentInfo = {
|
|
12
|
+
name: "popAgent",
|
|
13
|
+
agent: exports.popAgent,
|
|
14
|
+
mock: exports.popAgent,
|
|
15
|
+
samples: [
|
|
16
|
+
{
|
|
17
|
+
inputs: [[1, 2, 3]],
|
|
18
|
+
params: {},
|
|
19
|
+
result: {
|
|
20
|
+
array: [1, 2],
|
|
21
|
+
item: 3,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
inputs: [["a", "b", "c"]],
|
|
26
|
+
params: {},
|
|
27
|
+
result: {
|
|
28
|
+
array: ["a", "b"],
|
|
29
|
+
item: "c",
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
inputs: [
|
|
34
|
+
[1, 2, 3],
|
|
35
|
+
["a", "b", "c"],
|
|
36
|
+
],
|
|
37
|
+
params: {},
|
|
38
|
+
result: {
|
|
39
|
+
array: [1, 2],
|
|
40
|
+
item: 3,
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
description: "Pop Agent",
|
|
45
|
+
category: ["array"],
|
|
46
|
+
author: "Receptron team",
|
|
47
|
+
repository: "https://github.com/receptron/graphai",
|
|
48
|
+
license: "MIT",
|
|
49
|
+
};
|
|
50
|
+
exports.default = popAgentInfo;
|
|
@@ -1,2 +1,18 @@
|
|
|
1
1
|
import { AgentFunction } from "../../graphai";
|
|
2
|
-
export declare const pushAgent: AgentFunction<Record<string, any>, Record<string, any>,
|
|
2
|
+
export declare const pushAgent: AgentFunction<Record<string, any>, Record<string, any>, Array<any>>;
|
|
3
|
+
declare const pushAgentInfo: {
|
|
4
|
+
name: string;
|
|
5
|
+
agent: AgentFunction<Record<string, any>, Record<string, any>, any[]>;
|
|
6
|
+
mock: AgentFunction<Record<string, any>, Record<string, any>, any[]>;
|
|
7
|
+
samples: {
|
|
8
|
+
inputs: (number | number[])[];
|
|
9
|
+
params: {};
|
|
10
|
+
result: number[];
|
|
11
|
+
}[];
|
|
12
|
+
description: string;
|
|
13
|
+
category: never[];
|
|
14
|
+
author: string;
|
|
15
|
+
repository: string;
|
|
16
|
+
license: string;
|
|
17
|
+
};
|
|
18
|
+
export default pushAgentInfo;
|
|
@@ -1,14 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.pushAgent = void 0;
|
|
7
|
-
const deepmerge_1 = __importDefault(require("deepmerge"));
|
|
8
4
|
const pushAgent = async ({ inputs }) => {
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
array.push(item);
|
|
5
|
+
const array = inputs[0].map((item) => item); // shallow copy
|
|
6
|
+
array.push(inputs[1]);
|
|
12
7
|
return array;
|
|
13
8
|
};
|
|
14
9
|
exports.pushAgent = pushAgent;
|
|
10
|
+
const pushAgentInfo = {
|
|
11
|
+
name: "pushAgent",
|
|
12
|
+
agent: exports.pushAgent,
|
|
13
|
+
mock: exports.pushAgent,
|
|
14
|
+
samples: [
|
|
15
|
+
{
|
|
16
|
+
inputs: [[1, 2], 3],
|
|
17
|
+
params: {},
|
|
18
|
+
result: [1, 2, 3],
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
description: "push Agent",
|
|
22
|
+
category: [],
|
|
23
|
+
author: "Receptron team",
|
|
24
|
+
repository: "https://github.com/receptron/graphai",
|
|
25
|
+
license: "MIT",
|
|
26
|
+
};
|
|
27
|
+
exports.default = pushAgentInfo;
|
|
@@ -1,2 +1,28 @@
|
|
|
1
1
|
import { AgentFunction } from "../../graphai";
|
|
2
|
-
export declare const shiftAgent: AgentFunction<Record<string, any>, Record<string, any>,
|
|
2
|
+
export declare const shiftAgent: AgentFunction<Record<string, any>, Record<string, any>, Array<any>>;
|
|
3
|
+
declare const shiftAgentInfo: {
|
|
4
|
+
name: string;
|
|
5
|
+
agent: AgentFunction<Record<string, any>, Record<string, any>, any[]>;
|
|
6
|
+
mock: AgentFunction<Record<string, any>, Record<string, any>, any[]>;
|
|
7
|
+
samples: ({
|
|
8
|
+
inputs: number[][];
|
|
9
|
+
params: {};
|
|
10
|
+
result: {
|
|
11
|
+
array: number[];
|
|
12
|
+
item: number;
|
|
13
|
+
};
|
|
14
|
+
} | {
|
|
15
|
+
inputs: string[][];
|
|
16
|
+
params: {};
|
|
17
|
+
result: {
|
|
18
|
+
array: string[];
|
|
19
|
+
item: string;
|
|
20
|
+
};
|
|
21
|
+
})[];
|
|
22
|
+
description: string;
|
|
23
|
+
category: never[];
|
|
24
|
+
author: string;
|
|
25
|
+
repository: string;
|
|
26
|
+
license: string;
|
|
27
|
+
};
|
|
28
|
+
export default shiftAgentInfo;
|
|
@@ -1,15 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.shiftAgent = void 0;
|
|
7
|
-
const deepmerge_1 = __importDefault(require("deepmerge"));
|
|
8
4
|
const shiftAgent = async (context) => {
|
|
9
5
|
const { inputs } = context;
|
|
10
|
-
const
|
|
11
|
-
// TODO: Validation
|
|
6
|
+
const array = inputs[0].map((item) => item); // shallow copy
|
|
12
7
|
const item = array.shift();
|
|
13
8
|
return { array, item };
|
|
14
9
|
};
|
|
15
10
|
exports.shiftAgent = shiftAgent;
|
|
11
|
+
const shiftAgentInfo = {
|
|
12
|
+
name: "shiftAgent",
|
|
13
|
+
agent: exports.shiftAgent,
|
|
14
|
+
mock: exports.shiftAgent,
|
|
15
|
+
samples: [
|
|
16
|
+
{
|
|
17
|
+
inputs: [[1, 2, 3]],
|
|
18
|
+
params: {},
|
|
19
|
+
result: {
|
|
20
|
+
array: [2, 3],
|
|
21
|
+
item: 1,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
inputs: [["a", "b", "c"]],
|
|
26
|
+
params: {},
|
|
27
|
+
result: {
|
|
28
|
+
array: ["b", "c"],
|
|
29
|
+
item: "a",
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
description: "shift Agent",
|
|
34
|
+
category: [],
|
|
35
|
+
author: "Receptron team",
|
|
36
|
+
repository: "https://github.com/receptron/graphai",
|
|
37
|
+
license: "MIT",
|
|
38
|
+
};
|
|
39
|
+
exports.default = shiftAgentInfo;
|
|
@@ -4,7 +4,7 @@ declare const dataObjectMergeTemplateAgentInfo: {
|
|
|
4
4
|
name: string;
|
|
5
5
|
agent: AgentFunction;
|
|
6
6
|
mock: AgentFunction;
|
|
7
|
-
samples: {
|
|
7
|
+
samples: ({
|
|
8
8
|
inputs: ({
|
|
9
9
|
a: number;
|
|
10
10
|
b: number;
|
|
@@ -18,9 +18,64 @@ declare const dataObjectMergeTemplateAgentInfo: {
|
|
|
18
18
|
result: {
|
|
19
19
|
a: number;
|
|
20
20
|
b: number;
|
|
21
|
+
c: number;
|
|
22
|
+
};
|
|
23
|
+
} | {
|
|
24
|
+
inputs: ({
|
|
25
|
+
a: {
|
|
26
|
+
b: {
|
|
27
|
+
c: {
|
|
28
|
+
d: string;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
b?: undefined;
|
|
33
|
+
} | {
|
|
34
|
+
b: {
|
|
35
|
+
c: {
|
|
36
|
+
d: {
|
|
37
|
+
e: string;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
d?: undefined;
|
|
41
|
+
};
|
|
42
|
+
a?: undefined;
|
|
43
|
+
} | {
|
|
44
|
+
b: {
|
|
45
|
+
d: {
|
|
46
|
+
e: {
|
|
47
|
+
f: string;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
c?: undefined;
|
|
51
|
+
};
|
|
52
|
+
a?: undefined;
|
|
53
|
+
})[];
|
|
54
|
+
params: {};
|
|
55
|
+
result: {
|
|
56
|
+
a: {
|
|
57
|
+
b: {
|
|
58
|
+
c: {
|
|
59
|
+
d: string;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
b: {
|
|
64
|
+
c: {
|
|
65
|
+
d: {
|
|
66
|
+
e: string;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
d: {
|
|
70
|
+
e: {
|
|
71
|
+
f: string;
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
};
|
|
21
75
|
};
|
|
22
|
-
}[];
|
|
76
|
+
})[];
|
|
23
77
|
description: string;
|
|
78
|
+
category: string[];
|
|
24
79
|
author: string;
|
|
25
80
|
repository: string;
|
|
26
81
|
license: string;
|
|
@@ -18,7 +18,7 @@ const sampleInputs = [
|
|
|
18
18
|
{ a: 3, b: 0, c: 5 },
|
|
19
19
|
];
|
|
20
20
|
const sampleParams = {};
|
|
21
|
-
const sampleResult = { a:
|
|
21
|
+
const sampleResult = { a: 3, b: 0, c: 5 };
|
|
22
22
|
const dataObjectMergeTemplateAgentInfo = {
|
|
23
23
|
name: "dataObjectMergeTemplateAgent",
|
|
24
24
|
agent: exports.dataObjectMergeTemplateAgent,
|
|
@@ -29,8 +29,20 @@ const dataObjectMergeTemplateAgentInfo = {
|
|
|
29
29
|
params: sampleParams,
|
|
30
30
|
result: sampleResult,
|
|
31
31
|
},
|
|
32
|
+
{
|
|
33
|
+
inputs: [{ a: { b: { c: { d: "e" } } } }, { b: { c: { d: { e: "f" } } } }, { b: { d: { e: { f: "g" } } } }],
|
|
34
|
+
params: {},
|
|
35
|
+
result: {
|
|
36
|
+
a: { b: { c: { d: "e" } } },
|
|
37
|
+
b: {
|
|
38
|
+
c: { d: { e: "f" } },
|
|
39
|
+
d: { e: { f: "g" } },
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
},
|
|
32
43
|
],
|
|
33
44
|
description: "Merge object",
|
|
45
|
+
category: ["data"],
|
|
34
46
|
author: "Satoshi Nakajima",
|
|
35
47
|
repository: "https://github.com/receptron/graphai",
|
|
36
48
|
license: "MIT",
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { totalAgent } from "../../experimental_agents/data_agents/total_agent";
|
|
2
2
|
export { dataObjectMergeTemplateAgent } from "../../experimental_agents/data_agents/data_object_merge_template_agent";
|
|
3
3
|
export { dataSumTemplateAgent } from "../../experimental_agents/data_agents/data_sum_template_agent";
|
|
4
|
+
export { propertyFilterAgent } from "../../experimental_agents/data_agents/property_filter_agent";
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.dataSumTemplateAgent = exports.dataObjectMergeTemplateAgent = exports.totalAgent = void 0;
|
|
3
|
+
exports.propertyFilterAgent = exports.dataSumTemplateAgent = exports.dataObjectMergeTemplateAgent = exports.totalAgent = void 0;
|
|
4
4
|
var total_agent_1 = require("../../experimental_agents/data_agents/total_agent");
|
|
5
5
|
Object.defineProperty(exports, "totalAgent", { enumerable: true, get: function () { return total_agent_1.totalAgent; } });
|
|
6
6
|
var data_object_merge_template_agent_1 = require("../../experimental_agents/data_agents/data_object_merge_template_agent");
|
|
7
7
|
Object.defineProperty(exports, "dataObjectMergeTemplateAgent", { enumerable: true, get: function () { return data_object_merge_template_agent_1.dataObjectMergeTemplateAgent; } });
|
|
8
8
|
var data_sum_template_agent_1 = require("../../experimental_agents/data_agents/data_sum_template_agent");
|
|
9
9
|
Object.defineProperty(exports, "dataSumTemplateAgent", { enumerable: true, get: function () { return data_sum_template_agent_1.dataSumTemplateAgent; } });
|
|
10
|
+
var property_filter_agent_1 = require("../../experimental_agents/data_agents/property_filter_agent");
|
|
11
|
+
Object.defineProperty(exports, "propertyFilterAgent", { enumerable: true, get: function () { return property_filter_agent_1.propertyFilterAgent; } });
|