@autobe/agent 0.29.0 → 0.29.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/AutoBeAgent.d.ts +2 -1
- package/lib/AutoBeAgent.js +17 -8
- package/lib/AutoBeAgent.js.map +1 -1
- package/lib/AutoBeAgentBase.d.ts +2 -3
- package/lib/AutoBeAgentBase.js +1 -8
- package/lib/AutoBeAgentBase.js.map +1 -1
- package/lib/AutoBeMockAgent.js +13 -4
- package/lib/AutoBeMockAgent.js.map +1 -1
- package/lib/factory/createAutoBeContext.js +8 -10
- package/lib/factory/createAutoBeContext.js.map +1 -1
- package/lib/factory/getAutoBeGenerated.d.ts +7 -1
- package/lib/factory/getAutoBeGenerated.js +138 -33
- package/lib/factory/getAutoBeGenerated.js.map +1 -1
- package/lib/factory/getAutoBeRealizeGenerated.js +2 -2
- package/lib/factory/getAutoBeRealizeGenerated.js.map +1 -1
- package/lib/factory/getCriticalCompiler.js +2 -4
- package/lib/factory/getCriticalCompiler.js.map +1 -1
- package/lib/index.mjs +139 -222
- package/lib/index.mjs.map +1 -1
- package/lib/orchestrate/realize/internal/compileRealizeFiles.js +2 -1
- package/lib/orchestrate/realize/internal/compileRealizeFiles.js.map +1 -1
- package/lib/orchestrate/realize/orchestrateRealizeAuthorizationWrite.js +2 -1
- package/lib/orchestrate/realize/orchestrateRealizeAuthorizationWrite.js.map +1 -1
- package/lib/orchestrate/realize/utils/getRealizeWriteDto.js +1 -1
- package/lib/orchestrate/realize/utils/getRealizeWriteDto.js.map +1 -1
- package/lib/orchestrate/test/compile/getTestScenarioArtifacts.js +1 -1
- package/lib/orchestrate/test/compile/getTestScenarioArtifacts.js.map +1 -1
- package/lib/orchestrate/test/orchestrateTestCorrect.js +1 -1
- package/lib/utils/executeCachedBatch.js +1 -1
- package/lib/utils/executeCachedBatch.js.map +1 -1
- package/package.json +5 -5
- package/src/AutoBeAgent.ts +16 -5
- package/src/AutoBeAgentBase.ts +3 -12
- package/src/AutoBeMockAgent.ts +15 -4
- package/src/factory/createAutoBeContext.ts +5 -3
- package/src/factory/getAutoBeGenerated.ts +203 -42
- package/src/factory/getAutoBeRealizeGenerated.ts +0 -1
- package/src/factory/getCriticalCompiler.ts +3 -5
- package/src/orchestrate/realize/internal/compileRealizeFiles.ts +4 -4
- package/src/orchestrate/realize/orchestrateRealizeAuthorizationWrite.ts +2 -1
- package/src/orchestrate/realize/utils/getRealizeWriteDto.ts +1 -2
- package/src/orchestrate/test/compile/getTestScenarioArtifacts.ts +1 -1
- package/src/orchestrate/test/orchestrateTestCorrect.ts +1 -1
- package/src/utils/executeCachedBatch.ts +1 -1
- package/lib/factory/AutoBeFunctionCallingMetricFactory.d.ts +0 -7
- package/lib/factory/AutoBeFunctionCallingMetricFactory.js +0 -35
- package/lib/factory/AutoBeFunctionCallingMetricFactory.js.map +0 -1
- package/lib/factory/AutoBeProcessAggregateFactory.d.ts +0 -13
- package/lib/factory/AutoBeProcessAggregateFactory.js +0 -100
- package/lib/factory/AutoBeProcessAggregateFactory.js.map +0 -1
- package/lib/utils/TokenUsageComputer.d.ts +0 -5
- package/lib/utils/TokenUsageComputer.js +0 -29
- package/lib/utils/TokenUsageComputer.js.map +0 -1
- package/src/factory/AutoBeFunctionCallingMetricFactory.ts +0 -44
- package/src/factory/AutoBeProcessAggregateFactory.ts +0 -141
- package/src/utils/TokenUsageComputer.ts +0 -35
|
@@ -20,10 +20,10 @@ export const getCriticalCompiler = (
|
|
|
20
20
|
write: (app, dmbs) => lock(() => compiler.prisma.write(app, dmbs)),
|
|
21
21
|
},
|
|
22
22
|
interface: {
|
|
23
|
-
write: (doc
|
|
23
|
+
write: (doc, exclude) =>
|
|
24
|
+
lock(() => compiler.interface.write(doc, exclude)),
|
|
24
25
|
transform: (doc) => lock(() => compiler.interface.transform(doc)),
|
|
25
26
|
invert: (doc) => lock(() => compiler.interface.invert(doc)),
|
|
26
|
-
getTemplate: () => lock(() => compiler.interface.getTemplate()),
|
|
27
27
|
},
|
|
28
28
|
typescript: {
|
|
29
29
|
compile: (props) => lock(() => compiler.typescript.compile(props)),
|
|
@@ -36,13 +36,11 @@ export const getCriticalCompiler = (
|
|
|
36
36
|
validate: (props) => lock(() => compiler.test.validate(props)),
|
|
37
37
|
write: (props) => lock(() => compiler.test.write(props)),
|
|
38
38
|
getExternal: () => lock(() => compiler.test.getExternal()),
|
|
39
|
-
getTemplate: () => lock(() => compiler.test.getTemplate()),
|
|
40
39
|
},
|
|
41
40
|
realize: {
|
|
42
41
|
controller: (props) => lock(() => compiler.realize.controller(props)),
|
|
43
42
|
test: (props) => lock(() => compiler.realize.test(props)),
|
|
44
|
-
getTemplate: (options) =>
|
|
45
|
-
lock(() => compiler.realize.getTemplate(options)),
|
|
46
43
|
},
|
|
44
|
+
getTemplate: (options) => lock(() => compiler.getTemplate(options)),
|
|
47
45
|
};
|
|
48
46
|
};
|
|
@@ -22,10 +22,10 @@ export async function compileRealizeFiles<Model extends ILlmSchema.Model>(
|
|
|
22
22
|
props.authorizations.map((el) => [el.payload.location, el.payload.content]),
|
|
23
23
|
);
|
|
24
24
|
const compiler: IAutoBeCompiler = await ctx.compiler();
|
|
25
|
-
const templateFiles: Record<string, string> =
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
const templateFiles: Record<string, string> = await compiler.getTemplate({
|
|
26
|
+
phase: "realize",
|
|
27
|
+
dbms: "sqlite",
|
|
28
|
+
});
|
|
29
29
|
const nodeModules: Record<string, string> =
|
|
30
30
|
prisma?.type === "success" ? prisma.nodeModules : {};
|
|
31
31
|
|
|
@@ -46,7 +46,8 @@ export async function orchestrateRealizeAuthorizationWrite<
|
|
|
46
46
|
};
|
|
47
47
|
const templates: Record<string, string> = await (
|
|
48
48
|
await ctx.compiler()
|
|
49
|
-
).
|
|
49
|
+
).getTemplate({
|
|
50
|
+
phase: "realize",
|
|
50
51
|
dbms: "sqlite",
|
|
51
52
|
});
|
|
52
53
|
const authorizations: AutoBeRealizeAuthorization[] = await executeCachedBatch(
|
|
@@ -14,7 +14,7 @@ export async function getRealizeWriteDto<Model extends ILlmSchema.Model>(
|
|
|
14
14
|
|
|
15
15
|
const compiler: IAutoBeCompiler = await ctx.compiler();
|
|
16
16
|
const entries: [string, string][] = Object.entries(
|
|
17
|
-
await compiler.interface.write(document),
|
|
17
|
+
await compiler.interface.write(document, []),
|
|
18
18
|
);
|
|
19
19
|
|
|
20
20
|
const filter = (prefix: string, exclude?: string) => {
|
|
@@ -27,7 +27,6 @@ export async function getRealizeWriteDto<Model extends ILlmSchema.Model>(
|
|
|
27
27
|
: result,
|
|
28
28
|
);
|
|
29
29
|
};
|
|
30
|
-
|
|
31
30
|
const dto: Record<string, string> = filter("src/api/structures");
|
|
32
31
|
return dto;
|
|
33
32
|
}
|
|
@@ -22,7 +22,7 @@ export async function getTestScenarioArtifacts<Model extends ILlmSchema.Model>(
|
|
|
22
22
|
ctx.state().interface!.document,
|
|
23
23
|
);
|
|
24
24
|
const entries: [string, string][] = Object.entries(
|
|
25
|
-
await compiler.interface.write(document),
|
|
25
|
+
await compiler.interface.write(document, []),
|
|
26
26
|
);
|
|
27
27
|
const filter = (prefix: string, exclude?: string) => {
|
|
28
28
|
const result: [string, string][] = entries.filter(
|
|
@@ -24,7 +24,7 @@ export const executeCachedBatch = async <Model extends ILlmSchema.Model, T>(
|
|
|
24
24
|
.map((task, index) => new Pair(task, index));
|
|
25
25
|
const tail: Pair<T, number>[] = [];
|
|
26
26
|
await Promise.all(
|
|
27
|
-
new Array(semaphore).map(async () => {
|
|
27
|
+
new Array(semaphore).fill(0).map(async () => {
|
|
28
28
|
while (remained.length !== 0) {
|
|
29
29
|
const batch: Pair<Task<T>, number> = remained.splice(0, 1)[0]!;
|
|
30
30
|
const result: T = await batch.first(promptCacheKey!);
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { AutoBeFunctionCallingMetric } from "@autobe/interface";
|
|
2
|
-
export declare namespace AutoBeFunctionCallingMetricFactory {
|
|
3
|
-
const create: () => AutoBeFunctionCallingMetric;
|
|
4
|
-
const increment: (x: AutoBeFunctionCallingMetric, y: AutoBeFunctionCallingMetric) => void;
|
|
5
|
-
const plus: (x: AutoBeFunctionCallingMetric, y: AutoBeFunctionCallingMetric) => AutoBeFunctionCallingMetric;
|
|
6
|
-
const minus: (x: AutoBeFunctionCallingMetric, y: AutoBeFunctionCallingMetric) => AutoBeFunctionCallingMetric;
|
|
7
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AutoBeFunctionCallingMetricFactory = void 0;
|
|
4
|
-
var AutoBeFunctionCallingMetricFactory;
|
|
5
|
-
(function (AutoBeFunctionCallingMetricFactory) {
|
|
6
|
-
AutoBeFunctionCallingMetricFactory.create = () => ({
|
|
7
|
-
attempt: 0,
|
|
8
|
-
success: 0,
|
|
9
|
-
consent: 0,
|
|
10
|
-
validationFailure: 0,
|
|
11
|
-
invalidJson: 0,
|
|
12
|
-
});
|
|
13
|
-
AutoBeFunctionCallingMetricFactory.increment = (x, y) => {
|
|
14
|
-
x.attempt += y.attempt;
|
|
15
|
-
x.success += y.success;
|
|
16
|
-
x.consent += y.consent;
|
|
17
|
-
x.validationFailure += y.validationFailure;
|
|
18
|
-
x.invalidJson += y.invalidJson;
|
|
19
|
-
};
|
|
20
|
-
AutoBeFunctionCallingMetricFactory.plus = (x, y) => ({
|
|
21
|
-
attempt: x.attempt + y.attempt,
|
|
22
|
-
success: x.success + y.success,
|
|
23
|
-
consent: x.consent + y.consent,
|
|
24
|
-
validationFailure: x.validationFailure + y.validationFailure,
|
|
25
|
-
invalidJson: x.invalidJson + y.invalidJson,
|
|
26
|
-
});
|
|
27
|
-
AutoBeFunctionCallingMetricFactory.minus = (x, y) => ({
|
|
28
|
-
attempt: x.attempt - y.attempt,
|
|
29
|
-
success: x.success - y.success,
|
|
30
|
-
consent: x.consent - y.consent,
|
|
31
|
-
validationFailure: x.validationFailure - y.validationFailure,
|
|
32
|
-
invalidJson: x.invalidJson - y.invalidJson,
|
|
33
|
-
});
|
|
34
|
-
})(AutoBeFunctionCallingMetricFactory || (exports.AutoBeFunctionCallingMetricFactory = AutoBeFunctionCallingMetricFactory = {}));
|
|
35
|
-
//# sourceMappingURL=AutoBeFunctionCallingMetricFactory.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AutoBeFunctionCallingMetricFactory.js","sourceRoot":"","sources":["../../src/factory/AutoBeFunctionCallingMetricFactory.ts"],"names":[],"mappings":";;;AAEA,IAAiB,kCAAkC,CAyClD;AAzCD,WAAiB,kCAAkC;IACpC,yCAAM,GAAG,GAAgC,EAAE,CAAC,CAAC;QACxD,OAAO,EAAE,CAAC;QACV,OAAO,EAAE,CAAC;QACV,OAAO,EAAE,CAAC;QACV,iBAAiB,EAAE,CAAC;QACpB,WAAW,EAAE,CAAC;KACf,CAAC,CAAC;IAEU,4CAAS,GAAG,CACvB,CAA8B,EAC9B,CAA8B,EACxB,EAAE;QACR,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,OAAO,CAAC;QACvB,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,OAAO,CAAC;QACvB,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,OAAO,CAAC;QACvB,CAAC,CAAC,iBAAiB,IAAI,CAAC,CAAC,iBAAiB,CAAC;QAC3C,CAAC,CAAC,WAAW,IAAI,CAAC,CAAC,WAAW,CAAC;IACjC,CAAC,CAAC;IAEW,uCAAI,GAAG,CAClB,CAA8B,EAC9B,CAA8B,EACD,EAAE,CAAC,CAAC;QACjC,OAAO,EAAE,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,OAAO;QAC9B,OAAO,EAAE,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,OAAO;QAC9B,OAAO,EAAE,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,OAAO;QAC9B,iBAAiB,EAAE,CAAC,CAAC,iBAAiB,GAAG,CAAC,CAAC,iBAAiB;QAC5D,WAAW,EAAE,CAAC,CAAC,WAAW,GAAG,CAAC,CAAC,WAAW;KAC3C,CAAC,CAAC;IAEU,wCAAK,GAAG,CACnB,CAA8B,EAC9B,CAA8B,EACD,EAAE,CAAC,CAAC;QACjC,OAAO,EAAE,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,OAAO;QAC9B,OAAO,EAAE,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,OAAO;QAC9B,OAAO,EAAE,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,OAAO;QAC9B,iBAAiB,EAAE,CAAC,CAAC,iBAAiB,GAAG,CAAC,CAAC,iBAAiB;QAC5D,WAAW,EAAE,CAAC,CAAC,WAAW,GAAG,CAAC,CAAC,WAAW;KAC3C,CAAC,CAAC;AACL,CAAC,EAzCgB,kCAAkC,kDAAlC,kCAAkC,QAyClD"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { AutoBeAggregateEventBase, AutoBePhase, AutoBeProcessAggregate, AutoBeProcessAggregateCollection } from "@autobe/interface";
|
|
2
|
-
export declare namespace AutoBeProcessAggregateFactory {
|
|
3
|
-
const createAggregate: () => AutoBeProcessAggregate;
|
|
4
|
-
const createCollection: <Phase extends AutoBePhase | "all">() => AutoBeProcessAggregateCollection<Phase>;
|
|
5
|
-
const computeTotal: <Phase extends AutoBePhase | "all">(collection: AutoBeProcessAggregateCollection<Phase>) => AutoBeProcessAggregate;
|
|
6
|
-
const emplaceEvent: <Event extends AutoBeAggregateEventBase & {
|
|
7
|
-
type: string;
|
|
8
|
-
}>(collection: AutoBeProcessAggregateCollection, event: Event) => void;
|
|
9
|
-
const filterPhase: <Phase extends AutoBePhase>(collection: AutoBeProcessAggregateCollection, phase: Phase) => AutoBeProcessAggregateCollection<Phase>;
|
|
10
|
-
const reduce: (collections: AutoBeProcessAggregateCollection[]) => AutoBeProcessAggregateCollection;
|
|
11
|
-
const increment: (x: AutoBeProcessAggregateCollection, y: AutoBeProcessAggregateCollection) => void;
|
|
12
|
-
const minus: (x: AutoBeProcessAggregateCollection, y: AutoBeProcessAggregateCollection) => AutoBeProcessAggregateCollection;
|
|
13
|
-
}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AutoBeProcessAggregateFactory = void 0;
|
|
4
|
-
const AutoBeTokenUsageComponent_1 = require("../context/AutoBeTokenUsageComponent");
|
|
5
|
-
const TokenUsageComputer_1 = require("../utils/TokenUsageComputer");
|
|
6
|
-
const AutoBeFunctionCallingMetricFactory_1 = require("./AutoBeFunctionCallingMetricFactory");
|
|
7
|
-
var AutoBeProcessAggregateFactory;
|
|
8
|
-
(function (AutoBeProcessAggregateFactory) {
|
|
9
|
-
AutoBeProcessAggregateFactory.createAggregate = () => ({
|
|
10
|
-
metric: AutoBeFunctionCallingMetricFactory_1.AutoBeFunctionCallingMetricFactory.create(),
|
|
11
|
-
tokenUsage: new AutoBeTokenUsageComponent_1.AutoBeTokenUsageComponent().toJSON(),
|
|
12
|
-
});
|
|
13
|
-
AutoBeProcessAggregateFactory.createCollection = () => ({
|
|
14
|
-
total: AutoBeProcessAggregateFactory.createAggregate(),
|
|
15
|
-
});
|
|
16
|
-
AutoBeProcessAggregateFactory.computeTotal = (collection) => {
|
|
17
|
-
const total = AutoBeProcessAggregateFactory.createAggregate();
|
|
18
|
-
for (const [key, value] of Object.entries(collection)) {
|
|
19
|
-
if (key === "total")
|
|
20
|
-
continue;
|
|
21
|
-
AutoBeFunctionCallingMetricFactory_1.AutoBeFunctionCallingMetricFactory.increment(total.metric, value.metric);
|
|
22
|
-
TokenUsageComputer_1.TokenUsageComputer.increment(total.tokenUsage, value.tokenUsage);
|
|
23
|
-
}
|
|
24
|
-
return total;
|
|
25
|
-
};
|
|
26
|
-
AutoBeProcessAggregateFactory.emplaceEvent = (collection, event) => {
|
|
27
|
-
var _a, _b;
|
|
28
|
-
var _c, _d;
|
|
29
|
-
(_a = (_c = collection)[_d = event.type]) !== null && _a !== void 0 ? _a : (_c[_d] = AutoBeProcessAggregateFactory.createAggregate());
|
|
30
|
-
(_b = collection.total) !== null && _b !== void 0 ? _b : (collection.total = AutoBeProcessAggregateFactory.computeTotal(collection));
|
|
31
|
-
const local = collection[event.type];
|
|
32
|
-
const total = collection.total;
|
|
33
|
-
AutoBeFunctionCallingMetricFactory_1.AutoBeFunctionCallingMetricFactory.increment(local.metric, event.metric);
|
|
34
|
-
AutoBeFunctionCallingMetricFactory_1.AutoBeFunctionCallingMetricFactory.increment(total.metric, event.metric);
|
|
35
|
-
TokenUsageComputer_1.TokenUsageComputer.increment(local.tokenUsage, event.tokenUsage);
|
|
36
|
-
TokenUsageComputer_1.TokenUsageComputer.increment(total.tokenUsage, event.tokenUsage);
|
|
37
|
-
};
|
|
38
|
-
AutoBeProcessAggregateFactory.filterPhase = (collection, phase) => {
|
|
39
|
-
const result = AutoBeProcessAggregateFactory.createCollection();
|
|
40
|
-
for (const [key, value] of Object.entries(collection)) {
|
|
41
|
-
if (key === "total")
|
|
42
|
-
continue;
|
|
43
|
-
else if (key.startsWith(phase) === false)
|
|
44
|
-
continue;
|
|
45
|
-
result[key] = value;
|
|
46
|
-
AutoBeFunctionCallingMetricFactory_1.AutoBeFunctionCallingMetricFactory.increment(result.total.metric, value.metric);
|
|
47
|
-
TokenUsageComputer_1.TokenUsageComputer.increment(result.total.tokenUsage, value.tokenUsage);
|
|
48
|
-
}
|
|
49
|
-
return result;
|
|
50
|
-
};
|
|
51
|
-
AutoBeProcessAggregateFactory.reduce = (collections) => {
|
|
52
|
-
var _a, _b;
|
|
53
|
-
var _c;
|
|
54
|
-
const result = AutoBeProcessAggregateFactory.createCollection();
|
|
55
|
-
for (const collection of collections) {
|
|
56
|
-
for (const [key, value] of Object.entries(collection)) {
|
|
57
|
-
if (key === "total")
|
|
58
|
-
continue;
|
|
59
|
-
(_a = (_c = result)[key]) !== null && _a !== void 0 ? _a : (_c[key] = AutoBeProcessAggregateFactory.createAggregate());
|
|
60
|
-
const local = result[key];
|
|
61
|
-
AutoBeFunctionCallingMetricFactory_1.AutoBeFunctionCallingMetricFactory.increment(local.metric, value.metric);
|
|
62
|
-
TokenUsageComputer_1.TokenUsageComputer.increment(local.tokenUsage, value.tokenUsage);
|
|
63
|
-
AutoBeFunctionCallingMetricFactory_1.AutoBeFunctionCallingMetricFactory.increment(result.total.metric, value.metric);
|
|
64
|
-
TokenUsageComputer_1.TokenUsageComputer.increment(result.total.tokenUsage, value.tokenUsage);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
(_b = result.total) !== null && _b !== void 0 ? _b : (result.total = AutoBeProcessAggregateFactory.createAggregate());
|
|
68
|
-
Object.assign(result.total, AutoBeProcessAggregateFactory.computeTotal(result));
|
|
69
|
-
return result;
|
|
70
|
-
};
|
|
71
|
-
AutoBeProcessAggregateFactory.increment = (x, y) => {
|
|
72
|
-
var _a, _b;
|
|
73
|
-
var _c;
|
|
74
|
-
for (const [key, value] of Object.entries(y)) {
|
|
75
|
-
if (key === "total")
|
|
76
|
-
continue;
|
|
77
|
-
(_a = (_c = x)[key]) !== null && _a !== void 0 ? _a : (_c[key] = AutoBeProcessAggregateFactory.createAggregate());
|
|
78
|
-
const local = x[key];
|
|
79
|
-
AutoBeFunctionCallingMetricFactory_1.AutoBeFunctionCallingMetricFactory.increment(local.metric, value.metric);
|
|
80
|
-
}
|
|
81
|
-
(_b = x.total) !== null && _b !== void 0 ? _b : (x.total = AutoBeProcessAggregateFactory.createAggregate());
|
|
82
|
-
Object.assign(x.total, AutoBeProcessAggregateFactory.computeTotal(x));
|
|
83
|
-
};
|
|
84
|
-
AutoBeProcessAggregateFactory.minus = (x, y) => {
|
|
85
|
-
var _a, _b;
|
|
86
|
-
var _c;
|
|
87
|
-
const result = JSON.parse(JSON.stringify(x));
|
|
88
|
-
for (const [key, value] of Object.entries(y)) {
|
|
89
|
-
if (key === "total")
|
|
90
|
-
continue;
|
|
91
|
-
(_a = (_c = result)[key]) !== null && _a !== void 0 ? _a : (_c[key] = AutoBeProcessAggregateFactory.createAggregate());
|
|
92
|
-
const local = result[key];
|
|
93
|
-
AutoBeFunctionCallingMetricFactory_1.AutoBeFunctionCallingMetricFactory.minus(local.metric, value.metric);
|
|
94
|
-
}
|
|
95
|
-
(_b = result.total) !== null && _b !== void 0 ? _b : (result.total = AutoBeProcessAggregateFactory.createAggregate());
|
|
96
|
-
Object.assign(result.total, AutoBeProcessAggregateFactory.computeTotal(result));
|
|
97
|
-
return result;
|
|
98
|
-
};
|
|
99
|
-
})(AutoBeProcessAggregateFactory || (exports.AutoBeProcessAggregateFactory = AutoBeProcessAggregateFactory = {}));
|
|
100
|
-
//# sourceMappingURL=AutoBeProcessAggregateFactory.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AutoBeProcessAggregateFactory.js","sourceRoot":"","sources":["../../src/factory/AutoBeProcessAggregateFactory.ts"],"names":[],"mappings":";;;AAOA,oFAAiF;AACjF,oEAAiE;AACjE,6FAA0F;AAE1F,IAAiB,6BAA6B,CAiI7C;AAjID,WAAiB,6BAA6B;IAC/B,6CAAe,GAAG,GAA2B,EAAE,CAAC,CAAC;QAC5D,MAAM,EAAE,uEAAkC,CAAC,MAAM,EAAE;QACnD,UAAU,EAAE,IAAI,qDAAyB,EAAE,CAAC,MAAM,EAAE;KACrD,CAAC,CAAC;IAEU,8CAAgB,GAAG,GAEa,EAAE,CAC7C,CAAC;QACC,KAAK,EAAE,8BAAA,eAAe,EAAE;KACzB,CAAuF,CAAC;IAE9E,0CAAY,GAAG,CAC1B,UAAmD,EAC3B,EAAE;QAC1B,MAAM,KAAK,GAA2B,8BAAA,eAAe,EAAE,CAAC;QACxD,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAA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AE,EAAC;YAC3C,MAAM,KAAK,GAA4B,MAAc,CACnD,GAAG,CACsB,CAAC;YAC5B,uEAAkC,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;QACvE,CAAC;QACD,MAAA,MAAM,CAAC,KAAK,oCAAZ,MAAM,CAAC,KAAK,GAAK,8BAAA,eAAe,EAAE,EAAC;QACnC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,8BAAA,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC;QAClD,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC,EAjIgB,6BAA6B,6CAA7B,6BAA6B,QAiI7C"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { IAutoBeTokenUsageJson } from "@autobe/interface";
|
|
2
|
-
export declare namespace TokenUsageComputer {
|
|
3
|
-
const plus: (x: IAutoBeTokenUsageJson.IComponent, y: IAutoBeTokenUsageJson.IComponent) => IAutoBeTokenUsageJson.IComponent;
|
|
4
|
-
const increment: (x: IAutoBeTokenUsageJson.IComponent, y: IAutoBeTokenUsageJson.IComponent) => void;
|
|
5
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TokenUsageComputer = void 0;
|
|
4
|
-
var TokenUsageComputer;
|
|
5
|
-
(function (TokenUsageComputer) {
|
|
6
|
-
TokenUsageComputer.plus = (x, y) => ({
|
|
7
|
-
total: x.total + y.total,
|
|
8
|
-
input: {
|
|
9
|
-
total: x.input.total + y.input.total,
|
|
10
|
-
cached: x.input.cached + y.input.cached,
|
|
11
|
-
},
|
|
12
|
-
output: {
|
|
13
|
-
total: x.output.total + y.output.total,
|
|
14
|
-
reasoning: x.output.reasoning + y.output.reasoning,
|
|
15
|
-
accepted_prediction: x.output.accepted_prediction + y.output.accepted_prediction,
|
|
16
|
-
rejected_prediction: x.output.rejected_prediction + y.output.rejected_prediction,
|
|
17
|
-
},
|
|
18
|
-
});
|
|
19
|
-
TokenUsageComputer.increment = (x, y) => {
|
|
20
|
-
x.total += y.total;
|
|
21
|
-
x.input.total += y.input.total;
|
|
22
|
-
x.input.cached += y.input.cached;
|
|
23
|
-
x.output.total += y.output.total;
|
|
24
|
-
x.output.reasoning += y.output.reasoning;
|
|
25
|
-
x.output.accepted_prediction += y.output.accepted_prediction;
|
|
26
|
-
x.output.rejected_prediction += y.output.rejected_prediction;
|
|
27
|
-
};
|
|
28
|
-
})(TokenUsageComputer || (exports.TokenUsageComputer = TokenUsageComputer = {}));
|
|
29
|
-
//# sourceMappingURL=TokenUsageComputer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TokenUsageComputer.js","sourceRoot":"","sources":["../../src/utils/TokenUsageComputer.ts"],"names":[],"mappings":";;;AAEA,IAAiB,kBAAkB,CAgClC;AAhCD,WAAiB,kBAAkB;IACpB,uBAAI,GAAG,CAClB,CAAmC,EACnC,CAAmC,EACD,EAAE,CAAC,CAAC;QACtC,KAAK,EAAE,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK;QACxB,KAAK,EAAE;YACL,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,KAAK;YACpC,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,MAAM;SACxC;QACD,MAAM,EAAE;YACN,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK;YACtC,SAAS,EAAE,CAAC,CAAC,MAAM,CAAC,SAAS,GAAG,CAAC,CAAC,MAAM,CAAC,SAAS;YAClD,mBAAmB,EACjB,CAAC,CAAC,MAAM,CAAC,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC,mBAAmB;YAC7D,mBAAmB,EACjB,CAAC,CAAC,MAAM,CAAC,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC,mBAAmB;SAC9D;KACF,CAAC,CAAC;IAEU,4BAAS,GAAG,CACvB,CAAmC,EACnC,CAAmC,EAC7B,EAAE;QACR,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,KAAK,CAAC;QACnB,CAAC,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC;QAC/B,CAAC,CAAC,KAAK,CAAC,MAAM,IAAI,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC;QACjC,CAAC,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;QACjC,CAAC,CAAC,MAAM,CAAC,SAAS,IAAI,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC;QACzC,CAAC,CAAC,MAAM,CAAC,mBAAmB,IAAI,CAAC,CAAC,MAAM,CAAC,mBAAmB,CAAC;QAC7D,CAAC,CAAC,MAAM,CAAC,mBAAmB,IAAI,CAAC,CAAC,MAAM,CAAC,mBAAmB,CAAC;IAC/D,CAAC,CAAC;AACJ,CAAC,EAhCgB,kBAAkB,kCAAlB,kBAAkB,QAgClC"}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { AutoBeFunctionCallingMetric } from "@autobe/interface";
|
|
2
|
-
|
|
3
|
-
export namespace AutoBeFunctionCallingMetricFactory {
|
|
4
|
-
export const create = (): AutoBeFunctionCallingMetric => ({
|
|
5
|
-
attempt: 0,
|
|
6
|
-
success: 0,
|
|
7
|
-
consent: 0,
|
|
8
|
-
validationFailure: 0,
|
|
9
|
-
invalidJson: 0,
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
export const increment = (
|
|
13
|
-
x: AutoBeFunctionCallingMetric,
|
|
14
|
-
y: AutoBeFunctionCallingMetric,
|
|
15
|
-
): void => {
|
|
16
|
-
x.attempt += y.attempt;
|
|
17
|
-
x.success += y.success;
|
|
18
|
-
x.consent += y.consent;
|
|
19
|
-
x.validationFailure += y.validationFailure;
|
|
20
|
-
x.invalidJson += y.invalidJson;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export const plus = (
|
|
24
|
-
x: AutoBeFunctionCallingMetric,
|
|
25
|
-
y: AutoBeFunctionCallingMetric,
|
|
26
|
-
): AutoBeFunctionCallingMetric => ({
|
|
27
|
-
attempt: x.attempt + y.attempt,
|
|
28
|
-
success: x.success + y.success,
|
|
29
|
-
consent: x.consent + y.consent,
|
|
30
|
-
validationFailure: x.validationFailure + y.validationFailure,
|
|
31
|
-
invalidJson: x.invalidJson + y.invalidJson,
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
export const minus = (
|
|
35
|
-
x: AutoBeFunctionCallingMetric,
|
|
36
|
-
y: AutoBeFunctionCallingMetric,
|
|
37
|
-
): AutoBeFunctionCallingMetric => ({
|
|
38
|
-
attempt: x.attempt - y.attempt,
|
|
39
|
-
success: x.success - y.success,
|
|
40
|
-
consent: x.consent - y.consent,
|
|
41
|
-
validationFailure: x.validationFailure - y.validationFailure,
|
|
42
|
-
invalidJson: x.invalidJson - y.invalidJson,
|
|
43
|
-
});
|
|
44
|
-
}
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AutoBeAggregateEventBase,
|
|
3
|
-
AutoBePhase,
|
|
4
|
-
AutoBeProcessAggregate,
|
|
5
|
-
AutoBeProcessAggregateCollection,
|
|
6
|
-
} from "@autobe/interface";
|
|
7
|
-
|
|
8
|
-
import { AutoBeTokenUsageComponent } from "../context/AutoBeTokenUsageComponent";
|
|
9
|
-
import { TokenUsageComputer } from "../utils/TokenUsageComputer";
|
|
10
|
-
import { AutoBeFunctionCallingMetricFactory } from "./AutoBeFunctionCallingMetricFactory";
|
|
11
|
-
|
|
12
|
-
export namespace AutoBeProcessAggregateFactory {
|
|
13
|
-
export const createAggregate = (): AutoBeProcessAggregate => ({
|
|
14
|
-
metric: AutoBeFunctionCallingMetricFactory.create(),
|
|
15
|
-
tokenUsage: new AutoBeTokenUsageComponent().toJSON(),
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
export const createCollection = <
|
|
19
|
-
Phase extends AutoBePhase | "all",
|
|
20
|
-
>(): AutoBeProcessAggregateCollection<Phase> =>
|
|
21
|
-
({
|
|
22
|
-
total: createAggregate(),
|
|
23
|
-
}) satisfies AutoBeProcessAggregateCollection as AutoBeProcessAggregateCollection<Phase>;
|
|
24
|
-
|
|
25
|
-
export const computeTotal = <Phase extends AutoBePhase | "all">(
|
|
26
|
-
collection: AutoBeProcessAggregateCollection<Phase>,
|
|
27
|
-
): AutoBeProcessAggregate => {
|
|
28
|
-
const total: AutoBeProcessAggregate = createAggregate();
|
|
29
|
-
for (const [key, value] of Object.entries(collection)) {
|
|
30
|
-
if (key === "total") continue;
|
|
31
|
-
AutoBeFunctionCallingMetricFactory.increment(total.metric, value.metric);
|
|
32
|
-
TokenUsageComputer.increment(total.tokenUsage, value.tokenUsage);
|
|
33
|
-
}
|
|
34
|
-
return total;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export const emplaceEvent = <
|
|
38
|
-
Event extends AutoBeAggregateEventBase & {
|
|
39
|
-
type: string;
|
|
40
|
-
},
|
|
41
|
-
>(
|
|
42
|
-
collection: AutoBeProcessAggregateCollection,
|
|
43
|
-
event: Event,
|
|
44
|
-
): void => {
|
|
45
|
-
(collection as any)[event.type] ??= createAggregate();
|
|
46
|
-
collection.total ??= computeTotal(collection);
|
|
47
|
-
|
|
48
|
-
const local: AutoBeProcessAggregate = (collection as any)[
|
|
49
|
-
event.type
|
|
50
|
-
] as AutoBeProcessAggregate;
|
|
51
|
-
const total: AutoBeProcessAggregate = collection.total;
|
|
52
|
-
|
|
53
|
-
AutoBeFunctionCallingMetricFactory.increment(local.metric, event.metric);
|
|
54
|
-
AutoBeFunctionCallingMetricFactory.increment(total.metric, event.metric);
|
|
55
|
-
TokenUsageComputer.increment(local.tokenUsage, event.tokenUsage);
|
|
56
|
-
TokenUsageComputer.increment(total.tokenUsage, event.tokenUsage);
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
export const filterPhase = <Phase extends AutoBePhase>(
|
|
60
|
-
collection: AutoBeProcessAggregateCollection,
|
|
61
|
-
phase: Phase,
|
|
62
|
-
): AutoBeProcessAggregateCollection<Phase> => {
|
|
63
|
-
const result: AutoBeProcessAggregateCollection<Phase> = createCollection();
|
|
64
|
-
for (const [key, value] of Object.entries(collection)) {
|
|
65
|
-
if (key === "total") continue;
|
|
66
|
-
else if (key.startsWith(phase) === false) continue;
|
|
67
|
-
|
|
68
|
-
(result as any)[key] = value;
|
|
69
|
-
AutoBeFunctionCallingMetricFactory.increment(
|
|
70
|
-
result.total.metric,
|
|
71
|
-
value.metric,
|
|
72
|
-
);
|
|
73
|
-
TokenUsageComputer.increment(result.total.tokenUsage, value.tokenUsage);
|
|
74
|
-
}
|
|
75
|
-
return result;
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
export const reduce = (
|
|
79
|
-
collections: AutoBeProcessAggregateCollection[],
|
|
80
|
-
): AutoBeProcessAggregateCollection => {
|
|
81
|
-
const result: AutoBeProcessAggregateCollection = createCollection();
|
|
82
|
-
for (const collection of collections) {
|
|
83
|
-
for (const [key, value] of Object.entries(collection)) {
|
|
84
|
-
if (key === "total") continue;
|
|
85
|
-
(result as any)[key] ??= createAggregate();
|
|
86
|
-
const local: AutoBeProcessAggregate = (result as any)[
|
|
87
|
-
key
|
|
88
|
-
] as AutoBeProcessAggregate;
|
|
89
|
-
AutoBeFunctionCallingMetricFactory.increment(
|
|
90
|
-
local.metric,
|
|
91
|
-
value.metric,
|
|
92
|
-
);
|
|
93
|
-
TokenUsageComputer.increment(local.tokenUsage, value.tokenUsage);
|
|
94
|
-
AutoBeFunctionCallingMetricFactory.increment(
|
|
95
|
-
result.total.metric,
|
|
96
|
-
value.metric,
|
|
97
|
-
);
|
|
98
|
-
TokenUsageComputer.increment(result.total.tokenUsage, value.tokenUsage);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
result.total ??= createAggregate();
|
|
102
|
-
Object.assign(result.total, computeTotal(result));
|
|
103
|
-
return result;
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
export const increment = (
|
|
107
|
-
x: AutoBeProcessAggregateCollection,
|
|
108
|
-
y: AutoBeProcessAggregateCollection,
|
|
109
|
-
): void => {
|
|
110
|
-
for (const [key, value] of Object.entries(y)) {
|
|
111
|
-
if (key === "total") continue;
|
|
112
|
-
(x as any)[key] ??= createAggregate();
|
|
113
|
-
const local: AutoBeProcessAggregate = (x as any)[
|
|
114
|
-
key
|
|
115
|
-
] as AutoBeProcessAggregate;
|
|
116
|
-
AutoBeFunctionCallingMetricFactory.increment(local.metric, value.metric);
|
|
117
|
-
}
|
|
118
|
-
x.total ??= createAggregate();
|
|
119
|
-
Object.assign(x.total, computeTotal(x));
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
export const minus = (
|
|
123
|
-
x: AutoBeProcessAggregateCollection,
|
|
124
|
-
y: AutoBeProcessAggregateCollection,
|
|
125
|
-
): AutoBeProcessAggregateCollection => {
|
|
126
|
-
const result = JSON.parse(
|
|
127
|
-
JSON.stringify(x),
|
|
128
|
-
) as AutoBeProcessAggregateCollection;
|
|
129
|
-
for (const [key, value] of Object.entries(y)) {
|
|
130
|
-
if (key === "total") continue;
|
|
131
|
-
(result as any)[key] ??= createAggregate();
|
|
132
|
-
const local: AutoBeProcessAggregate = (result as any)[
|
|
133
|
-
key
|
|
134
|
-
] as AutoBeProcessAggregate;
|
|
135
|
-
AutoBeFunctionCallingMetricFactory.minus(local.metric, value.metric);
|
|
136
|
-
}
|
|
137
|
-
result.total ??= createAggregate();
|
|
138
|
-
Object.assign(result.total, computeTotal(result));
|
|
139
|
-
return result;
|
|
140
|
-
};
|
|
141
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { IAutoBeTokenUsageJson } from "@autobe/interface";
|
|
2
|
-
|
|
3
|
-
export namespace TokenUsageComputer {
|
|
4
|
-
export const plus = (
|
|
5
|
-
x: IAutoBeTokenUsageJson.IComponent,
|
|
6
|
-
y: IAutoBeTokenUsageJson.IComponent,
|
|
7
|
-
): IAutoBeTokenUsageJson.IComponent => ({
|
|
8
|
-
total: x.total + y.total,
|
|
9
|
-
input: {
|
|
10
|
-
total: x.input.total + y.input.total,
|
|
11
|
-
cached: x.input.cached + y.input.cached,
|
|
12
|
-
},
|
|
13
|
-
output: {
|
|
14
|
-
total: x.output.total + y.output.total,
|
|
15
|
-
reasoning: x.output.reasoning + y.output.reasoning,
|
|
16
|
-
accepted_prediction:
|
|
17
|
-
x.output.accepted_prediction + y.output.accepted_prediction,
|
|
18
|
-
rejected_prediction:
|
|
19
|
-
x.output.rejected_prediction + y.output.rejected_prediction,
|
|
20
|
-
},
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
export const increment = (
|
|
24
|
-
x: IAutoBeTokenUsageJson.IComponent,
|
|
25
|
-
y: IAutoBeTokenUsageJson.IComponent,
|
|
26
|
-
): void => {
|
|
27
|
-
x.total += y.total;
|
|
28
|
-
x.input.total += y.input.total;
|
|
29
|
-
x.input.cached += y.input.cached;
|
|
30
|
-
x.output.total += y.output.total;
|
|
31
|
-
x.output.reasoning += y.output.reasoning;
|
|
32
|
-
x.output.accepted_prediction += y.output.accepted_prediction;
|
|
33
|
-
x.output.rejected_prediction += y.output.rejected_prediction;
|
|
34
|
-
};
|
|
35
|
-
}
|