@receptron/graphai_cli 0.2.0 → 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 +11 -2
- package/lib/args.d.ts +3 -0
- package/lib/args.js +19 -0
- package/lib/graphai_cli.d.ts +1 -1
- package/lib/graphai_cli.js +22 -2
- package/lib/mermaid.d.ts +2 -0
- package/lib/mermaid.js +28 -0
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
# graphai cli
|
|
1
|
+
# graphai cli🤖
|
|
2
2
|
|
|
3
3
|
graphai command line tool
|
|
4
4
|
|
|
5
|
+
## Install 🚀
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm i -g @receptron/graphai_cli
|
|
9
|
+
```
|
|
10
|
+
|
|
5
11
|
## Usage
|
|
6
12
|
|
|
7
13
|
```
|
|
@@ -16,9 +22,12 @@ Options:
|
|
|
16
22
|
--help Show help [boolean]
|
|
17
23
|
--version Show version number [boolean]
|
|
18
24
|
-l, --list agents list
|
|
19
|
-
-s, --sample
|
|
25
|
+
-s, --sample agent sample data [string]
|
|
20
26
|
-d, --detail agent detail [string]
|
|
21
27
|
-v, --verbose verbose log [boolean] [required] [default: false]
|
|
28
|
+
-m, --mermaid mermaid [boolean] [required] [default: false]
|
|
29
|
+
--yaml dump yaml [boolean] [required] [default: false]
|
|
30
|
+
--json dump json [boolean] [required] [default: false]
|
|
22
31
|
--log output log [string]
|
|
23
32
|
```
|
|
24
33
|
|
package/lib/args.d.ts
CHANGED
package/lib/args.js
CHANGED
|
@@ -27,6 +27,25 @@ exports.args = yargs_1.default
|
|
|
27
27
|
demandOption: true,
|
|
28
28
|
default: false,
|
|
29
29
|
type: "boolean",
|
|
30
|
+
})
|
|
31
|
+
.option("m", {
|
|
32
|
+
alias: "mermaid",
|
|
33
|
+
describe: "mermaid",
|
|
34
|
+
demandOption: true,
|
|
35
|
+
default: false,
|
|
36
|
+
type: "boolean",
|
|
37
|
+
})
|
|
38
|
+
.option("yaml", {
|
|
39
|
+
describe: "dump yaml",
|
|
40
|
+
demandOption: true,
|
|
41
|
+
default: false,
|
|
42
|
+
type: "boolean",
|
|
43
|
+
})
|
|
44
|
+
.option("json", {
|
|
45
|
+
describe: "dump json",
|
|
46
|
+
demandOption: true,
|
|
47
|
+
default: false,
|
|
48
|
+
type: "boolean",
|
|
30
49
|
})
|
|
31
50
|
.option("log", {
|
|
32
51
|
description: "output log",
|
package/lib/graphai_cli.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
import "dotenv/config";
|
package/lib/graphai_cli.js
CHANGED
|
@@ -29,12 +29,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
29
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
30
|
const graphai_1 = require("graphai");
|
|
31
31
|
const packages = __importStar(require("graphai/lib/experimental_agents/packages"));
|
|
32
|
+
require("dotenv/config");
|
|
32
33
|
const fs_1 = __importDefault(require("fs"));
|
|
33
34
|
const path_1 = __importDefault(require("path"));
|
|
35
|
+
const yaml_1 = __importDefault(require("yaml"));
|
|
34
36
|
const args_1 = require("./args");
|
|
35
37
|
const utils_1 = require("./utils");
|
|
36
38
|
const file_utils_1 = require("./file_utils");
|
|
37
39
|
const options_1 = require("./options");
|
|
40
|
+
const mermaid_1 = require("./mermaid");
|
|
38
41
|
const fileFullPath = (file) => {
|
|
39
42
|
return path_1.default.resolve(process.cwd() + "/" + file) || "";
|
|
40
43
|
};
|
|
@@ -54,6 +57,18 @@ const main = async () => {
|
|
|
54
57
|
}
|
|
55
58
|
try {
|
|
56
59
|
const graph_data = (0, file_utils_1.readGraphaiData)(file_path);
|
|
60
|
+
if (args_1.args.mermaid) {
|
|
61
|
+
(0, mermaid_1.mermaid)(graph_data);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
if (args_1.args.json) {
|
|
65
|
+
console.log(JSON.stringify(graph_data, null, 2));
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (args_1.args.yaml) {
|
|
69
|
+
console.log(yaml_1.default.stringify(graph_data, null, 2));
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
57
72
|
const agents = Object.entries(packages).reduce((tmp, current) => {
|
|
58
73
|
const [k, v] = current;
|
|
59
74
|
tmp[v.name] = v.agent;
|
|
@@ -63,8 +78,13 @@ const main = async () => {
|
|
|
63
78
|
if (args_1.args.verbose) {
|
|
64
79
|
graph.onLogCallback = utils_1.callbackLog;
|
|
65
80
|
}
|
|
66
|
-
|
|
67
|
-
|
|
81
|
+
try {
|
|
82
|
+
const results = await graph.run();
|
|
83
|
+
console.log(results);
|
|
84
|
+
}
|
|
85
|
+
catch (e) {
|
|
86
|
+
console.log("error", e);
|
|
87
|
+
}
|
|
68
88
|
if (args_1.args.log) {
|
|
69
89
|
const logfile = fileFullPath(args_1.args.log);
|
|
70
90
|
fs_1.default.writeFileSync(logfile, JSON.stringify(graph.transactionLogs(), null, 2));
|
package/lib/mermaid.d.ts
ADDED
package/lib/mermaid.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mermaid = void 0;
|
|
4
|
+
const utils_1 = require("graphai/lib/utils/utils");
|
|
5
|
+
const mermaid = (graphData) => {
|
|
6
|
+
console.log("flowchart TD");
|
|
7
|
+
Object.keys(graphData.nodes).forEach((nodeId) => {
|
|
8
|
+
const node = graphData.nodes[nodeId];
|
|
9
|
+
// label / name
|
|
10
|
+
if ("agentId" in node) {
|
|
11
|
+
if (node.inputs) {
|
|
12
|
+
node.inputs.forEach((input) => {
|
|
13
|
+
const source = (0, utils_1.parseNodeName)(input);
|
|
14
|
+
if (source.propIds) {
|
|
15
|
+
console.log(` ${source.nodeId}(${source.nodeId}) -- ${source.propIds.join(".")} --> ${nodeId}`);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
console.log(` ${source.nodeId}(${source.nodeId}) --> ${nodeId}`);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
if ("value" in node) {
|
|
24
|
+
// console.log(node.value);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
exports.mermaid = mermaid;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@receptron/graphai_cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "GraphAI command line tools.",
|
|
5
5
|
"main": "lib/graphai_cli.js",
|
|
6
6
|
"bin": {
|
|
@@ -47,7 +47,8 @@
|
|
|
47
47
|
"deepmerge": "^4.3.1",
|
|
48
48
|
"dotenv": "^16.4.5",
|
|
49
49
|
"express": "^4.19.2",
|
|
50
|
-
"graphai": "0.2.
|
|
50
|
+
"graphai": "^0.2.7",
|
|
51
|
+
"groq-sdk": "^0.3.3",
|
|
51
52
|
"openai": "^4.12.4",
|
|
52
53
|
"slashgpt": "^0.0.8",
|
|
53
54
|
"tiktoken": "^1.0.14",
|