@resolveio/server-lib 20.13.11 → 20.14.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.
- package/collections/ai-terminal-conversation.collection.d.ts +2 -0
- package/collections/ai-terminal-conversation.collection.js +133 -0
- package/collections/ai-terminal-conversation.collection.js.map +1 -0
- package/collections/ai-terminal-message.collection.d.ts +2 -0
- package/collections/ai-terminal-message.collection.js +113 -0
- package/collections/ai-terminal-message.collection.js.map +1 -0
- package/collections/communication-metric.collection.d.ts +2 -0
- package/collections/communication-metric.collection.js +133 -0
- package/collections/communication-metric.collection.js.map +1 -0
- package/collections/openai-usage-ledger.collection.d.ts +2 -0
- package/collections/openai-usage-ledger.collection.js +120 -0
- package/collections/openai-usage-ledger.collection.js.map +1 -0
- package/managers/communication-metric.manager.d.ts +16 -0
- package/managers/communication-metric.manager.js +134 -0
- package/managers/communication-metric.manager.js.map +1 -0
- package/managers/method.manager.d.ts +2 -0
- package/managers/method.manager.js +162 -45
- package/managers/method.manager.js.map +1 -1
- package/managers/openai-usage-ledger.manager.d.ts +14 -0
- package/managers/openai-usage-ledger.manager.js +137 -0
- package/managers/openai-usage-ledger.manager.js.map +1 -0
- package/managers/subscription.manager.js +2 -0
- package/managers/subscription.manager.js.map +1 -1
- package/methods/ai-terminal.d.ts +1 -0
- package/methods/ai-terminal.js +1200 -0
- package/methods/ai-terminal.js.map +1 -0
- package/methods/report-builder.js +741 -0
- package/methods/report-builder.js.map +1 -1
- package/methods.ts +27 -0
- package/models/ai-terminal-conversation.model.d.ts +16 -0
- package/models/ai-terminal-conversation.model.js +4 -0
- package/models/ai-terminal-conversation.model.js.map +1 -0
- package/models/ai-terminal-message.model.d.ts +22 -0
- package/models/ai-terminal-message.model.js +4 -0
- package/models/ai-terminal-message.model.js.map +1 -0
- package/models/communication-metric.model.d.ts +20 -0
- package/models/communication-metric.model.js +4 -0
- package/models/communication-metric.model.js.map +1 -0
- package/models/openai-usage-ledger.model.d.ts +14 -0
- package/models/openai-usage-ledger.model.js +4 -0
- package/models/openai-usage-ledger.model.js.map +1 -0
- package/package.json +5 -1
- package/public_api.d.ts +13 -0
- package/public_api.js +13 -0
- package/public_api.js.map +1 -1
- package/publications/ai-terminal.d.ts +1 -0
- package/publications/ai-terminal.js +58 -0
- package/publications/ai-terminal.js.map +1 -0
- package/publications.ts +6 -0
- package/services/codex-client.d.ts +81 -0
- package/services/codex-client.js +991 -0
- package/services/codex-client.js.map +1 -0
- package/services/openai-client.d.ts +46 -0
- package/services/openai-client.js +315 -0
- package/services/openai-client.js.map +1 -0
- package/util/common.js +20 -53
- package/util/common.js.map +1 -1
- package/util/tokenizer.d.ts +5 -0
- package/util/tokenizer.js +35 -0
- package/util/tokenizer.js.map +1 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { AiTerminalConversationModel } from '../models/ai-terminal-conversation.model';
|
|
2
|
+
export declare const AiTerminalConversations: import("../managers/mongo.manager").MongoManagerCollection<AiTerminalConversationModel> | import("../managers/mongo.manager").MongoManagerUserCollection<AiTerminalConversationModel>;
|
|
@@ -0,0 +1,133 @@
|
|
|
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 __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.AiTerminalConversations = void 0;
|
|
40
|
+
var mongo_manager_1 = require("../managers/mongo.manager");
|
|
41
|
+
var schema = {
|
|
42
|
+
_id: {
|
|
43
|
+
type: String,
|
|
44
|
+
optional: true
|
|
45
|
+
},
|
|
46
|
+
__v: {
|
|
47
|
+
type: Number,
|
|
48
|
+
optional: true
|
|
49
|
+
},
|
|
50
|
+
createdAt: {
|
|
51
|
+
type: Date,
|
|
52
|
+
optional: true
|
|
53
|
+
},
|
|
54
|
+
updatedAt: {
|
|
55
|
+
type: Date,
|
|
56
|
+
optional: true
|
|
57
|
+
},
|
|
58
|
+
id_client: {
|
|
59
|
+
type: String,
|
|
60
|
+
optional: true
|
|
61
|
+
},
|
|
62
|
+
id_app: {
|
|
63
|
+
type: String,
|
|
64
|
+
optional: true
|
|
65
|
+
},
|
|
66
|
+
title: {
|
|
67
|
+
type: String,
|
|
68
|
+
optional: true
|
|
69
|
+
},
|
|
70
|
+
mode: {
|
|
71
|
+
type: String,
|
|
72
|
+
optional: true
|
|
73
|
+
},
|
|
74
|
+
branch_enabled: {
|
|
75
|
+
type: Boolean,
|
|
76
|
+
optional: true
|
|
77
|
+
},
|
|
78
|
+
branch_name: {
|
|
79
|
+
type: String,
|
|
80
|
+
optional: true
|
|
81
|
+
},
|
|
82
|
+
status: {
|
|
83
|
+
type: String,
|
|
84
|
+
optional: true
|
|
85
|
+
},
|
|
86
|
+
profile_id: {
|
|
87
|
+
type: String,
|
|
88
|
+
optional: true
|
|
89
|
+
},
|
|
90
|
+
metadata: {
|
|
91
|
+
type: Object,
|
|
92
|
+
optional: true,
|
|
93
|
+
blackbox: true
|
|
94
|
+
},
|
|
95
|
+
last_message_at: {
|
|
96
|
+
type: Date,
|
|
97
|
+
optional: true
|
|
98
|
+
},
|
|
99
|
+
last_message_id: {
|
|
100
|
+
type: String,
|
|
101
|
+
optional: true
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
var model = mongo_manager_1.MongoManagerModel.create({
|
|
105
|
+
collectionName: 'ai-terminal-conversations',
|
|
106
|
+
schema: schema,
|
|
107
|
+
useVersionCollection: false,
|
|
108
|
+
useReportBuilder: false,
|
|
109
|
+
reportBuilderLookupTables: [],
|
|
110
|
+
timestamps: true,
|
|
111
|
+
createLogs: false,
|
|
112
|
+
checkSchema: true,
|
|
113
|
+
collectionOptions: null
|
|
114
|
+
});
|
|
115
|
+
exports.AiTerminalConversations = model.collection_main;
|
|
116
|
+
setTimeout(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
117
|
+
return __generator(this, function (_a) {
|
|
118
|
+
switch (_a.label) {
|
|
119
|
+
case 0: return [4 /*yield*/, exports.AiTerminalConversations.createIndex({ id_client: 1, updatedAt: -1 })];
|
|
120
|
+
case 1:
|
|
121
|
+
_a.sent();
|
|
122
|
+
return [4 /*yield*/, exports.AiTerminalConversations.createIndex({ id_app: 1, updatedAt: -1 })];
|
|
123
|
+
case 2:
|
|
124
|
+
_a.sent();
|
|
125
|
+
return [4 /*yield*/, exports.AiTerminalConversations.createIndex({ status: 1, updatedAt: -1 })];
|
|
126
|
+
case 3:
|
|
127
|
+
_a.sent();
|
|
128
|
+
return [2 /*return*/];
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
}); }, 5000);
|
|
132
|
+
|
|
133
|
+
//# sourceMappingURL=ai-terminal-conversation.collection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/collections/ai-terminal-conversation.collection.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2DAA8D;AAG9D,IAAM,MAAM,GAAQ;IACnB,GAAG,EAAE;QACJ,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;KACd;IACD,GAAG,EAAE;QACJ,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;KACd;IACD,SAAS,EAAE;QACV,IAAI,EAAE,IAAI;QACV,QAAQ,EAAE,IAAI;KACd;IACD,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,CAAC;;;oBACV,qBAAM,+BAAuB,CAAC,WAAW,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,EAAA;;gBAA1E,SAA0E,CAAC;gBAC3E,qBAAM,+BAAuB,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,EAAA;;gBAAvE,SAAuE,CAAC;gBACxE,qBAAM,+BAAuB,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,EAAA;;gBAAvE,SAAuE,CAAC;;;;KACxE,EAAE,IAAI,CAAC,CAAC","file":"ai-terminal-conversation.collection.js","sourcesContent":["import { MongoManagerModel } from '../managers/mongo.manager';\nimport { AiTerminalConversationModel } from '../models/ai-terminal-conversation.model';\n\nconst schema: any = {\n\t_id: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\t__v: {\n\t\ttype: Number,\n\t\toptional: true\n\t},\n\tcreatedAt: {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\tupdatedAt: {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\tid_client: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tid_app: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\ttitle: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tmode: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tbranch_enabled: {\n\t\ttype: Boolean,\n\t\toptional: true\n\t},\n\tbranch_name: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tstatus: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tprofile_id: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tmetadata: {\n\t\ttype: Object,\n\t\toptional: true,\n\t\tblackbox: true\n\t},\n\tlast_message_at: {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\tlast_message_id: {\n\t\ttype: String,\n\t\toptional: true\n\t}\n};\n\nconst model = MongoManagerModel.create<AiTerminalConversationModel>({\n\tcollectionName: 'ai-terminal-conversations',\n\tschema: schema,\n\tuseVersionCollection: false,\n\tuseReportBuilder: false,\n\treportBuilderLookupTables: [],\n\ttimestamps: true,\n\tcreateLogs: false,\n\tcheckSchema: true,\n\tcollectionOptions: null\n});\n\nexport const AiTerminalConversations = model.collection_main;\n\nsetTimeout(async () => {\n\tawait AiTerminalConversations.createIndex({ id_client: 1, updatedAt: -1 });\n\tawait AiTerminalConversations.createIndex({ id_app: 1, updatedAt: -1 });\n\tawait AiTerminalConversations.createIndex({ status: 1, updatedAt: -1 });\n}, 5000);\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { AiTerminalMessageModel } from '../models/ai-terminal-message.model';
|
|
2
|
+
export declare const AiTerminalMessages: import("../managers/mongo.manager").MongoManagerCollection<AiTerminalMessageModel> | import("../managers/mongo.manager").MongoManagerUserCollection<AiTerminalMessageModel>;
|
|
@@ -0,0 +1,113 @@
|
|
|
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 __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.AiTerminalMessages = void 0;
|
|
40
|
+
var mongo_manager_1 = require("../managers/mongo.manager");
|
|
41
|
+
var schema = {
|
|
42
|
+
_id: {
|
|
43
|
+
type: String,
|
|
44
|
+
optional: true
|
|
45
|
+
},
|
|
46
|
+
__v: {
|
|
47
|
+
type: Number,
|
|
48
|
+
optional: true
|
|
49
|
+
},
|
|
50
|
+
createdAt: {
|
|
51
|
+
type: Date,
|
|
52
|
+
optional: true
|
|
53
|
+
},
|
|
54
|
+
updatedAt: {
|
|
55
|
+
type: Date,
|
|
56
|
+
optional: true
|
|
57
|
+
},
|
|
58
|
+
id_conversation: {
|
|
59
|
+
type: String
|
|
60
|
+
},
|
|
61
|
+
role: {
|
|
62
|
+
type: String
|
|
63
|
+
},
|
|
64
|
+
content: {
|
|
65
|
+
type: String
|
|
66
|
+
},
|
|
67
|
+
metadata: {
|
|
68
|
+
type: Object,
|
|
69
|
+
optional: true,
|
|
70
|
+
blackbox: true
|
|
71
|
+
},
|
|
72
|
+
usage: {
|
|
73
|
+
type: Object,
|
|
74
|
+
optional: true,
|
|
75
|
+
blackbox: true
|
|
76
|
+
},
|
|
77
|
+
attachments: {
|
|
78
|
+
type: Array,
|
|
79
|
+
optional: true
|
|
80
|
+
},
|
|
81
|
+
'attachments.$': {
|
|
82
|
+
type: Object,
|
|
83
|
+
optional: true,
|
|
84
|
+
blackbox: true
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
var model = mongo_manager_1.MongoManagerModel.create({
|
|
88
|
+
collectionName: 'ai-terminal-messages',
|
|
89
|
+
schema: schema,
|
|
90
|
+
useVersionCollection: false,
|
|
91
|
+
useReportBuilder: false,
|
|
92
|
+
reportBuilderLookupTables: [],
|
|
93
|
+
timestamps: true,
|
|
94
|
+
createLogs: false,
|
|
95
|
+
checkSchema: true,
|
|
96
|
+
collectionOptions: null
|
|
97
|
+
});
|
|
98
|
+
exports.AiTerminalMessages = model.collection_main;
|
|
99
|
+
setTimeout(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
100
|
+
return __generator(this, function (_a) {
|
|
101
|
+
switch (_a.label) {
|
|
102
|
+
case 0: return [4 /*yield*/, exports.AiTerminalMessages.createIndex({ id_conversation: 1, createdAt: 1 })];
|
|
103
|
+
case 1:
|
|
104
|
+
_a.sent();
|
|
105
|
+
return [4 /*yield*/, exports.AiTerminalMessages.createIndex({ id_conversation: 1, role: 1 })];
|
|
106
|
+
case 2:
|
|
107
|
+
_a.sent();
|
|
108
|
+
return [2 /*return*/];
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
}); }, 5000);
|
|
112
|
+
|
|
113
|
+
//# sourceMappingURL=ai-terminal-message.collection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/collections/ai-terminal-message.collection.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2DAA8D;AAG9D,IAAM,MAAM,GAAQ;IACnB,GAAG,EAAE;QACJ,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;KACd;IACD,GAAG,EAAE;QACJ,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;KACd;IACD,SAAS,EAAE;QACV,IAAI,EAAE,IAAI;QACV,QAAQ,EAAE,IAAI;KACd;IACD,SAAS,EAAE;QACV,IAAI,EAAE,IAAI;QACV,QAAQ,EAAE,IAAI;KACd;IACD,eAAe,EAAE;QAChB,IAAI,EAAE,MAAM;KACZ;IACD,IAAI,EAAE;QACL,IAAI,EAAE,MAAM;KACZ;IACD,OAAO,EAAE;QACR,IAAI,EAAE,MAAM;KACZ;IACD,QAAQ,EAAE;QACT,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;QACd,QAAQ,EAAE,IAAI;KACd;IACD,KAAK,EAAE;QACN,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;QACd,QAAQ,EAAE,IAAI;KACd;IACD,WAAW,EAAE;QACZ,IAAI,EAAE,KAAK;QACX,QAAQ,EAAE,IAAI;KACd;IACD,eAAe,EAAE;QAChB,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;QACd,QAAQ,EAAE,IAAI;KACd;CACD,CAAC;AAEF,IAAM,KAAK,GAAG,iCAAiB,CAAC,MAAM,CAAyB;IAC9D,cAAc,EAAE,sBAAsB;IACtC,MAAM,EAAE,MAAM;IACd,oBAAoB,EAAE,KAAK;IAC3B,gBAAgB,EAAE,KAAK;IACvB,yBAAyB,EAAE,EAAE;IAC7B,UAAU,EAAE,IAAI;IAChB,UAAU,EAAE,KAAK;IACjB,WAAW,EAAE,IAAI;IACjB,iBAAiB,EAAE,IAAI;CACvB,CAAC,CAAC;AAEU,QAAA,kBAAkB,GAAG,KAAK,CAAC,eAAe,CAAC;AAExD,UAAU,CAAC;;;oBACV,qBAAM,0BAAkB,CAAC,WAAW,CAAC,EAAE,eAAe,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,EAAA;;gBAA1E,SAA0E,CAAC;gBAC3E,qBAAM,0BAAkB,CAAC,WAAW,CAAC,EAAE,eAAe,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,EAAA;;gBAArE,SAAqE,CAAC;;;;KACtE,EAAE,IAAI,CAAC,CAAC","file":"ai-terminal-message.collection.js","sourcesContent":["import { MongoManagerModel } from '../managers/mongo.manager';\nimport { AiTerminalMessageModel } from '../models/ai-terminal-message.model';\n\nconst schema: any = {\n\t_id: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\t__v: {\n\t\ttype: Number,\n\t\toptional: true\n\t},\n\tcreatedAt: {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\tupdatedAt: {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\tid_conversation: {\n\t\ttype: String\n\t},\n\trole: {\n\t\ttype: String\n\t},\n\tcontent: {\n\t\ttype: String\n\t},\n\tmetadata: {\n\t\ttype: Object,\n\t\toptional: true,\n\t\tblackbox: true\n\t},\n\tusage: {\n\t\ttype: Object,\n\t\toptional: true,\n\t\tblackbox: true\n\t},\n\tattachments: {\n\t\ttype: Array,\n\t\toptional: true\n\t},\n\t'attachments.$': {\n\t\ttype: Object,\n\t\toptional: true,\n\t\tblackbox: true\n\t}\n};\n\nconst model = MongoManagerModel.create<AiTerminalMessageModel>({\n\tcollectionName: 'ai-terminal-messages',\n\tschema: schema,\n\tuseVersionCollection: false,\n\tuseReportBuilder: false,\n\treportBuilderLookupTables: [],\n\ttimestamps: true,\n\tcreateLogs: false,\n\tcheckSchema: true,\n\tcollectionOptions: null\n});\n\nexport const AiTerminalMessages = model.collection_main;\n\nsetTimeout(async () => {\n\tawait AiTerminalMessages.createIndex({ id_conversation: 1, createdAt: 1 });\n\tawait AiTerminalMessages.createIndex({ id_conversation: 1, role: 1 });\n}, 5000);\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { CommunicationMetricModel } from '../models/communication-metric.model';
|
|
2
|
+
export declare const CommunicationMetrics: import("../managers/mongo.manager").MongoManagerCollection<CommunicationMetricModel> | import("../managers/mongo.manager").MongoManagerUserCollection<CommunicationMetricModel>;
|
|
@@ -0,0 +1,133 @@
|
|
|
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 __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.CommunicationMetrics = void 0;
|
|
40
|
+
var mongo_manager_1 = require("../managers/mongo.manager");
|
|
41
|
+
var schema = {
|
|
42
|
+
_id: {
|
|
43
|
+
type: String,
|
|
44
|
+
optional: true
|
|
45
|
+
},
|
|
46
|
+
date: {
|
|
47
|
+
type: Date
|
|
48
|
+
},
|
|
49
|
+
type: {
|
|
50
|
+
type: String
|
|
51
|
+
},
|
|
52
|
+
value: {
|
|
53
|
+
type: Number
|
|
54
|
+
},
|
|
55
|
+
unit: {
|
|
56
|
+
type: String,
|
|
57
|
+
optional: true
|
|
58
|
+
},
|
|
59
|
+
metadata: {
|
|
60
|
+
type: Object,
|
|
61
|
+
optional: true,
|
|
62
|
+
blackbox: true
|
|
63
|
+
},
|
|
64
|
+
'metadata.clientSlug': {
|
|
65
|
+
type: String,
|
|
66
|
+
optional: true
|
|
67
|
+
},
|
|
68
|
+
'metadata.clientName': {
|
|
69
|
+
type: String,
|
|
70
|
+
optional: true
|
|
71
|
+
},
|
|
72
|
+
'metadata.id_client': {
|
|
73
|
+
type: String,
|
|
74
|
+
optional: true
|
|
75
|
+
},
|
|
76
|
+
'metadata.channel': {
|
|
77
|
+
type: String,
|
|
78
|
+
optional: true
|
|
79
|
+
},
|
|
80
|
+
'metadata.status': {
|
|
81
|
+
type: String,
|
|
82
|
+
optional: true
|
|
83
|
+
},
|
|
84
|
+
'metadata.provider': {
|
|
85
|
+
type: String,
|
|
86
|
+
optional: true
|
|
87
|
+
},
|
|
88
|
+
'metadata.method': {
|
|
89
|
+
type: String,
|
|
90
|
+
optional: true
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
var model = mongo_manager_1.MongoManagerModel.create({
|
|
94
|
+
collectionName: 'communication-metrics',
|
|
95
|
+
schema: schema,
|
|
96
|
+
useVersionCollection: false,
|
|
97
|
+
useReportBuilder: false,
|
|
98
|
+
reportBuilderLookupTables: [],
|
|
99
|
+
timestamps: false,
|
|
100
|
+
createLogs: false,
|
|
101
|
+
checkSchema: true,
|
|
102
|
+
collectionOptions: {
|
|
103
|
+
timeseries: {
|
|
104
|
+
timeField: 'date',
|
|
105
|
+
granularity: 'hours',
|
|
106
|
+
metaField: 'metadata'
|
|
107
|
+
},
|
|
108
|
+
expireAfterSeconds: 60 * 60 * 24 * 365
|
|
109
|
+
},
|
|
110
|
+
skipCache: true
|
|
111
|
+
});
|
|
112
|
+
exports.CommunicationMetrics = model.collection_main;
|
|
113
|
+
setTimeout(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
114
|
+
return __generator(this, function (_a) {
|
|
115
|
+
switch (_a.label) {
|
|
116
|
+
case 0: return [4 /*yield*/, exports.CommunicationMetrics.createIndex({ type: 1, date: 1 })];
|
|
117
|
+
case 1:
|
|
118
|
+
_a.sent();
|
|
119
|
+
return [4 /*yield*/, exports.CommunicationMetrics.createIndex({ 'metadata.clientSlug': 1, date: 1 })];
|
|
120
|
+
case 2:
|
|
121
|
+
_a.sent();
|
|
122
|
+
return [4 /*yield*/, exports.CommunicationMetrics.createIndex({ 'metadata.clientName': 1, date: 1 })];
|
|
123
|
+
case 3:
|
|
124
|
+
_a.sent();
|
|
125
|
+
return [4 /*yield*/, exports.CommunicationMetrics.createIndex({ 'metadata.id_client': 1, date: 1 })];
|
|
126
|
+
case 4:
|
|
127
|
+
_a.sent();
|
|
128
|
+
return [2 /*return*/];
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
}); }, 5000);
|
|
132
|
+
|
|
133
|
+
//# sourceMappingURL=communication-metric.collection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/collections/communication-metric.collection.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2DAA8D;AAG9D,IAAM,MAAM,GAAQ;IACnB,GAAG,EAAE;QACJ,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;KACd;IACD,IAAI,EAAE;QACL,IAAI,EAAE,IAAI;KACV;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AI;CACf,CAAC,CAAC;AAEU,QAAA,oBAAoB,GAAG,KAAK,CAAC,eAAe,CAAC;AAE1D,UAAU,CAAC;;;oBACV,qBAAM,4BAAoB,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,EAAA;;gBAA5D,SAA4D,CAAC;gBAC7D,qBAAM,4BAAoB,CAAC,WAAW,CAAC,EAAE,qBAAqB,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,EAAA;;gBAA7E,SAA6E,CAAC;gBAC9E,qBAAM,4BAAoB,CAAC,WAAW,CAAC,EAAE,qBAAqB,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,EAAA;;gBAA7E,SAA6E,CAAC;gBAC9E,qBAAM,4BAAoB,CAAC,WAAW,CAAC,EAAE,oBAAoB,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,EAAA;;gBAA5E,SAA4E,CAAC;;;;KAC7E,EAAE,IAAI,CAAC,CAAC","file":"communication-metric.collection.js","sourcesContent":["import { MongoManagerModel } from '../managers/mongo.manager';\nimport { CommunicationMetricModel } from '../models/communication-metric.model';\n\nconst schema: any = {\n\t_id: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tdate: {\n\t\ttype: Date\n\t},\n\ttype: {\n\t\ttype: String\n\t},\n\tvalue: {\n\t\ttype: Number\n\t},\n\tunit: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tmetadata: {\n\t\ttype: Object,\n\t\toptional: true,\n\t\tblackbox: true\n\t},\n\t'metadata.clientSlug': {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\t'metadata.clientName': {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\t'metadata.id_client': {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\t'metadata.channel': {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\t'metadata.status': {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\t'metadata.provider': {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\t'metadata.method': {\n\t\ttype: String,\n\t\toptional: true\n\t}\n};\n\nconst model = MongoManagerModel.create<CommunicationMetricModel>({\n\tcollectionName: 'communication-metrics',\n\tschema,\n\tuseVersionCollection: false,\n\tuseReportBuilder: false,\n\treportBuilderLookupTables: [],\n\ttimestamps: false,\n\tcreateLogs: false,\n\tcheckSchema: true,\n\tcollectionOptions: {\n\t\ttimeseries: {\n\t\t\ttimeField: 'date',\n\t\t\tgranularity: 'hours',\n\t\t\tmetaField: 'metadata'\n\t\t},\n\t\texpireAfterSeconds: 60 * 60 * 24 * 365\n\t},\n\tskipCache: true\n});\n\nexport const CommunicationMetrics = model.collection_main;\n\nsetTimeout(async () => {\n\tawait CommunicationMetrics.createIndex({ type: 1, date: 1 });\n\tawait CommunicationMetrics.createIndex({ 'metadata.clientSlug': 1, date: 1 });\n\tawait CommunicationMetrics.createIndex({ 'metadata.clientName': 1, date: 1 });\n\tawait CommunicationMetrics.createIndex({ 'metadata.id_client': 1, date: 1 });\n}, 5000);\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { OpenAIUsageLedgerModel } from '../models/openai-usage-ledger.model';
|
|
2
|
+
export declare const OpenAIUsageLedger: import("../managers/mongo.manager").MongoManagerCollection<OpenAIUsageLedgerModel> | import("../managers/mongo.manager").MongoManagerUserCollection<OpenAIUsageLedgerModel>;
|
|
@@ -0,0 +1,120 @@
|
|
|
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 __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.OpenAIUsageLedger = void 0;
|
|
40
|
+
var mongo_manager_1 = require("../managers/mongo.manager");
|
|
41
|
+
var schema = {
|
|
42
|
+
_id: {
|
|
43
|
+
type: String,
|
|
44
|
+
optional: true
|
|
45
|
+
},
|
|
46
|
+
id_client: {
|
|
47
|
+
type: String
|
|
48
|
+
},
|
|
49
|
+
timestamp: {
|
|
50
|
+
type: Date
|
|
51
|
+
},
|
|
52
|
+
model: {
|
|
53
|
+
type: String
|
|
54
|
+
},
|
|
55
|
+
input_tokens: {
|
|
56
|
+
type: Number
|
|
57
|
+
},
|
|
58
|
+
output_tokens: {
|
|
59
|
+
type: Number
|
|
60
|
+
},
|
|
61
|
+
total_tokens: {
|
|
62
|
+
type: Number
|
|
63
|
+
},
|
|
64
|
+
cost_estimate: {
|
|
65
|
+
type: Number
|
|
66
|
+
},
|
|
67
|
+
billable: {
|
|
68
|
+
type: Boolean
|
|
69
|
+
},
|
|
70
|
+
category: {
|
|
71
|
+
type: String,
|
|
72
|
+
optional: true
|
|
73
|
+
},
|
|
74
|
+
id_request: {
|
|
75
|
+
type: String,
|
|
76
|
+
optional: true
|
|
77
|
+
},
|
|
78
|
+
id_conversation: {
|
|
79
|
+
type: String,
|
|
80
|
+
optional: true
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
var model = mongo_manager_1.MongoManagerModel.create({
|
|
84
|
+
collectionName: 'openai-usage-ledger',
|
|
85
|
+
schema: schema,
|
|
86
|
+
useVersionCollection: false,
|
|
87
|
+
useReportBuilder: false,
|
|
88
|
+
reportBuilderLookupTables: [],
|
|
89
|
+
timestamps: false,
|
|
90
|
+
createLogs: false,
|
|
91
|
+
checkSchema: true,
|
|
92
|
+
collectionOptions: {
|
|
93
|
+
timeseries: {
|
|
94
|
+
timeField: 'timestamp',
|
|
95
|
+
metaField: 'id_client',
|
|
96
|
+
granularity: 'hours'
|
|
97
|
+
},
|
|
98
|
+
expireAfterSeconds: 60 * 60 * 24 * 365
|
|
99
|
+
},
|
|
100
|
+
skipCache: true
|
|
101
|
+
});
|
|
102
|
+
exports.OpenAIUsageLedger = model.collection_main;
|
|
103
|
+
setTimeout(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
104
|
+
return __generator(this, function (_a) {
|
|
105
|
+
switch (_a.label) {
|
|
106
|
+
case 0: return [4 /*yield*/, exports.OpenAIUsageLedger.createIndex({ id_client: 1, timestamp: -1 })];
|
|
107
|
+
case 1:
|
|
108
|
+
_a.sent();
|
|
109
|
+
return [4 /*yield*/, exports.OpenAIUsageLedger.createIndex({ id_conversation: 1, timestamp: -1 })];
|
|
110
|
+
case 2:
|
|
111
|
+
_a.sent();
|
|
112
|
+
return [4 /*yield*/, exports.OpenAIUsageLedger.createIndex({ id_request: 1 })];
|
|
113
|
+
case 3:
|
|
114
|
+
_a.sent();
|
|
115
|
+
return [2 /*return*/];
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
}); }, 5000);
|
|
119
|
+
|
|
120
|
+
//# sourceMappingURL=openai-usage-ledger.collection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/collections/openai-usage-ledger.collection.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2DAA8D;AAG9D,IAAM,MAAM,GAAQ;IACnB,GAAG,EAAE;QACJ,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;KACd;IACD,SAAS,EAAE;QACV,IAAI,EAAE,MAAM;KACZ;IACD,SAAS,EAAE;QACV,IAAI,EAAE,IAAI;KACV;IACD,KAAK,EAAE;QACN,IAAI,EAAE,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AAC,EAAE,CAAC,EAAA;;gBAA1E,SAA0E,CAAC;gBAC3E,qBAAM,yBAAiB,CAAC,WAAW,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC,EAAA;;gBAAtD,SAAsD,CAAC;;;;KACvD,EAAE,IAAI,CAAC,CAAC","file":"openai-usage-ledger.collection.js","sourcesContent":["import { MongoManagerModel } from '../managers/mongo.manager';\nimport { OpenAIUsageLedgerModel } from '../models/openai-usage-ledger.model';\n\nconst schema: any = {\n\t_id: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tid_client: {\n\t\ttype: String\n\t},\n\ttimestamp: {\n\t\ttype: Date\n\t},\n\tmodel: {\n\t\ttype: String\n\t},\n\tinput_tokens: {\n\t\ttype: Number\n\t},\n\toutput_tokens: {\n\t\ttype: Number\n\t},\n\ttotal_tokens: {\n\t\ttype: Number\n\t},\n\tcost_estimate: {\n\t\ttype: Number\n\t},\n\tbillable: {\n\t\ttype: Boolean\n\t},\n\tcategory: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tid_request: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tid_conversation: {\n\t\ttype: String,\n\t\toptional: true\n\t}\n};\n\nconst model = MongoManagerModel.create<OpenAIUsageLedgerModel>({\n\tcollectionName: 'openai-usage-ledger',\n\tschema,\n\tuseVersionCollection: false,\n\tuseReportBuilder: false,\n\treportBuilderLookupTables: [],\n\ttimestamps: false,\n\tcreateLogs: false,\n\tcheckSchema: true,\n\tcollectionOptions: {\n\t\ttimeseries: {\n\t\t\ttimeField: 'timestamp',\n\t\t\tmetaField: 'id_client',\n\t\t\tgranularity: 'hours'\n\t\t},\n\t\texpireAfterSeconds: 60 * 60 * 24 * 365\n\t},\n\tskipCache: true\n});\n\nexport const OpenAIUsageLedger = model.collection_main;\n\nsetTimeout(async () => {\n\tawait OpenAIUsageLedger.createIndex({ id_client: 1, timestamp: -1 });\n\tawait OpenAIUsageLedger.createIndex({ id_conversation: 1, timestamp: -1 });\n\tawait OpenAIUsageLedger.createIndex({ id_request: 1 });\n}, 5000);\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { CommunicationMetricChannel, CommunicationMetricStatus } from '../models/communication-metric.model';
|
|
2
|
+
export interface CommunicationMetricInput {
|
|
3
|
+
channel: CommunicationMetricChannel;
|
|
4
|
+
status: CommunicationMetricStatus;
|
|
5
|
+
value?: number;
|
|
6
|
+
unit?: string;
|
|
7
|
+
timestamp?: Date;
|
|
8
|
+
provider?: string;
|
|
9
|
+
clientSlug?: string;
|
|
10
|
+
clientName?: string;
|
|
11
|
+
id_client?: string;
|
|
12
|
+
metadata?: Record<string, any>;
|
|
13
|
+
}
|
|
14
|
+
export declare function recordCommunicationMetric(input: CommunicationMetricInput): Promise<void>;
|
|
15
|
+
export declare function recordEmailMetric(input: Omit<CommunicationMetricInput, 'channel'>): Promise<void>;
|
|
16
|
+
export declare function recordTextMessageMetric(input: Omit<CommunicationMetricInput, 'channel'>): Promise<void>;
|