@autobe/benchmark 0.27.0

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.
@@ -0,0 +1,39 @@
1
+ import { AutoBeEventSnapshot, AutoBeExampleProject, AutoBeHistory, AutoBePhase, AutoBeUserMessageHistory, IAutoBeTokenUsageJson } from "@autobe/interface";
2
+ export declare namespace AutoBeExampleStorage {
3
+ const repository: () => string;
4
+ const getDirectory: (props: {
5
+ vendor: string;
6
+ project: string;
7
+ }) => string;
8
+ const save: (props: {
9
+ vendor: string;
10
+ project: AutoBeExampleProject;
11
+ files: Record<string, string>;
12
+ }) => Promise<void>;
13
+ const getUserMessage: (props: {
14
+ project: AutoBeExampleProject;
15
+ phase: AutoBePhase;
16
+ }) => Promise<AutoBeUserMessageHistory>;
17
+ const getVendorModels: () => Promise<string[]>;
18
+ const getHistories: (props: {
19
+ vendor: string;
20
+ project: AutoBeExampleProject;
21
+ phase: AutoBePhase;
22
+ }) => Promise<AutoBeHistory[]>;
23
+ const getSnapshots: (props: {
24
+ vendor: string;
25
+ project: AutoBeExampleProject;
26
+ phase: AutoBePhase;
27
+ }) => Promise<AutoBeEventSnapshot[]>;
28
+ const getTokenUsage: (props: {
29
+ vendor: string;
30
+ project: AutoBeExampleProject;
31
+ phase: AutoBePhase;
32
+ }) => Promise<IAutoBeTokenUsageJson>;
33
+ const has: (props: {
34
+ vendor: string;
35
+ project: AutoBeExampleProject;
36
+ phase: AutoBePhase;
37
+ }) => Promise<boolean>;
38
+ const slugModel: (model: string, replaceSlash: boolean) => string;
39
+ }
@@ -0,0 +1,169 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.AutoBeExampleStorage = void 0;
16
+ const filesystem_1 = require("@autobe/filesystem");
17
+ const child_process_1 = __importDefault(require("child_process"));
18
+ const fs_1 = __importDefault(require("fs"));
19
+ const path_1 = __importDefault(require("path"));
20
+ const tstl_1 = require("tstl");
21
+ const uuid_1 = require("uuid");
22
+ var AutoBeExampleStorage;
23
+ (function (AutoBeExampleStorage) {
24
+ AutoBeExampleStorage.repository = () => examples.get();
25
+ AutoBeExampleStorage.getDirectory = (props) => `${examples.get()}/raw/${AutoBeExampleStorage.slugModel(props.vendor, false)}/${props.project}`;
26
+ AutoBeExampleStorage.save = (props) => __awaiter(this, void 0, void 0, function* () {
27
+ yield saveWithGzip({
28
+ root: `${AutoBeExampleStorage.getDirectory(props)}`,
29
+ files: props.files,
30
+ overwrite: true,
31
+ });
32
+ });
33
+ AutoBeExampleStorage.getUserMessage = (props) => __awaiter(this, void 0, void 0, function* () {
34
+ const full = `${TEST_ROOT}/scripts/${props.project}/${props.phase}`;
35
+ if (fs_1.default.existsSync(`${full}.md`) === false) {
36
+ const text = props.phase === "analyze"
37
+ ? yield fs_1.default.promises.readFile(`${TEST_ROOT}/scripts/${props.project}.md`, "utf8")
38
+ : PROMPT_TEMPLATE[props.phase];
39
+ return {
40
+ type: "userMessage",
41
+ id: (0, uuid_1.v7)(),
42
+ created_at: new Date().toISOString(),
43
+ contents: [
44
+ {
45
+ type: "text",
46
+ text,
47
+ },
48
+ ],
49
+ };
50
+ }
51
+ const text = yield fs_1.default.promises.readFile(`${full}.md`, "utf8");
52
+ return {
53
+ type: "userMessage",
54
+ id: (0, uuid_1.v7)(),
55
+ created_at: new Date().toISOString(),
56
+ contents: [
57
+ {
58
+ type: "text",
59
+ text: text,
60
+ },
61
+ ],
62
+ };
63
+ });
64
+ AutoBeExampleStorage.getVendorModels = () => __awaiter(this, void 0, void 0, function* () {
65
+ const result = [];
66
+ const repoPath = AutoBeExampleStorage.repository();
67
+ for (const vendor of yield fs_1.default.promises.readdir(repoPath))
68
+ for (const model of yield fs_1.default.promises.readdir(`${repoPath}/${vendor}`)) {
69
+ const stat = yield fs_1.default.promises.lstat(`${repoPath}/${vendor}/${model}`);
70
+ if (stat.isDirectory() === true)
71
+ result.push(`${vendor}/${model}`);
72
+ }
73
+ return result.sort();
74
+ });
75
+ AutoBeExampleStorage.getHistories = (props) => __awaiter(this, void 0, void 0, function* () {
76
+ const location = `${AutoBeExampleStorage.getDirectory(props)}/${props.phase}.histories.json.gz`;
77
+ const content = yield filesystem_1.CompressUtil.gunzip(yield fs_1.default.promises.readFile(location));
78
+ return JSON.parse(content);
79
+ });
80
+ AutoBeExampleStorage.getSnapshots = (props) => __awaiter(this, void 0, void 0, function* () {
81
+ const location = `${AutoBeExampleStorage.getDirectory(props)}/${props.phase}.snapshots.json.gz`;
82
+ const content = yield filesystem_1.CompressUtil.gunzip(yield fs_1.default.promises.readFile(location));
83
+ return JSON.parse(content);
84
+ });
85
+ AutoBeExampleStorage.getTokenUsage = (props) => __awaiter(this, void 0, void 0, function* () {
86
+ var _a, _b;
87
+ const snapshots = yield AutoBeExampleStorage.getSnapshots(props);
88
+ return ((_b = (_a = snapshots.at(-1)) === null || _a === void 0 ? void 0 : _a.tokenUsage) !== null && _b !== void 0 ? _b : (() => {
89
+ const component = () => ({
90
+ total: 0,
91
+ input: {
92
+ total: 0,
93
+ cached: 0,
94
+ },
95
+ output: {
96
+ total: 0,
97
+ reasoning: 0,
98
+ accepted_prediction: 0,
99
+ rejected_prediction: 0,
100
+ },
101
+ });
102
+ return {
103
+ aggregate: component(),
104
+ facade: component(),
105
+ analyze: component(),
106
+ prisma: component(),
107
+ interface: component(),
108
+ test: component(),
109
+ realize: component(),
110
+ };
111
+ })());
112
+ });
113
+ AutoBeExampleStorage.has = (props) => __awaiter(this, void 0, void 0, function* () {
114
+ return fs_1.default.existsSync(`${AutoBeExampleStorage.getDirectory(props)}/${props.phase}.histories.json.gz`);
115
+ });
116
+ AutoBeExampleStorage.slugModel = (model, replaceSlash) => {
117
+ model = model.replaceAll(":", "-");
118
+ if (replaceSlash)
119
+ model = model.replaceAll("/", "-");
120
+ return model;
121
+ };
122
+ })(AutoBeExampleStorage || (exports.AutoBeExampleStorage = AutoBeExampleStorage = {}));
123
+ const PROMPT_TEMPLATE = {
124
+ prisma: "Design the database schema.",
125
+ interface: "Create the API interface specification.",
126
+ test: "Make the e2e test functions.",
127
+ realize: "Implement API functions.",
128
+ };
129
+ const TEST_ROOT = `${__dirname}/../../../../test`;
130
+ const examples = new tstl_1.Singleton(() => {
131
+ const location = `${TEST_ROOT}/repositories/autobe-examples`;
132
+ if (fs_1.default.existsSync(location) === false) {
133
+ try {
134
+ fs_1.default.mkdirSync(`${TEST_ROOT}/repositories`);
135
+ }
136
+ catch (_a) { }
137
+ child_process_1.default.execSync(`git clone https://github.com/wrtnlabs/autobe-examples`, {
138
+ cwd: `${TEST_ROOT}/repositories`,
139
+ stdio: "inherit",
140
+ });
141
+ }
142
+ child_process_1.default.execSync("git pull", {
143
+ cwd: location,
144
+ stdio: "ignore",
145
+ });
146
+ if (fs_1.default.existsSync(`${location}/raw`) === false)
147
+ fs_1.default.mkdirSync(`${location}/raw`);
148
+ return location;
149
+ });
150
+ const saveWithGzip = (props) => __awaiter(void 0, void 0, void 0, function* () {
151
+ if (props.overwrite !== true && fs_1.default.existsSync(props.root))
152
+ yield fs_1.default.promises.rm(props.root, {
153
+ recursive: true,
154
+ });
155
+ const directory = new tstl_1.VariadicSingleton((location) => __awaiter(void 0, void 0, void 0, function* () {
156
+ try {
157
+ yield fs_1.default.promises.mkdir(location, {
158
+ recursive: true,
159
+ });
160
+ }
161
+ catch (_a) { }
162
+ }));
163
+ for (const [key, value] of Object.entries(props.files)) {
164
+ const file = path_1.default.resolve(`${props.root}/${key}.gz`);
165
+ yield directory.get(path_1.default.dirname(file));
166
+ yield fs_1.default.promises.writeFile(file, yield filesystem_1.CompressUtil.gzip(value !== null && value !== void 0 ? value : ""));
167
+ }
168
+ });
169
+ //# sourceMappingURL=AutoBeExampleStorage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AutoBeExampleStorage.js","sourceRoot":"","sources":["../../src/example/AutoBeExampleStorage.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mDAAkD;AASlD,kEAA+B;AAC/B,4CAAoB;AACpB,gDAAwB;AACxB,+BAAoD;AACpD,+BAA0B;AAE1B,IAAiB,oBAAoB,CAkJpC;AAlJD,WAAiB,oBAAoB;IACtB,+BAAU,GAAG,GAAW,EAAE,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC;IAC1C,iCAAY,GAAG,CAAC,KAG5B,EAAU,EAAE,CACX,GAAG,QAAQ,CAAC,GAAG,EAAE,QAAQ,qBAAA,SAAS,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;IAEhE,yBAAI,GAAG,CAAO,KAI1B,EAAiB,EAAE;QAClB,MAAM,YAAY,CAAC;YACjB,IAAI,EAAE,GAAG,qBAAA,YAAY,CAAC,KAAK,CAAC,EAAE;YAC9B,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,SAAS,EAAE,IAAI;SAChB,CAAC,CAAC;IACL,CAAC,CAAA,CAAC;IAEW,mCAAc,GAAG,CAAO,KAGpC,EAAqC,EAAE;QACtC,MAAM,IAAI,GAAW,GAAG,SAAS,YAAY,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;QAC5E,IAAI,YAAE,CAAC,UAAU,CAAC,GAAG,IAAI,KAAK,CAAC,KAAK,KAAK,EAA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CAAC,CAAA,CAAC,CAAC;IACH,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;QACvD,MAAM,IAAI,GAAW,cAAI,CAAC,OAAO,CAAC,GAAG,KAAK,CAAC,IAAI,IAAI,GAAG,KAAK,CAAC,CAAC;QAC7D,MAAM,SAAS,CAAC,GAAG,CAAC,cAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QACxC,MAAM,YAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,EAAE,MAAM,yBAAY,CAAC,IAAI,CAAC,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,EAAE,CAAC,CAAC,CAAC;IAC1E,CAAC;AACH,CAAC,CAAA,CAAC"}
@@ -0,0 +1 @@
1
+ export * from "./AutoBeExampleStorage";
@@ -0,0 +1,18 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./AutoBeExampleStorage"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/example/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yDAAuC"}
package/lib/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./example";
2
+ export * from "./replay";
package/lib/index.js ADDED
@@ -0,0 +1,19 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./example"), exports);
18
+ __exportStar(require("./replay"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,2CAAyB"}
@@ -0,0 +1,7 @@
1
+ import { AutoBeExampleProject, IAutoBePlaygroundBenchmarkScore, IAutoBePlaygroundReplay } from "@autobe/interface";
2
+ export declare namespace AutoBeReplayComputer {
3
+ const SIGNIFICANT_PROJECTS: AutoBeExampleProject[];
4
+ const emoji: (summaries: IAutoBePlaygroundReplay.ISummary[]) => string;
5
+ const score: (summaries: IAutoBePlaygroundReplay.ISummary[]) => IAutoBePlaygroundBenchmarkScore;
6
+ const summarize: (replay: IAutoBePlaygroundReplay) => IAutoBePlaygroundReplay.ISummary;
7
+ }
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AutoBeReplayComputer = void 0;
4
+ const AutoBeProcessAggregateFactory_1 = require("@autobe/agent/src/factory/AutoBeProcessAggregateFactory");
5
+ var AutoBeReplayComputer;
6
+ (function (AutoBeReplayComputer) {
7
+ AutoBeReplayComputer.SIGNIFICANT_PROJECTS = [
8
+ "todo",
9
+ "bbs",
10
+ "reddit",
11
+ "shopping",
12
+ ];
13
+ AutoBeReplayComputer.emoji = (summaries) => {
14
+ const success = summaries.filter((s) => s.realize !== null && s.realize.success === true).length;
15
+ if (success >= 3)
16
+ return "🟢";
17
+ const tested = !!summaries.find((s) => s.test !== null);
18
+ return tested ? "🟡" : "❌";
19
+ };
20
+ AutoBeReplayComputer.score = (summaries) => {
21
+ // list up significant projects
22
+ summaries = summaries.filter((s) => ["todo", "bbs", "reddit", "shopping"].includes(s.project));
23
+ // the formula to compute the benchmark score
24
+ const compute = (summary) => {
25
+ const add = (phase, success, failure) => phase !== null
26
+ ? phase.success === true
27
+ ? success
28
+ : (failure !== null && failure !== void 0 ? failure : success / 2)
29
+ : 0;
30
+ return (add(summary.analyze, 10) +
31
+ add(summary.prisma, 20) +
32
+ add(summary.interface, 30) +
33
+ add(summary.test, 20) +
34
+ add(summary.realize, 20));
35
+ };
36
+ const individual = (project) => {
37
+ const found = summaries.find((s) => s.project === project);
38
+ if (found === undefined)
39
+ return 0;
40
+ return compute(found);
41
+ };
42
+ return {
43
+ aggregate: summaries.map(compute).reduce((a, b) => a + b, 0) / 4,
44
+ todo: individual("todo"),
45
+ bbs: individual("bbs"),
46
+ reddit: individual("reddit"),
47
+ shopping: individual("shopping"),
48
+ };
49
+ };
50
+ AutoBeReplayComputer.summarize = (replay) => {
51
+ var _a;
52
+ const predicate = (type, success, commodity) => {
53
+ var _a;
54
+ const reversed = replay.histories.slice().reverse();
55
+ const step = (_a = reversed.find((h) => h.type === "analyze")) === null || _a === void 0 ? void 0 : _a.step;
56
+ if (step === undefined)
57
+ return null;
58
+ const history = reversed.find((h) => h.type === type && h.step === step);
59
+ if (history === undefined)
60
+ return null;
61
+ return {
62
+ success: success(history),
63
+ commodity: commodity(history),
64
+ elapsed: new Date(history.completed_at).getTime() -
65
+ new Date(history.created_at).getTime(),
66
+ aggregates: history.aggregates,
67
+ };
68
+ };
69
+ const phaseStates = {
70
+ analyze: predicate("analyze", () => true, (h) => ({
71
+ actors: h.actors.length,
72
+ documents: h.files.length,
73
+ })),
74
+ prisma: predicate("prisma", (h) => h.compiled.type === "success", (h) => ({
75
+ namespaces: h.result.data.files.length,
76
+ models: h.result.data.files.map((f) => f.models).flat().length,
77
+ })),
78
+ interface: predicate("interface", (h) => h.missed.length === 0, (h) => ({
79
+ operations: h.document.operations.length,
80
+ schemas: Object.keys(h.document.components.schemas).length,
81
+ })),
82
+ test: predicate("test", (h) => h.compiled.type === "success", (h) => (Object.assign({ functions: h.files.length }, (h.compiled.type === "failure"
83
+ ? {
84
+ errors: new Set(h.compiled.diagnostics.map((d) => { var _a; return (_a = d.file) !== null && _a !== void 0 ? _a : ""; }))
85
+ .size,
86
+ }
87
+ : {})))),
88
+ realize: predicate("realize", (h) => h.compiled.type === "success", (h) => (Object.assign({ functions: h.functions.length }, (h.compiled.type === "failure"
89
+ ? {
90
+ errors: new Set(h.compiled.diagnostics.map((d) => { var _a; return (_a = d.file) !== null && _a !== void 0 ? _a : ""; }))
91
+ .size,
92
+ }
93
+ : {})))),
94
+ };
95
+ const phase = (_a = ["realize", "test", "interface", "prisma", "analyze"].find((key) => phaseStates[key] !== null)) !== null && _a !== void 0 ? _a : null;
96
+ return Object.assign(Object.assign({ vendor: replay.vendor, project: replay.project, aggregates: AutoBeProcessAggregateFactory_1.AutoBeProcessAggregateFactory.reduce(replay.histories
97
+ .filter((h) => h.type === "analyze" ||
98
+ h.type === "prisma" ||
99
+ h.type === "interface" ||
100
+ h.type === "test" ||
101
+ h.type === "realize")
102
+ .map((h) => h.aggregates)), elapsed: replay.histories
103
+ .filter((h) => h.type !== "userMessage" && h.type !== "assistantMessage")
104
+ .map((h) => new Date(h.completed_at).getTime() -
105
+ new Date(h.created_at).getTime())
106
+ .reduce((a, b) => a + b, 0) }, phaseStates), { phase });
107
+ };
108
+ })(AutoBeReplayComputer || (exports.AutoBeReplayComputer = AutoBeReplayComputer = {}));
109
+ //# sourceMappingURL=AutoBeReplayComputer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AutoBeReplayComputer.js","sourceRoot":"","sources":["../../src/replay/AutoBeReplayComputer.ts"],"names":[],"mappings":";;;AAAA,2GAAwG;AASxG,IAAiB,oBAAoB,CAmLpC;AAnLD,WAAiB,oBAAoB;IACtB,yCAAoB,GAA2B;QAC1D,MAAM;QACN,KAAK;QACL,QAAQ;QACR,UAAU;KACX,CAAC;IAEW,0BAAK,GAAG,CACnB,SAA6C,EACrC,EAAE;QACV,MAAM,OAAO,GAAW,SAAS,CAAC,MAAM,CACtC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,KAAK,IAAI,IAAI,CAAC,CAAC,OAAO,CAAC,OAAO,KAAK,IAAI,CACxD,CAAC,MAAM,CAAC;QACT,IAAI,OAAO,IAAI,CAAC;YAAE,OAAO,IAAI,CAAC;QAE9B,MAAM,MAAM,GAAY,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;QACjE,OAAO,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC;IAC7B,CAAC,CAAC;IAEW,0BAAK,GAAG,CACnB,SAA6C,EACZ,EAAE;QACnC,+BAA+B;QAC/B,SAAS,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CACjC,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAC1D,CAAC;QAEF,6CAA6C;QAC7C,MAAM,OAAO,GAAG,CAAC,OAAyC,EAAU,EAAE;YACp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MAAM,CACL,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,aAAa,IAAI,CAAC,CAAC,IAAI,KAAK,kBAAkB,CACjE;iBACA,GAAG,CACF,CAAC,CAAC,EAAE,EAAE,CACJ,IAAI,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,OAAO,EAAE;gBAClC,IAAI,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,OAAO,EAAE,CACnC;iBACA,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,IAC1B,WAAW,KACd,KAAK,IACL;IACJ,CAAC,CAAC;AACJ,CAAC,EAnLgB,oBAAoB,oCAApB,oBAAoB,QAmLpC"}
@@ -0,0 +1,4 @@
1
+ import { IAutoBePlaygroundBenchmark } from "@autobe/interface";
2
+ export declare namespace AutoBeReplayDocumentation {
3
+ const readme: (experiments: IAutoBePlaygroundBenchmark[]) => string;
4
+ }
@@ -0,0 +1,146 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AutoBeReplayDocumentation = void 0;
4
+ const utils_1 = require("@autobe/utils");
5
+ const AutoBeExampleStorage_1 = require("../example/AutoBeExampleStorage");
6
+ var AutoBeReplayDocumentation;
7
+ (function (AutoBeReplayDocumentation) {
8
+ AutoBeReplayDocumentation.readme = (experiments) => {
9
+ return utils_1.StringUtil.trim `
10
+ # AutoBe Generated Examples
11
+
12
+ ## Benchmark
13
+
14
+ AI Model | Score | FCSR | Status
15
+ :--------|------:|-----:|:------:
16
+ ${experiments
17
+ .map((e) => [
18
+ `[\`${AutoBeExampleStorage_1.AutoBeExampleStorage.slugModel(e.vendor, false)}\`](#${AutoBeExampleStorage_1.AutoBeExampleStorage.slugModel(e.vendor, false)
19
+ .replaceAll("/", "")
20
+ .replaceAll(".", "")})`,
21
+ e.score.aggregate,
22
+ (() => {
23
+ const [x, y] = e.replays
24
+ .map((r) => r.aggregates.total.metric)
25
+ .map((m) => [m.success, m.attempt])
26
+ .reduce((a, b) => [a[0] + b[0], a[1] + b[1]], [0, 0]);
27
+ return y === 0 ? "0%" : Math.floor((x / y) * 100) + "%";
28
+ })(),
29
+ e.emoji,
30
+ ].join(" | "))
31
+ .join("\n")}
32
+
33
+ - FCSR: Function Calling Success Rate
34
+ - Status:
35
+ - 🟢: All projects completed successfully
36
+ - 🟡: Some projects failed
37
+ - ❌: All projects failed or not executed
38
+
39
+ ${experiments.map(vendor).join("\n\n\n")}
40
+ `;
41
+ };
42
+ const vendor = (exp) => {
43
+ const row = (project) => {
44
+ const found = exp.replays.find((r) => r.project === project);
45
+ if (found === undefined)
46
+ return `\`${project}\` | 0 | ❌ | ❌ | ❌ | ❌ | ❌`;
47
+ const phase = (state) => {
48
+ if (state === null)
49
+ return "❌";
50
+ else if (state.success === false)
51
+ return "🟡";
52
+ else
53
+ return "🟢";
54
+ };
55
+ return [
56
+ `[\`${found.project}\`](./${exp.vendor}/${found.project}/)`,
57
+ exp.score[project],
58
+ phase(found.analyze),
59
+ phase(found.prisma),
60
+ phase(found.interface),
61
+ phase(found.test),
62
+ phase(found.realize),
63
+ ].join(" | ");
64
+ };
65
+ return utils_1.StringUtil.trim `
66
+ ## \`${exp.vendor}\`
67
+
68
+ Project | Score | Analyze | Prisma | Interface | Test | Realize
69
+ :-------|------:|:-------:|:------:|:----------|:----:|:-------:
70
+ ${row("todo")}
71
+ ${row("bbs")}
72
+ ${row("reddit")}
73
+ ${row("shopping")}
74
+
75
+ ${exp.replays
76
+ .map((r) => project({
77
+ replay: r,
78
+ score: exp.score[r.project],
79
+ }))
80
+ .join("\n\n\n")}
81
+ `;
82
+ };
83
+ const project = (props) => {
84
+ const phase = (key) => {
85
+ const title = key.charAt(0).toUpperCase() + key.slice(1);
86
+ const state = props.replay[key];
87
+ if (state === null)
88
+ return [`⚪ ${title}`, "", "", "", ""].join(" | ");
89
+ return [
90
+ `${state.success === true ? "🟢" : "🔴"} ${title}`,
91
+ Object.entries(state.commodity)
92
+ .map(([key, value]) => `\`${key}\`: ${value}`)
93
+ .join(", "),
94
+ formatTokens(state.aggregates.total.tokenUsage.total),
95
+ formatElapsedTime(state.elapsed),
96
+ Math.floor((state.aggregates.total.metric.success /
97
+ state.aggregates.total.metric.attempt) *
98
+ 100) + "%",
99
+ ].join(" | ");
100
+ };
101
+ return utils_1.StringUtil.trim `
102
+ ### \`${props.replay.vendor}\` - \`${props.replay.project}\`
103
+
104
+ - Source Code: ${`[\`${AutoBeExampleStorage_1.AutoBeExampleStorage.slugModel(props.replay.vendor, false)}/${props.replay.project}\`](./${AutoBeExampleStorage_1.AutoBeExampleStorage.slugModel(props.replay.vendor, false)}/${props.replay.project}/)`}
105
+ - Score: ${props.score}
106
+ - Elapsed Time: ${formatElapsedTime(props.replay.elapsed)}
107
+ - Token Usage: ${formatTokens(props.replay.aggregates.total.tokenUsage.total)}
108
+ - Function Calling Success Rate: ${((props.replay.aggregates.total.metric.success /
109
+ props.replay.aggregates.total.metric.attempt) *
110
+ 100).toFixed(2)}%
111
+
112
+ Phase | Generated | Token Usage | Elapsed Time | FCSR
113
+ :-----|:----------|------------:|-------------:|------:
114
+ ${["analyze", "prisma", "interface", "test", "realize"]
115
+ .map((key) => phase(key))
116
+ .join("\n")}
117
+ `;
118
+ };
119
+ })(AutoBeReplayDocumentation || (exports.AutoBeReplayDocumentation = AutoBeReplayDocumentation = {}));
120
+ function formatElapsedTime(ms) {
121
+ const seconds = Math.floor(ms / 1000);
122
+ const minutes = Math.floor(seconds / 60);
123
+ const hours = Math.floor(minutes / 60);
124
+ const s = seconds % 60;
125
+ const m = minutes % 60;
126
+ const h = hours;
127
+ if (h > 0) {
128
+ return `${h}h ${m}m ${s}s`;
129
+ }
130
+ else if (m > 0) {
131
+ return `${m}m ${s}s`;
132
+ }
133
+ else {
134
+ return `${s}s`;
135
+ }
136
+ }
137
+ function formatTokens(num) {
138
+ if (num >= 1000000) {
139
+ return `${(num / 1000000).toFixed(2)}M`;
140
+ }
141
+ else if (num >= 1000) {
142
+ return `${(num / 1000).toFixed(1)}K`;
143
+ }
144
+ return num.toString();
145
+ }
146
+ //# sourceMappingURL=AutoBeReplayDocumentation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AutoBeReplayDocumentation.js","sourceRoot":"","sources":["../../src/replay/AutoBeReplayDocumentation.ts"],"names":[],"mappings":";;;AAMA,yCAA2C;AAE3C,0EAAuE;AAEvE,IAAiB,yBAAyB,CAuIzC;AAvID,WAAiB,yBAAyB;IAC3B,gCAAM,GAAG,CAAC,WAAyC,EAAU,EAAE;QAC1E,OAAO,kBAAU,CAAC,IAAI,CAAA;;;;;;;QAOlB,WAAW;aACV,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CACT;YACE,MAAM,2CAAoB,CAAC,SAAS,CAClC,CAAC,CAAC,MAAM,EACR,KAAK,CACN,QAAQ,2CAAoB,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC;iBACrD,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC;iBACnB,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG;YACzB,CAAC,CAAC,KAAK,CAAC,SAAS;YACjB,CAAC,GAAG,EAAE;gBACJ,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,OAAO;qBACrB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC;qBACrC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC;qBAClC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,C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,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;IACvC,CAAC;IACD,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;AACxB,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { AutoBeExampleProject, IAutoBePlaygroundReplay } from "@autobe/interface";
2
+ export declare namespace AutoBeReplayStorage {
3
+ const getAll: (vendor: string, projectFilter?: (project: AutoBeExampleProject) => boolean) => Promise<IAutoBePlaygroundReplay[]>;
4
+ const get: (props: {
5
+ vendor: string;
6
+ project: AutoBeExampleProject;
7
+ }) => Promise<IAutoBePlaygroundReplay | null>;
8
+ }
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.AutoBeReplayStorage = void 0;
16
+ const typia_1 = __importDefault(require("typia"));
17
+ const AutoBeExampleStorage_1 = require("../example/AutoBeExampleStorage");
18
+ var AutoBeReplayStorage;
19
+ (function (AutoBeReplayStorage) {
20
+ AutoBeReplayStorage.getAll = (vendor, projectFilter) => __awaiter(this, void 0, void 0, function* () {
21
+ const projects = typia_1.default.misc
22
+ .literals()
23
+ .filter(projectFilter !== null && projectFilter !== void 0 ? projectFilter : (() => true));
24
+ const replays = yield Promise.all(projects.map((p) => AutoBeReplayStorage.get({
25
+ vendor,
26
+ project: p,
27
+ })));
28
+ return replays.filter((r) => r !== null);
29
+ });
30
+ AutoBeReplayStorage.get = (props) => __awaiter(this, void 0, void 0, function* () {
31
+ const histories = yield getHistories(props);
32
+ if (histories === null)
33
+ return null;
34
+ const snapshots = (phase) => __awaiter(this, void 0, void 0, function* () {
35
+ try {
36
+ return yield AutoBeExampleStorage_1.AutoBeExampleStorage.getSnapshots({
37
+ vendor: props.vendor,
38
+ project: props.project,
39
+ phase,
40
+ });
41
+ }
42
+ catch (_a) {
43
+ return null;
44
+ }
45
+ });
46
+ return {
47
+ vendor: props.vendor,
48
+ project: props.project,
49
+ histories,
50
+ analyze: yield snapshots("analyze"),
51
+ prisma: yield snapshots("prisma"),
52
+ interface: yield snapshots("interface"),
53
+ test: yield snapshots("test"),
54
+ realize: yield snapshots("realize"),
55
+ };
56
+ });
57
+ const getHistories = (props) => __awaiter(this, void 0, void 0, function* () {
58
+ for (const phase of SEQUENCE) {
59
+ try {
60
+ return yield AutoBeExampleStorage_1.AutoBeExampleStorage.getHistories({
61
+ vendor: props.vendor,
62
+ project: props.project,
63
+ phase,
64
+ });
65
+ }
66
+ catch (_a) { }
67
+ }
68
+ return null;
69
+ });
70
+ })(AutoBeReplayStorage || (exports.AutoBeReplayStorage = AutoBeReplayStorage = {}));
71
+ const SEQUENCE = ["realize", "test", "interface", "prisma", "analyze"];
72
+ //# sourceMappingURL=AutoBeReplayStorage.js.map