@receptron/graphai_cli 0.4.1 → 0.4.2

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/lib/docs.d.ts ADDED
@@ -0,0 +1 @@
1
+ export {};
package/lib/docs.js ADDED
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ const utils_1 = require("graphai/lib/utils/utils");
30
+ const json_schema_generator_1 = __importDefault(require("json-schema-generator"));
31
+ const packages = __importStar(require("graphai/lib/experimental_agents"));
32
+ const fs_1 = __importDefault(require("fs"));
33
+ const path_1 = __importDefault(require("path"));
34
+ const agentAttribute = (agentInfo, key) => {
35
+ if (key === "samples") {
36
+ return agentInfo.samples
37
+ .map((sample) => {
38
+ return [
39
+ "#### inputs",
40
+ "```json",
41
+ JSON.stringify(sample.inputs, null, 2),
42
+ "````",
43
+ "#### params",
44
+ "```json",
45
+ JSON.stringify(sample.params),
46
+ "````",
47
+ "#### result",
48
+ "```json",
49
+ JSON.stringify(sample.result, null, 2),
50
+ "````",
51
+ ].join("\n\n");
52
+ // return JSON.stringify(agentInfo.samples, null, 2);
53
+ })
54
+ .join("\n");
55
+ }
56
+ if (key === "schemas") {
57
+ return agentInfo.samples
58
+ .map((sample) => {
59
+ return ["#### inputs", "```json", JSON.stringify((0, json_schema_generator_1.default)(sample.inputs), null, 2), "````"].join("\n\n");
60
+ // return JSON.stringify(agentInfo.samples, null, 2);
61
+ })
62
+ .join("\n");
63
+ }
64
+ if (key === "resultKey") {
65
+ return agentInfo.samples
66
+ .map((sample) => {
67
+ return ["```json", JSON.stringify((0, utils_1.debugResultKey)("agentId", sample.result), null, 2), "````"].join("\n\n");
68
+ })
69
+ .join("\n");
70
+ }
71
+ return agentInfo[key];
72
+ };
73
+ const readTemplate = (file) => {
74
+ return fs_1.default.readFileSync(path_1.default.resolve(__dirname) + "/../templates/" + file, "utf8");
75
+ };
76
+ const agentMd = (agentInfo) => {
77
+ const template = readTemplate("agent.md");
78
+ const md = ["name", "description", "author", "repository", "license", "samples", "schemas", "resultKey"].reduce((tmp, key) => {
79
+ tmp = tmp.replace("{" + key + "}", agentAttribute(agentInfo, key));
80
+ return tmp;
81
+ }, template);
82
+ return md;
83
+ };
84
+ const IndexMd = (ret) => {
85
+ const templates = [];
86
+ for (const cat of Object.keys(ret)) {
87
+ templates.push("## " + cat);
88
+ for (const agentName of Object.keys(ret[cat])) {
89
+ templates.push("### [" + agentName + "](./" + cat + "/" + agentName + ".md)");
90
+ }
91
+ templates.push("");
92
+ }
93
+ return templates.join("\n");
94
+ };
95
+ const main = () => {
96
+ const ret = {};
97
+ Object.values(packages).map((agent) => {
98
+ const md = agentMd(agent);
99
+ agent.category.map(async (cat) => {
100
+ if (!ret[cat]) {
101
+ ret[cat] = {};
102
+ }
103
+ ret[cat][agent.name] = agent.name;
104
+ const catDir = path_1.default.resolve(__dirname + "/../docs/" + cat);
105
+ await fs_1.default.promises.mkdir(catDir, { recursive: true });
106
+ fs_1.default.writeFileSync(catDir + "/" + agent.name + ".md", md);
107
+ });
108
+ });
109
+ // console.log(ret);
110
+ const index = IndexMd(ret);
111
+ fs_1.default.writeFileSync(__dirname + "/../docs/README.md", index);
112
+ };
113
+ main();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@receptron/graphai_cli",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "GraphAI command line tools.",
5
5
  "main": "lib/graphai_cli.js",
6
6
  "bin": {
@@ -12,6 +12,7 @@
12
12
  "scripts": {
13
13
  "build": "tsc && tsc-alias",
14
14
  "eslint": "eslint --fix",
15
+ "doc": "npx ts-node -r tsconfig-paths/register src/docs.ts",
15
16
  "format": "prettier --write '{src,test_yaml,samples}/**/*.{yaml,ts,json}'",
16
17
  "test": "node --test -r tsconfig-paths/register --require ts-node/register ./test_yaml/test_*.ts",
17
18
  "cli": "npx ts-node -r tsconfig-paths/register ./src/graphai_cli.ts",
@@ -29,15 +30,16 @@
29
30
  "homepage": "https://github.com/receptron/graphai_cli#readme",
30
31
  "devDependencies": {
31
32
  "@types/express": "^4.17.21",
33
+ "@types/json-schema-generator": "^2.0.3",
32
34
  "@types/node": "^20.8.7",
33
35
  "@types/yargs": "^17.0.32",
34
- "eslint": "^9.2.0",
35
- "prettier": "^3.0.3",
36
- "ts-node": "^10.9.1",
36
+ "eslint": "^9.3.0",
37
+ "prettier": "^3.2.5",
38
+ "ts-node": "^10.9.2",
37
39
  "tsc-alias": "^1.8.8",
38
40
  "tsconfig-paths": "^4.2.0",
39
- "typescript": "^5.4.3",
40
- "typescript-eslint": "^7.8.0"
41
+ "typescript": "^5.4.5",
42
+ "typescript-eslint": "^7.9.0"
41
43
  },
42
44
  "dependencies": {
43
45
  "@inquirer/prompts": "^5.0.0",
@@ -45,8 +47,9 @@
45
47
  "deepmerge": "^4.3.1",
46
48
  "dotenv": "^16.4.5",
47
49
  "express": "^4.19.2",
48
- "graphai": "0.4.1",
50
+ "graphai": "^0.4.4",
49
51
  "groq-sdk": "^0.3.3",
52
+ "json-schema-generator": "^2.0.6",
50
53
  "openai": "^4.12.4",
51
54
  "slashgpt": "^0.0.8",
52
55
  "tiktoken": "^1.0.14",