@autobe/agent 0.29.0 → 0.29.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.
@@ -25,7 +25,7 @@ const executeCachedBatch = (ctx, taskList, promptCacheKey) => __awaiter(void 0,
25
25
  .slice(1)
26
26
  .map((task, index) => new tstl_1.Pair(task, index));
27
27
  const tail = [];
28
- yield Promise.all(new Array(semaphore).map(() => __awaiter(void 0, void 0, void 0, function* () {
28
+ yield Promise.all(new Array(semaphore).fill(0).map(() => __awaiter(void 0, void 0, void 0, function* () {
29
29
  while (remained.length !== 0) {
30
30
  const batch = remained.splice(0, 1)[0];
31
31
  const result = yield batch.first(promptCacheKey);
@@ -1 +1 @@
1
- {"version":3,"file":"executeCachedBatch.js","sourceRoot":"","sources":["../../src/utils/executeCachedBatch.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,+BAAuC;AACvC,+BAA0B;AAKnB,MAAM,kBAAkB,GAAG,CAChC,GAAyB,EACzB,QAAmB,EACnB,cAAuB,EACT,EAAE;;IAChB,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAErC,cAAc,aAAd,cAAc,cAAd,cAAc,IAAd,cAAc,GAAK,IAAA,SAAE,GAAE,EAAC;IACxB,MAAM,KAAK,GAAM,MAAM,QAAQ,CAAC,CAAC,CAAE,CAAC,cAAc,CAAC,CAAC;IACpD,MAAM,SAAS,GACb,GAAG,CAAC,MAAM,CAAC,SAAS,IAAI,GAAG,CAAC,MAAM,CAAC,SAAS,YAAY,gBAAS;QAC/D,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE;QAC5B,CAAC,CAAC,CAAC,MAAA,GAAG,CAAC,MAAM,CAAC,SAAS,0EAAkC,CAAC,CAAC;IAE/D,MAAM,QAAQ,GAAiC,QAAQ;SACpD,KAAK,CAAC,CAAC,CAAC;SACR,GAAG,CAAC,CAAC,IAAI,EAAE,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AC,CAAC,KAAK,CAAC;KAChE,CAAC;AACJ,CAAC,CAAA,CAAC;AA/BW,QAAA,kBAAkB,sBA+B7B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autobe/agent",
3
- "version": "0.29.0",
3
+ "version": "0.29.1",
4
4
  "description": "AI backend server code generator",
5
5
  "main": "lib/index.js",
6
6
  "author": "Wrtn Technologies",
@@ -28,8 +28,8 @@
28
28
  "tstl": "^3.0.0",
29
29
  "typia": "^10.0.2",
30
30
  "uuid": "^11.1.0",
31
- "@autobe/interface": "^0.29.0",
32
- "@autobe/utils": "^0.29.0"
31
+ "@autobe/interface": "^0.29.1",
32
+ "@autobe/utils": "^0.29.1"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@rollup/plugin-json": "^6.1.0",
@@ -42,8 +42,8 @@
42
42
  "ts-node": "^10.9.2",
43
43
  "ts-patch": "^3.3.0",
44
44
  "typescript": "~5.9.3",
45
- "@autobe/compiler": "^0.29.0",
46
- "@autobe/filesystem": "^0.29.0"
45
+ "@autobe/filesystem": "^0.29.1",
46
+ "@autobe/compiler": "^0.29.1"
47
47
  },
48
48
  "keywords": [
49
49
  "ai",
@@ -15,6 +15,7 @@ import {
15
15
  IAutoBeAgent,
16
16
  IAutoBeCompilerListener,
17
17
  } from "@autobe/interface";
18
+ import { AutoBeProcessAggregateFactory } from "@autobe/utils";
18
19
  import { ILlmSchema } from "@samchon/openapi";
19
20
  import { Semaphore, Singleton } from "tstl";
20
21
  import { v7 } from "uuid";
@@ -24,7 +25,6 @@ import { AutoBeConfigConstant } from "./constants/AutoBeConfigConstant";
24
25
  import { AutoBeContext } from "./context/AutoBeContext";
25
26
  import { AutoBeState } from "./context/AutoBeState";
26
27
  import { AutoBeTokenUsage } from "./context/AutoBeTokenUsage";
27
- import { AutoBeProcessAggregateFactory } from "./factory/AutoBeProcessAggregateFactory";
28
28
  import { createAgenticaHistory } from "./factory/createAgenticaHistory";
29
29
  import { createAutoBeContext } from "./factory/createAutoBeContext";
30
30
  import { createAutoBeState } from "./factory/createAutoBeState";
@@ -26,7 +26,11 @@ import {
26
26
  IAutoBeGetFilesOptions,
27
27
  IAutoBeTokenUsageJson,
28
28
  } from "@autobe/interface";
29
- import { StringUtil } from "@autobe/utils";
29
+ import {
30
+ AutoBeProcessAggregateFactory,
31
+ StringUtil,
32
+ TokenUsageComputer,
33
+ } from "@autobe/utils";
30
34
  import { ILlmSchema } from "@samchon/openapi";
31
35
  import { Semaphore } from "tstl";
32
36
  import typia from "typia";
@@ -42,8 +46,6 @@ import { IAutoBeConfig } from "../structures/IAutoBeConfig";
42
46
  import { IAutoBeVendor } from "../structures/IAutoBeVendor";
43
47
  import { AutoBeTimeoutError } from "../utils/AutoBeTimeoutError";
44
48
  import { TimedConversation } from "../utils/TimedConversation";
45
- import { TokenUsageComputer } from "../utils/TokenUsageComputer";
46
- import { AutoBeProcessAggregateFactory } from "./AutoBeProcessAggregateFactory";
47
49
  import { consentFunctionCall } from "./consentFunctionCall";
48
50
  import { getCommonPrompt } from "./getCommonPrompt";
49
51
  import { getCriticalCompiler } from "./getCriticalCompiler";
@@ -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,EAA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W;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,EAAE,CAAC;YACtD,IAAI,GAAG,KAAK,OAAO;gBAAE,SAAS;YAC9B,uEAAkC,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;YACzE,uCAAkB,CAAC,SAAS,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;QACnE,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC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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,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AAC,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
- }