graphai 0.4.5 → 0.4.7

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 ADDED
@@ -0,0 +1,388 @@
1
+ # GraphAI
2
+
3
+ ## Overview
4
+
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
+
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* 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
+
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
+
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).
16
+
17
+ ```YAML
18
+ nodes:
19
+ source: // Input data to this RAG application
20
+ value:
21
+ name: Sam Bankman-Fried
22
+ query: describe the final sentence by the court for Sam Bank-Fried
23
+ wikipedia: // Retrieve data from Wikipedia
24
+ agent: wikipediaAgent
25
+ inputs: [:source.name]
26
+ chunks: // Break the text from Wikipedia into chunks (2048 character each with 512 overlap)
27
+ agent: stringSplitterAgent
28
+ inputs: [:wikipedia]
29
+ chunkEmbeddings: // Get embedding vector of each chunk
30
+ agent: stringEmbeddingsAgent
31
+ inputs: [:chunks]
32
+ topicEmbedding: // Get embedding vector of the question
33
+ agent: stringEmbeddingsAgent
34
+ inputs: [:source.query]
35
+ similarities: // Calculate the cosine similarity of each chunk
36
+ agent: dotProductAgent
37
+ inputs: [:chunkEmbeddings, :topicEmbedding]
38
+ sortedChunks: // Sort chunks based on their similarities
39
+ agent: sortByValuesAgent
40
+ inputs: [:chunks, :similarities]
41
+ referenceText: // Concatenate chunks up to the token limit (5000)
42
+ agent: tokenBoundStringsAgent
43
+ inputs: [:sortedChunks]
44
+ params:
45
+ limit: 5000
46
+ prompt: // Generate a prompt with that reference text
47
+ agent: stringTemplateAgent
48
+ inputs: [:source, :referenceText]
49
+ params:
50
+ template: |-
51
+ Using the following document, ${0}
52
+ ${1}
53
+ query: // retrieves the answer from GPT3.5
54
+ agent: slashGPTAgent
55
+ params:
56
+ manifest:
57
+ model: gpt-3.5-turbo
58
+ isResult: true // indicating this is the final result
59
+ inputs: [:prompt]
60
+ ```
61
+
62
+ ```mermaid
63
+ flowchart TD
64
+ source -- name --> wikipedia(wikipedia)
65
+ source -- query --> topicEmbedding(topicEmbedding)
66
+ wikipedia --> chunks(chunks)
67
+ chunks --> chunkEmbeddings(chunkEmbeddings)
68
+ chunkEmbeddings --> similarities(similarities)
69
+ topicEmbedding --> similarities
70
+ similarities --> sortedChunks(sortedChunks)
71
+ sortedChunks --> referenceText(resourceText)
72
+ source -- query --> prompt(prompt)
73
+ referenceText --> prompt
74
+ prompt --> query(query)
75
+ ```
76
+
77
+ Notice that the conversion of the query 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.
78
+
79
+ ## Quick Install
80
+
81
+ ```
82
+ npm install graphai
83
+ ```
84
+
85
+ or
86
+
87
+ ```
88
+ yarn add graphai
89
+ ```
90
+
91
+ ## Data Flow Graph
92
+
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.
94
+
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.
96
+
97
+ ### Data Source
98
+
99
+ Connections between nodes will be established by references from one node to another, using either its "inputs", "update", "if" or "while" property. The values of those properties are *data sources*. A *data souce* is specified by either the ":" + nodeId (e.g., ":node1"), or ":" + nodeId + propertyId (e.g., ":node1.item"), index (e.g., ":node1.$0", ":node2.$last") or combinations (e.g., ":node1.messages.$0.content").
100
+
101
+ ### DFG Structure
102
+
103
+ - *version*: GraphAI version, *required*. The latest version is 0.3.
104
+ - *nodes*: A list of node. Required.
105
+ - *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.
106
+ - *loop*: An optional property, which specifies if the graph needs to be executed multiple times (iterations). See the [Loop section below](#loop) for details.
107
+
108
+ ## Agent
109
+
110
+ An *agent* is an abstract object which takes some inputs and generates an output asynchronously. It could be an LLM call (such as GPT-4), a media generator, a database access, or a REST API over HTTP. A node associated with an agent (specified by the *agent*'* property) is called [computed node](#computed-node), which takes a set of *inputs* from *data sources*, asks the *agent function* to process it, and makes the returned value available to other nodes.
111
+
112
+ ### Agent function
113
+
114
+ An *agent function* is a TypeScript function, which implements a particular *agent*, performing some computations for the associated *computed node*. An *agent function* receives a *context* (type AgentFunctionContext), which has following properties:
115
+
116
+ - *params*: agent specific parameters specified in the DFG (specified by the "params" property of the node)
117
+ - *inputs*: a set of inputs came from other nodes (specified by "inputs" property of the node).
118
+ - *debugInfo*: a set of information for debugging purposes.
119
+
120
+ There are additional optional parameters for developers of nested agents and agent filters.
121
+
122
+ - *graphData*: an optional GraphData (for nested agents)
123
+ - *agents*: AgentFunctionInfoDictionary (for nested agents)
124
+ - *taskManager*: TaskManager (for nested agents)
125
+ - *log*: TransactionLog[] (for nested agents)
126
+ - *filterParams*: agent filter parameters (for agent filters)
127
+
128
+ ### Inline Agent Function
129
+
130
+ An *inline agent function* is a simplified version of *agent function*, which is embedded in the graph (available only when the graph was described in TypeScript). An *inline agent function* receives only the *inputs* paramter as a variable length arguments.
131
+
132
+ Here is an examnple (from [weather chat](https://github.com/receptron/graphai/blob/main/samples/sample_weather.ts)):
133
+
134
+ ```typescript
135
+ messagesWithUserInput: {
136
+ // Appends the user's input to the messages.
137
+ agent: (messages: Array<any>, content: string) => [...messages, { role: "user", content }],
138
+ inputs: [":messages", ":userInput"],
139
+ if: "checkInput",
140
+ },
141
+ ```
142
+
143
+ ## Node
144
+
145
+ There are two types of Node, *computed nodes* and *static nodes*.
146
+
147
+ A *computed node* is associated with an *agent function*, which receives some inputs, performs some computations asynchronously, and returns the result (output).
148
+
149
+ A *static node* is a placeholder of a value (just like a variable in programming languages), which is initially specified by its *value* property, and can be updated by an external program (before the execution of the graph), or updated using the *update* property at the end of each iteration of a [loop](#loop) operation.
150
+
151
+ ### Computed Node
152
+
153
+ A *computed node* has following properties.
154
+
155
+ - *agent*: An **required** property, which specifies the id of the *agent function*, or an *inline agent function* (NOTE: this is not possible in JSON or YAML).
156
+ - *params*: An optional agent-specific property to control the behavior of the associated agent function. The top level property may reference a *data source*.
157
+ - *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.
158
+ - *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.
159
+ - *retry*: An optional number, which specifies the maximum number of retries to be made. If the last attempt fails, the error will be recorded.
160
+ - *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.
161
+ - *isResult*: An optional boolean value, which indicates that the return value of this node, should be included as a property of the return value from the run() method of the GraphUI instance.
162
+ - *priority*: An optional number, which specifies the priority of the execution of the associated agent (the task). Default is 0, which means "neutral". Negative numbers are allowed as well.
163
+ - *if*: An optional data source property. The node will be activated only if the value from the data source is truthy.
164
+ - *unless*: An optional data source property. The node will be activated only if the value from the data source is falty (including empty array).
165
+ - *graph*: An optional property for nested agents, which specifies the inner graph. This value can be a graph itself or the data souce, whose value is a graph.
166
+
167
+ ### Static Node
168
+
169
+ A *static* node has following properties.
170
+
171
+ - *value*: An **required** property, which specifies the initial value of this static node (equivalent to calling the injectValue method from outside).
172
+ - *update*: An optional property, which specifies the *data source* for a [loop](#loop) operation. After each iteration, the value of this node will be updated with the data from the specified *data source*.
173
+
174
+ ## Flow Control
175
+
176
+ Since the data-flow graph must be asyclic by design, we added a few mechanisms to control data flows, [nesting](#nesting), [loop](#loop), [mapping](#mapping) and [conditional flow](#conditional-flow).
177
+
178
+ ### Nested Graph
179
+
180
+ In order to make it easy to reuse some code, GraphAI supports nesting. It requires a special agent function, which creates an instance (or instances) of GraphAI object within the agent function and execute it. The system supports two types of nesting agent functions (nestAgent and mapAgent), but developers can create their own using the standard agent extension mechanism.
181
+
182
+ A typical nesting graph looks like this:
183
+
184
+ ```YAML
185
+ nodes:
186
+ question:
187
+ value: "Find out which materials we need to purchase this week for Joe Smith's residential house project."
188
+ projectId: // identifies the projectId from the question
189
+ agent: "identifierAgent"
190
+ inputs: [":source"] // == "sourceNode.query"
191
+ database:
192
+ agent: "nestedAgent"
193
+ inputs: [":question", ":projectId"]
194
+ graph:
195
+ nodes:
196
+ schema: // retrieves the database schema for the apecified projectId
197
+ agent: "schemaAgent"
198
+ inputs: [":$1"]
199
+ ... // issue query to the database and build an appropriate prompt with it.
200
+ query: // send the generated prompt to the LLM
201
+ agent: "llama3Agent"
202
+ inputs: [":prompt"]
203
+ isResult: true
204
+ response: // Deliver the answer
205
+ agent: "deliveryAgent"
206
+ inputs: [:database.query.$last.content]
207
+ ```
208
+
209
+ The databaseQuery node (which is associated "nestedAgent") takes the data from "question" node abd "projectId" node, and make them available to inner nodes (nodes of the child graph) via phantom node, "$0" and "$1". After the completion of the child graph, the data from "query" node (which has "isResult" property) becomes available as a property of the output of "database" node.
210
+
211
+ Here is the diagram of the parent graph.
212
+
213
+ ```mermaid
214
+ flowchart LR
215
+ question --> projectId(projectId)
216
+ question --> database
217
+ projectId --> database
218
+ database[[database]] -- query --> response(response)
219
+ ```
220
+
221
+ Here is the diagram of the child graph. Notice that two phantom nodes are automatically created to allow inner nodes to access input data from the parent graph.
222
+
223
+ ```mermaid
224
+ flowchart LR
225
+ $0 --> ...
226
+ $1 --> schema(schema)
227
+ schema --> ...(...)
228
+ ... --> query(query)
229
+ ```
230
+
231
+ This mechanism does not only allows devleoper to reuse code, but also makes it possible to execute the child graph on another machine using a "remote" agent (which will be released later), enabling the *distributed execution* of nested graphs.
232
+
233
+ ### Loop
234
+
235
+ The loop is an optional property of a graph, which has two optional properties.
236
+
237
+ - *count*: Specifies the number of times the graph needs to be executed.
238
+ - *while*: Specifies the *data source* to check after the each iteration. It continues if the data from that *data source* is *true*. Unlike JavaScript, an empty array will be treated as *false*.
239
+
240
+ 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 sends 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).
241
+
242
+ 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.
243
+
244
+ ```
245
+ loop:
246
+ while: :people
247
+ nodes:
248
+ people:
249
+ value: [Steve Jobs, Elon Musk, Nikola Tesla]
250
+ update: :retriever.array
251
+ result:
252
+ value: []
253
+ update: :reducer
254
+ isResult: true
255
+ retriever:
256
+ agent: shift
257
+ inputs: [people]
258
+ query:
259
+ agent: slashgpt
260
+ params:
261
+ manifest:
262
+ prompt: Describe about the person in less than 100 words
263
+ inputs: [:retriever.item]
264
+ reducer:
265
+ agent: push
266
+ inputs: [:result, :query.content]
267
+ ```
268
+
269
+ ```mermaid
270
+ flowchart LR
271
+ result --> reducer(reducer)
272
+ people --> retriever(retriever)
273
+ retriever -- item --> query(query)
274
+ query -- content --> reducer
275
+ retriever -. array .-> people
276
+ reducer -.-> result
277
+ ```
278
+
279
+ The *loop* mechanism is often used with a nested graph, which receives an array of data from a node of the parent graph and performs the "reduction" process of a *map-reduce* operation, just like the *reduce* method of JavaScript.
280
+
281
+ Please notice that each iteration will be done sequencially unlike the *mapping* described below.
282
+
283
+ ### Mapping
284
+
285
+ The mapAgent is one of nested agents, which receives an array of data as an input (inputs[0]) and performs the same operation (specified by its graph property) on each item concurrently.
286
+
287
+ If the size of array is N, the mapAgent creates N instances of GraphAI object, and run them concurrently.
288
+
289
+ After the completion of all of instances, the mapAgent returns an array of results, just like the map function of JavaScript.
290
+
291
+ The following graph will generate the same result (an array of answers) as the sample graph for the *loop*, but three queries will be issued concurretly.
292
+
293
+ ```
294
+ nodes:
295
+ people:
296
+ value: [Steve Jobs, Elon Musk, Nikola Tesla]
297
+ retriever:
298
+ agent: "mapAgent"
299
+ inputs: [":people"]
300
+ graph:
301
+ nodes:
302
+ query:
303
+ agent: slashgpt
304
+ params:
305
+ manifest:
306
+ prompt: Describe about the person in less than 100 words
307
+ inputs: [":$0"]
308
+ ```
309
+
310
+ Here is the conceptual representation of this operation.
311
+
312
+ ```mermaid
313
+ flowchart LR
314
+ people -- "[0]" --> query_0(query_0)
315
+ people -- "[1]" --> query_1(query_1)
316
+ people -- "[2]" --> query_2(query_2)
317
+ query_0 --> retriever[[retriever]]
318
+ query_1 --> retriever
319
+ query_2 --> retriever
320
+ ```
321
+ ### Conditional Flow
322
+
323
+ GraphAI provides mechanisms to control the flow of data based on certain conditions. This is achieved through the *if* and *anyInput* properties.
324
+
325
+ #### If/Unless Property
326
+
327
+ The *if* property allows you to specify a condition that must be met for the data to flow into a particular node. The condition is defined by a data source. If the value obtained from the specified *data source* is truthy (i.e., not null, undefined, 0, false, NaN, or an empty array/string), the node will be executed; otherwise, it will be skipped.The *unless* property is just the opporsite of the *if* property.
328
+
329
+ For example, the following node will be executed only if the *tool_calls* property of the message from the LLM contains a non-zero/non-empty value:
330
+
331
+ ```typescript
332
+ tool_calls: {
333
+ // This node is activated if the LLM requests a tool call.
334
+ agent: "nestedAgent",
335
+ inputs: [":groq.choices.$0.message.tool_calls", ":messagesWithFirstRes"],
336
+ if: ":groq.choices.$0.message.tool_calls",
337
+ graph: {
338
+ // This graph is nested only for the readability.
339
+ ```
340
+
341
+ It is recommended to use the *if* property in conjunction with nested graphs for better code readability and organization.
342
+
343
+ #### AnyInput Property
344
+
345
+ The *anyInput* property (boolean) allows you to merge multiple data flow paths into a single node. When set to *true*, the agent function associated with the node will be executed as soon as data becomes available from any of the specified input data sources.
346
+
347
+ This property is particularly useful when you want to continue the flow regardless of which path the data comes from. In the weather chat sample application, it is used to continue the chat iteration whether a tool was requested by the LLM or not:
348
+
349
+ ```typescript
350
+ reducer: {
351
+ // Receives messages from either case.
352
+ agent: "copyAgent",
353
+ anyInput: true,
354
+ inputs: [":no_tool_calls", ":tool_calls.messagesWithSecondRes"],
355
+ },
356
+ ```
357
+
358
+ In this example, the "reducer" node will execute as soon as data is available from either the "no_tool_calls" or "tool_calls.messagesWithSecondRes" data source.
359
+
360
+ By combining the *if* and *anyInput* properties, you can create complex conditional flows that control the execution of nodes based on the availability and values of data from various sources. This flexibility allows you to build sophisticated data-driven applications with GraphAI.
361
+
362
+ ## Concurrency
363
+
364
+ GraphAI supports concurrent execution of tasks, allowing you to leverage parallelism and improve performance. The level of concurrency can be controlled through the *concurrency* property at the top level of the graph definition.
365
+
366
+ ```typescript
367
+ concurrency: 16 # Maximum number of concurrent tasks
368
+ ```
369
+
370
+ If the *concurrency* property is not specified, the default value of 8 is used.
371
+
372
+ ### Concurrency and Nested Graphs
373
+
374
+ Since the task queue is shared between the parent graph and the children graph (uness the graph is running remotely), tasks created by the child graph will be bound by the same concurrency specified by the parent graph.
375
+
376
+ Since the task executing the nested graph will be in "running" state while tasks within the child graph are runnig, the concurrency limit will be incremented by one when we start running the child graph and restored when it is completed.
377
+
378
+ ### Task Prioritization
379
+
380
+ By default, tasks are executed in a first-in, first-out (FIFO) order with a neutral priority (0). However, you can assign custom priorities to nodes using the *priority* property. Tasks associated with nodes that have a higher priority value will be executed before those with lower priorities.
381
+
382
+ Negative priority values are allowed, enabling you to fine-tune the execution order based on your application's requirements.
383
+
384
+ ## References
385
+
386
+ - [Collaboration](./Collaboration.md)
387
+ - [Sample Graphs](./samples/README.md)
388
+ - [API Document](./APIDocument.md)
package/lib/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  export { GraphAI } from "./graphai";
2
- export { AgentFunction, AgentFunctionInfo, AgentFunctionInfoDictionary, AgentFunctionContext, GraphData, ResultDataDictionary, ResultData, NodeState, AgentFilterFunction, AgentFilterInfo, StaticNodeData, } from "./type";
2
+ export { AgentFunction, AgentFunctionInfo, AgentFunctionInfoDictionary, AgentFunctionContext, GraphData, ResultDataDictionary, ResultData, NodeState, AgentFilterFunction, AgentFilterInfo, NodeData, StaticNodeData, ComputedNodeData, DefaultResultData, DefaultInputData, } from "./type";
3
3
  export type { TransactionLog } from "./transaction_log";
4
4
  export { agentFilterRunnerBuilder } from "./utils/runner";
5
+ export { defaultAgentInfo, agentInfoWrapper, defaultTestContext, strIntentionalError } from "./utils/utils";
6
+ export { ValidationError } from "./validators/common";
package/lib/index.js CHANGED
@@ -1,9 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.agentFilterRunnerBuilder = exports.NodeState = exports.GraphAI = void 0;
3
+ exports.ValidationError = exports.strIntentionalError = exports.defaultTestContext = exports.agentInfoWrapper = exports.defaultAgentInfo = exports.agentFilterRunnerBuilder = exports.NodeState = exports.GraphAI = void 0;
4
4
  var graphai_1 = require("./graphai");
5
5
  Object.defineProperty(exports, "GraphAI", { enumerable: true, get: function () { return graphai_1.GraphAI; } });
6
6
  var type_1 = require("./type");
7
7
  Object.defineProperty(exports, "NodeState", { enumerable: true, get: function () { return type_1.NodeState; } });
8
8
  var runner_1 = require("./utils/runner");
9
9
  Object.defineProperty(exports, "agentFilterRunnerBuilder", { enumerable: true, get: function () { return runner_1.agentFilterRunnerBuilder; } });
10
+ var utils_1 = require("./utils/utils");
11
+ Object.defineProperty(exports, "defaultAgentInfo", { enumerable: true, get: function () { return utils_1.defaultAgentInfo; } });
12
+ Object.defineProperty(exports, "agentInfoWrapper", { enumerable: true, get: function () { return utils_1.agentInfoWrapper; } });
13
+ Object.defineProperty(exports, "defaultTestContext", { enumerable: true, get: function () { return utils_1.defaultTestContext; } });
14
+ Object.defineProperty(exports, "strIntentionalError", { enumerable: true, get: function () { return utils_1.strIntentionalError; } });
15
+ var common_1 = require("./validators/common");
16
+ Object.defineProperty(exports, "ValidationError", { enumerable: true, get: function () { return common_1.ValidationError; } });
@@ -35,3 +35,14 @@ export declare const agentInfoWrapper: (agent: AgentFunction<any, any, any>) =>
35
35
  };
36
36
  export declare const debugResultKey: (agentId: string, result: any) => string[];
37
37
  export declare const isLogicallyTrue: (value: any) => boolean;
38
+ export declare const defaultTestContext: {
39
+ debugInfo: {
40
+ nodeId: string;
41
+ retry: number;
42
+ verbose: boolean;
43
+ };
44
+ params: {};
45
+ filterParams: {};
46
+ agents: {};
47
+ log: never[];
48
+ };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isLogicallyTrue = exports.debugResultKey = exports.agentInfoWrapper = exports.defaultAgentInfo = exports.strIntentionalError = exports.getDataFromSource = exports.isObject = exports.assert = exports.parseNodeName = exports.sleep = void 0;
3
+ exports.defaultTestContext = exports.isLogicallyTrue = exports.debugResultKey = exports.agentInfoWrapper = exports.defaultAgentInfo = exports.strIntentionalError = exports.getDataFromSource = exports.isObject = exports.assert = exports.parseNodeName = exports.sleep = void 0;
4
4
  const sleep = async (milliseconds) => {
5
5
  return await new Promise((resolve) => setTimeout(resolve, milliseconds));
6
6
  };
@@ -155,3 +155,14 @@ const isLogicallyTrue = (value) => {
155
155
  return true;
156
156
  };
157
157
  exports.isLogicallyTrue = isLogicallyTrue;
158
+ exports.defaultTestContext = {
159
+ debugInfo: {
160
+ nodeId: "test",
161
+ retry: 0,
162
+ verbose: true,
163
+ },
164
+ params: {},
165
+ filterParams: {},
166
+ agents: {},
167
+ log: [],
168
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "graphai",
3
- "version": "0.4.5",
3
+ "version": "0.4.7",
4
4
  "description": "Asynchronous data flow execution engine for agentic AI apps.",
5
5
  "main": "lib/index.js",
6
6
  "files": [
@@ -9,7 +9,7 @@
9
9
  "scripts": {
10
10
  "build": "rm -r lib/* && tsc && tsc-alias",
11
11
  "eslint": "eslint",
12
- "apiDoc": " npx typedoc src/index.ts --out apiDoc",
12
+ "doc": " npx typedoc src/index.ts --out ../../docs/apiDoc",
13
13
  "format": "prettier --write '{src,tests,samples}/**/*.ts'",
14
14
  "test": "node --test -r tsconfig-paths/register --require ts-node/register ./tests/**/test_*.ts",
15
15
  "b": "yarn run format && yarn run eslint && yarn run build"
@@ -25,35 +25,7 @@
25
25
  },
26
26
  "homepage": "https://github.com/receptron/graphai#readme",
27
27
  "devDependencies": {
28
- "@anthropic-ai/sdk": "^0.21.0",
29
- "@google/generative-ai": "^0.11.4",
30
- "@graphai/vanilla": "^0.0.1",
31
- "@inquirer/prompts": "^5.0.0",
32
- "@types/cors": "^2.8.17",
33
- "@types/express": "^4.17.21",
34
- "@types/node": "^20.12.11",
35
- "@types/xml2js": "^0.4.14",
36
- "arxiv-api-ts": "^1.0.3",
37
- "cors": "^2.8.5",
38
- "deepmerge": "^4.3.1",
39
- "dotenv": "^16.4.5",
40
- "eslint": "^9.2.0",
41
- "express": "^4.19.2",
42
- "globals": "^15.2.0",
43
- "groq-sdk": "^0.3.3",
44
- "openai": "^4.47.1",
45
- "prettier": "^3.2.5",
46
- "slashgpt": "^0.0.9",
47
- "tiktoken": "^1.0.14",
48
- "ts-node": "^10.9.2",
49
- "tsc-alias": "^1.8.8",
50
- "tsconfig-paths": "^4.2.0",
51
- "typedoc": "^0.25.13",
52
- "typescript": "^5.4.5",
53
- "typescript-eslint": "^7.8.0",
54
- "wikipedia": "^2.1.2",
55
- "xml2js": "^0.6.2",
56
- "yaml": "^2.4.1"
28
+ "typedoc": "^0.25.13"
57
29
  },
58
30
  "types": "./lib/index.d.ts",
59
31
  "directories": {
@@ -1,2 +0,0 @@
1
- import { AgentFilterFunction, AgentFunctionContext } from "../type";
2
- export declare const streamAgentFilterGenerator: <T>(callback: (context: AgentFunctionContext, data: T) => void) => AgentFilterFunction;
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.streamAgentFilterGenerator = void 0;
4
- const streamAgentFilterGenerator = (callback) => {
5
- const streamAgentFilter = async (context, next) => {
6
- context.filterParams.streamTokenCallback = (data) => {
7
- callback(context, data);
8
- };
9
- return next(context);
10
- };
11
- return streamAgentFilter;
12
- };
13
- exports.streamAgentFilterGenerator = streamAgentFilterGenerator;
@@ -1,11 +0,0 @@
1
- export declare const defaultTestContext: {
2
- debugInfo: {
3
- nodeId: string;
4
- retry: number;
5
- verbose: boolean;
6
- };
7
- params: {};
8
- filterParams: {};
9
- agents: {};
10
- log: never[];
11
- };
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.defaultTestContext = void 0;
4
- exports.defaultTestContext = {
5
- debugInfo: {
6
- nodeId: "test",
7
- retry: 0,
8
- verbose: true,
9
- },
10
- params: {},
11
- filterParams: {},
12
- agents: {},
13
- log: [],
14
- };