@autobe/utils 0.28.1 → 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.
- package/lib/ArrayUtil.d.ts +4 -0
- package/lib/ArrayUtil.js +38 -0
- package/lib/ArrayUtil.js.map +1 -0
- package/lib/aggregate/AutoBeFunctionCallingMetricFactory.d.ts +7 -0
- package/lib/aggregate/AutoBeFunctionCallingMetricFactory.js +35 -0
- package/lib/aggregate/AutoBeFunctionCallingMetricFactory.js.map +1 -0
- package/lib/aggregate/AutoBeProcessAggregateFactory.d.ts +13 -0
- package/lib/aggregate/AutoBeProcessAggregateFactory.js +111 -0
- package/lib/aggregate/AutoBeProcessAggregateFactory.js.map +1 -0
- package/lib/aggregate/TokenUsageComputer.d.ts +6 -0
- package/lib/aggregate/TokenUsageComputer.js +42 -0
- package/lib/aggregate/TokenUsageComputer.js.map +1 -0
- package/lib/aggregate/index.d.ts +3 -0
- package/lib/aggregate/index.js +20 -0
- package/lib/aggregate/index.js.map +1 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.js +3 -0
- package/lib/index.js.map +1 -1
- package/lib/prisma/index.d.ts +1 -0
- package/lib/prisma/index.js +18 -0
- package/lib/prisma/index.js.map +1 -0
- package/lib/prisma/writePrismaApplication.d.ts +5 -0
- package/lib/prisma/writePrismaApplication.js +342 -0
- package/lib/prisma/writePrismaApplication.js.map +1 -0
- package/package.json +3 -2
- package/src/ArrayUtil.ts +21 -0
- package/src/aggregate/AutoBeFunctionCallingMetricFactory.ts +44 -0
- package/src/aggregate/AutoBeProcessAggregateFactory.ts +152 -0
- package/src/aggregate/TokenUsageComputer.ts +49 -0
- package/src/aggregate/index.ts +3 -0
- package/src/index.ts +4 -0
- package/src/prisma/index.ts +1 -0
- package/src/prisma/writePrismaApplication.ts +439 -0
package/lib/ArrayUtil.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ArrayUtil = void 0;
|
|
13
|
+
var ArrayUtil;
|
|
14
|
+
(function (ArrayUtil) {
|
|
15
|
+
function asyncMap(array, callback) {
|
|
16
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
const result = new Array(array.length);
|
|
18
|
+
for (let i = 0; i < array.length; i++)
|
|
19
|
+
result[i] = yield callback(array[i], i, array);
|
|
20
|
+
return result;
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
ArrayUtil.asyncMap = asyncMap;
|
|
24
|
+
function paddle(contents) {
|
|
25
|
+
const output = [];
|
|
26
|
+
contents.forEach((c) => {
|
|
27
|
+
if (c.length === 0)
|
|
28
|
+
return;
|
|
29
|
+
else if (output.length === 0)
|
|
30
|
+
output.push(...c);
|
|
31
|
+
else
|
|
32
|
+
output.push("", ...c);
|
|
33
|
+
});
|
|
34
|
+
return output;
|
|
35
|
+
}
|
|
36
|
+
ArrayUtil.paddle = paddle;
|
|
37
|
+
})(ArrayUtil || (exports.ArrayUtil = ArrayUtil = {}));
|
|
38
|
+
//# sourceMappingURL=ArrayUtil.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ArrayUtil.js","sourceRoot":"","sources":["../src/ArrayUtil.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,IAAiB,SAAS,CAoBzB;AApBD,WAAiB,SAAS;IACxB,SAAsB,QAAQ,CAC5B,KAAU,EACV,QAA6D;;YAE7D,MAAM,MAAM,GAAQ,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YAC5C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE;gBACnC,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;YACjD,OAAO,MAAM,CAAC;QAChB,CAAC;KAAA;IARqB,kBAAQ,WAQ7B,CAAA;IAED,SAAgB,MAAM,CAAC,QAAoB;QACzC,MAAM,MAAM,GAAa,EAAE,CAAC;QAC5B,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;YACrB,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC;gBAAE,OAAO;iBACtB,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;gBAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;;gBAC3C,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC;QAC7B,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC;IARe,gBAAM,SAQrB,CAAA;AACH,CAAC,EApBgB,SAAS,yBAAT,SAAS,QAoBzB"}
|
|
@@ -0,0 +1,7 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AutoBeFunctionCallingMetricFactory.js","sourceRoot":"","sources":["../../src/aggregate/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"}
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AutoBeProcessAggregateFactory = void 0;
|
|
4
|
+
const AutoBeFunctionCallingMetricFactory_1 = require("./AutoBeFunctionCallingMetricFactory");
|
|
5
|
+
const TokenUsageComputer_1 = require("./TokenUsageComputer");
|
|
6
|
+
var AutoBeProcessAggregateFactory;
|
|
7
|
+
(function (AutoBeProcessAggregateFactory) {
|
|
8
|
+
AutoBeProcessAggregateFactory.createAggregate = () => ({
|
|
9
|
+
metric: AutoBeFunctionCallingMetricFactory_1.AutoBeFunctionCallingMetricFactory.create(),
|
|
10
|
+
tokenUsage: {
|
|
11
|
+
total: 0,
|
|
12
|
+
input: {
|
|
13
|
+
total: 0,
|
|
14
|
+
cached: 0,
|
|
15
|
+
},
|
|
16
|
+
output: {
|
|
17
|
+
total: 0,
|
|
18
|
+
reasoning: 0,
|
|
19
|
+
accepted_prediction: 0,
|
|
20
|
+
rejected_prediction: 0,
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
AutoBeProcessAggregateFactory.createCollection = () => ({
|
|
25
|
+
total: AutoBeProcessAggregateFactory.createAggregate(),
|
|
26
|
+
});
|
|
27
|
+
AutoBeProcessAggregateFactory.computeTotal = (collection) => {
|
|
28
|
+
const total = AutoBeProcessAggregateFactory.createAggregate();
|
|
29
|
+
for (const [key, value] of Object.entries(collection)) {
|
|
30
|
+
if (key === "total")
|
|
31
|
+
continue;
|
|
32
|
+
AutoBeFunctionCallingMetricFactory_1.AutoBeFunctionCallingMetricFactory.increment(total.metric, value.metric);
|
|
33
|
+
TokenUsageComputer_1.TokenUsageComputer.increment(total.tokenUsage, value.tokenUsage);
|
|
34
|
+
}
|
|
35
|
+
return total;
|
|
36
|
+
};
|
|
37
|
+
AutoBeProcessAggregateFactory.emplaceEvent = (collection, event) => {
|
|
38
|
+
var _a, _b;
|
|
39
|
+
var _c, _d;
|
|
40
|
+
(_a = (_c = collection)[_d = event.type]) !== null && _a !== void 0 ? _a : (_c[_d] = AutoBeProcessAggregateFactory.createAggregate());
|
|
41
|
+
(_b = collection.total) !== null && _b !== void 0 ? _b : (collection.total = AutoBeProcessAggregateFactory.computeTotal(collection));
|
|
42
|
+
const local = collection[event.type];
|
|
43
|
+
const total = collection.total;
|
|
44
|
+
AutoBeFunctionCallingMetricFactory_1.AutoBeFunctionCallingMetricFactory.increment(local.metric, event.metric);
|
|
45
|
+
AutoBeFunctionCallingMetricFactory_1.AutoBeFunctionCallingMetricFactory.increment(total.metric, event.metric);
|
|
46
|
+
TokenUsageComputer_1.TokenUsageComputer.increment(local.tokenUsage, event.tokenUsage);
|
|
47
|
+
TokenUsageComputer_1.TokenUsageComputer.increment(total.tokenUsage, event.tokenUsage);
|
|
48
|
+
};
|
|
49
|
+
AutoBeProcessAggregateFactory.filterPhase = (collection, phase) => {
|
|
50
|
+
const result = AutoBeProcessAggregateFactory.createCollection();
|
|
51
|
+
for (const [key, value] of Object.entries(collection)) {
|
|
52
|
+
if (key === "total")
|
|
53
|
+
continue;
|
|
54
|
+
else if (key.startsWith(phase) === false)
|
|
55
|
+
continue;
|
|
56
|
+
result[key] = value;
|
|
57
|
+
AutoBeFunctionCallingMetricFactory_1.AutoBeFunctionCallingMetricFactory.increment(result.total.metric, value.metric);
|
|
58
|
+
TokenUsageComputer_1.TokenUsageComputer.increment(result.total.tokenUsage, value.tokenUsage);
|
|
59
|
+
}
|
|
60
|
+
return result;
|
|
61
|
+
};
|
|
62
|
+
AutoBeProcessAggregateFactory.reduce = (collections) => {
|
|
63
|
+
var _a, _b;
|
|
64
|
+
var _c;
|
|
65
|
+
const result = AutoBeProcessAggregateFactory.createCollection();
|
|
66
|
+
for (const collection of collections) {
|
|
67
|
+
for (const [key, value] of Object.entries(collection)) {
|
|
68
|
+
if (key === "total")
|
|
69
|
+
continue;
|
|
70
|
+
(_a = (_c = result)[key]) !== null && _a !== void 0 ? _a : (_c[key] = AutoBeProcessAggregateFactory.createAggregate());
|
|
71
|
+
const local = result[key];
|
|
72
|
+
AutoBeFunctionCallingMetricFactory_1.AutoBeFunctionCallingMetricFactory.increment(local.metric, value.metric);
|
|
73
|
+
TokenUsageComputer_1.TokenUsageComputer.increment(local.tokenUsage, value.tokenUsage);
|
|
74
|
+
AutoBeFunctionCallingMetricFactory_1.AutoBeFunctionCallingMetricFactory.increment(result.total.metric, value.metric);
|
|
75
|
+
TokenUsageComputer_1.TokenUsageComputer.increment(result.total.tokenUsage, value.tokenUsage);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
(_b = result.total) !== null && _b !== void 0 ? _b : (result.total = AutoBeProcessAggregateFactory.createAggregate());
|
|
79
|
+
Object.assign(result.total, AutoBeProcessAggregateFactory.computeTotal(result));
|
|
80
|
+
return result;
|
|
81
|
+
};
|
|
82
|
+
AutoBeProcessAggregateFactory.increment = (x, y) => {
|
|
83
|
+
var _a, _b;
|
|
84
|
+
var _c;
|
|
85
|
+
for (const [key, value] of Object.entries(y)) {
|
|
86
|
+
if (key === "total")
|
|
87
|
+
continue;
|
|
88
|
+
(_a = (_c = x)[key]) !== null && _a !== void 0 ? _a : (_c[key] = AutoBeProcessAggregateFactory.createAggregate());
|
|
89
|
+
const local = x[key];
|
|
90
|
+
AutoBeFunctionCallingMetricFactory_1.AutoBeFunctionCallingMetricFactory.increment(local.metric, value.metric);
|
|
91
|
+
}
|
|
92
|
+
(_b = x.total) !== null && _b !== void 0 ? _b : (x.total = AutoBeProcessAggregateFactory.createAggregate());
|
|
93
|
+
Object.assign(x.total, AutoBeProcessAggregateFactory.computeTotal(x));
|
|
94
|
+
};
|
|
95
|
+
AutoBeProcessAggregateFactory.minus = (x, y) => {
|
|
96
|
+
var _a, _b;
|
|
97
|
+
var _c;
|
|
98
|
+
const result = JSON.parse(JSON.stringify(x));
|
|
99
|
+
for (const [key, value] of Object.entries(y)) {
|
|
100
|
+
if (key === "total")
|
|
101
|
+
continue;
|
|
102
|
+
(_a = (_c = result)[key]) !== null && _a !== void 0 ? _a : (_c[key] = AutoBeProcessAggregateFactory.createAggregate());
|
|
103
|
+
const local = result[key];
|
|
104
|
+
AutoBeFunctionCallingMetricFactory_1.AutoBeFunctionCallingMetricFactory.minus(local.metric, value.metric);
|
|
105
|
+
}
|
|
106
|
+
(_b = result.total) !== null && _b !== void 0 ? _b : (result.total = AutoBeProcessAggregateFactory.createAggregate());
|
|
107
|
+
Object.assign(result.total, AutoBeProcessAggregateFactory.computeTotal(result));
|
|
108
|
+
return result;
|
|
109
|
+
};
|
|
110
|
+
})(AutoBeProcessAggregateFactory || (exports.AutoBeProcessAggregateFactory = AutoBeProcessAggregateFactory = {}));
|
|
111
|
+
//# sourceMappingURL=AutoBeProcessAggregateFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AutoBeProcessAggregateFactory.js","sourceRoot":"","sources":["../../src/aggregate/AutoBeProcessAggregateFactory.ts"],"names":[],"mappings":";;;AAOA,6FAA0F;AAC1F,6DAA0D;AAE1D,IAAiB,6BAA6B,CA6I7C;AA7ID,WAAiB,6BAA6B;IAC/B,6CAAe,GAAG,GAA2B,EAAE,CAAC,CAAC;QAC5D,MAAM,EAAE,uEAAkC,CAAC,MAAM,EAAE;QACnD,UAAU,EAAE;YACV,KAAK,EAAE,CAAC;YACR,KAAK,EAAE;gBACL,KAAK,EAAE,CAAC;gBACR,MAAM,EAAE,CAAC;aACV;YACD,MAAM,EAAE;gBACN,KAAK,EAAE,CAAC;gBACR,SAAS,EAAE,CAAC;gBACZ,mBAAmB,EAAE,CAAC;gBACtB,mBAAmB,EAAE,CAAC;aACvB;SACF;KACF,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,E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,IAAI,GAAG,KAAK,OAAO;gBAAE,SAAS;YAC9B,YAAC,MAAc,EAAC,GAAG,wCAAH,GAAG,IAAM,8BAAA,eAAe,EAAE,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,EA7IgB,6BAA6B,6CAA7B,6BAA6B,QA6I7C"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { IAutoBeTokenUsageJson } from "@autobe/interface";
|
|
2
|
+
export declare namespace TokenUsageComputer {
|
|
3
|
+
const zero: () => IAutoBeTokenUsageJson.IComponent;
|
|
4
|
+
const plus: (x: IAutoBeTokenUsageJson.IComponent, y: IAutoBeTokenUsageJson.IComponent) => IAutoBeTokenUsageJson.IComponent;
|
|
5
|
+
const increment: (x: IAutoBeTokenUsageJson.IComponent, y: IAutoBeTokenUsageJson.IComponent) => void;
|
|
6
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TokenUsageComputer = void 0;
|
|
4
|
+
var TokenUsageComputer;
|
|
5
|
+
(function (TokenUsageComputer) {
|
|
6
|
+
TokenUsageComputer.zero = () => ({
|
|
7
|
+
total: 0,
|
|
8
|
+
input: {
|
|
9
|
+
total: 0,
|
|
10
|
+
cached: 0,
|
|
11
|
+
},
|
|
12
|
+
output: {
|
|
13
|
+
total: 0,
|
|
14
|
+
reasoning: 0,
|
|
15
|
+
accepted_prediction: 0,
|
|
16
|
+
rejected_prediction: 0,
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
TokenUsageComputer.plus = (x, y) => ({
|
|
20
|
+
total: x.total + y.total,
|
|
21
|
+
input: {
|
|
22
|
+
total: x.input.total + y.input.total,
|
|
23
|
+
cached: x.input.cached + y.input.cached,
|
|
24
|
+
},
|
|
25
|
+
output: {
|
|
26
|
+
total: x.output.total + y.output.total,
|
|
27
|
+
reasoning: x.output.reasoning + y.output.reasoning,
|
|
28
|
+
accepted_prediction: x.output.accepted_prediction + y.output.accepted_prediction,
|
|
29
|
+
rejected_prediction: x.output.rejected_prediction + y.output.rejected_prediction,
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
TokenUsageComputer.increment = (x, y) => {
|
|
33
|
+
x.total += y.total;
|
|
34
|
+
x.input.total += y.input.total;
|
|
35
|
+
x.input.cached += y.input.cached;
|
|
36
|
+
x.output.total += y.output.total;
|
|
37
|
+
x.output.reasoning += y.output.reasoning;
|
|
38
|
+
x.output.accepted_prediction += y.output.accepted_prediction;
|
|
39
|
+
x.output.rejected_prediction += y.output.rejected_prediction;
|
|
40
|
+
};
|
|
41
|
+
})(TokenUsageComputer || (exports.TokenUsageComputer = TokenUsageComputer = {}));
|
|
42
|
+
//# sourceMappingURL=TokenUsageComputer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TokenUsageComputer.js","sourceRoot":"","sources":["../../src/aggregate/TokenUsageComputer.ts"],"names":[],"mappings":";;;AAEA,IAAiB,kBAAkB,CA8ClC;AA9CD,WAAiB,kBAAkB;IACpB,uBAAI,GAAG,GAAqC,EAAE,CAAC,CAAC;QAC3D,KAAK,EAAE,CAAC;QACR,KAAK,EAAE;YACL,KAAK,EAAE,CAAC;YACR,MAAM,EAAE,CAAC;SACV;QACD,MAAM,EAAE;YACN,KAAK,EAAE,CAAC;YACR,SAAS,EAAE,CAA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C,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,EA9CgB,kBAAkB,kCAAlB,kBAAkB,QA8ClC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
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("./AutoBeFunctionCallingMetricFactory"), exports);
|
|
18
|
+
__exportStar(require("./AutoBeProcessAggregateFactory"), exports);
|
|
19
|
+
__exportStar(require("./TokenUsageComputer"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/aggregate/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uEAAqD;AACrD,kEAAgD;AAChD,uDAAqC"}
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -14,8 +14,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./aggregate"), exports);
|
|
18
|
+
__exportStar(require("./prisma"), exports);
|
|
17
19
|
__exportStar(require("./interface"), exports);
|
|
18
20
|
__exportStar(require("./test"), exports);
|
|
21
|
+
__exportStar(require("./ArrayUtil"), exports);
|
|
19
22
|
__exportStar(require("./MapUtil"), exports);
|
|
20
23
|
__exportStar(require("./StringUtil"), exports);
|
|
21
24
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,yCAAuB;AAEvB,4CAA0B;AAC1B,+CAA6B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAE5B,2CAAyB;AACzB,8CAA4B;AAC5B,yCAAuB;AAEvB,8CAA4B;AAC5B,4CAA0B;AAC1B,+CAA6B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./writePrismaApplication";
|
|
@@ -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("./writePrismaApplication"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/prisma/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2DAAyC"}
|