@common_ch/common 1.0.271 → 1.0.273
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.
|
@@ -4,16 +4,23 @@ export declare enum RequestType {
|
|
|
4
4
|
image = "create_image",
|
|
5
5
|
audio = "audio",
|
|
6
6
|
text = "text",
|
|
7
|
-
vector = "vector"
|
|
7
|
+
vector = "vector",
|
|
8
|
+
upload = "upload"
|
|
9
|
+
}
|
|
10
|
+
export declare enum FileType {
|
|
11
|
+
text = "text",
|
|
12
|
+
image = "image",
|
|
13
|
+
audio = "audio"
|
|
8
14
|
}
|
|
9
15
|
export interface UsageAiAttrs {
|
|
10
16
|
userId: string;
|
|
11
17
|
requestType: RequestType;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
18
|
+
fileType?: FileType;
|
|
19
|
+
ai?: string;
|
|
20
|
+
modelAi?: string;
|
|
21
|
+
promptTokens?: number;
|
|
22
|
+
completionTokens?: number;
|
|
23
|
+
totalTokens?: number;
|
|
17
24
|
cost: number;
|
|
18
25
|
description: string;
|
|
19
26
|
createdAt?: number;
|
|
@@ -25,12 +32,13 @@ interface UsageAiModel extends mongoose.Model<UsageAiDoc> {
|
|
|
25
32
|
export interface UsageAiDoc extends mongoose.Document {
|
|
26
33
|
_id: string;
|
|
27
34
|
userId: string;
|
|
28
|
-
|
|
35
|
+
fileType?: FileType;
|
|
36
|
+
ai?: string;
|
|
29
37
|
requestType: RequestType;
|
|
30
|
-
modelAi
|
|
31
|
-
promptTokens
|
|
32
|
-
completionTokens
|
|
33
|
-
totalTokens
|
|
38
|
+
modelAi?: string;
|
|
39
|
+
promptTokens?: number;
|
|
40
|
+
completionTokens?: number;
|
|
41
|
+
totalTokens?: number;
|
|
34
42
|
cost: number;
|
|
35
43
|
description: string;
|
|
36
44
|
createdAt?: number;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.UsageAi = exports.RequestType = void 0;
|
|
6
|
+
exports.UsageAi = exports.FileType = exports.RequestType = void 0;
|
|
7
7
|
const mongoose_1 = __importDefault(require("mongoose"));
|
|
8
8
|
var RequestType;
|
|
9
9
|
(function (RequestType) {
|
|
@@ -12,7 +12,14 @@ var RequestType;
|
|
|
12
12
|
RequestType["audio"] = "audio";
|
|
13
13
|
RequestType["text"] = "text";
|
|
14
14
|
RequestType["vector"] = "vector";
|
|
15
|
+
RequestType["upload"] = "upload";
|
|
15
16
|
})(RequestType || (exports.RequestType = RequestType = {}));
|
|
17
|
+
var FileType;
|
|
18
|
+
(function (FileType) {
|
|
19
|
+
FileType["text"] = "text";
|
|
20
|
+
FileType["image"] = "image";
|
|
21
|
+
FileType["audio"] = "audio";
|
|
22
|
+
})(FileType || (exports.FileType = FileType = {}));
|
|
16
23
|
const usageAiSchema = new mongoose_1.default.Schema({
|
|
17
24
|
userId: {
|
|
18
25
|
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
@@ -22,32 +29,37 @@ const usageAiSchema = new mongoose_1.default.Schema({
|
|
|
22
29
|
ai: {
|
|
23
30
|
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
24
31
|
ref: 'Ai',
|
|
25
|
-
require:
|
|
32
|
+
require: false,
|
|
26
33
|
},
|
|
27
34
|
requestType: {
|
|
28
35
|
type: String,
|
|
29
36
|
enum: RequestType,
|
|
30
37
|
default: RequestType.chat,
|
|
31
38
|
},
|
|
39
|
+
fileType: {
|
|
40
|
+
type: String,
|
|
41
|
+
enum: FileType,
|
|
42
|
+
default: FileType.text,
|
|
43
|
+
},
|
|
32
44
|
modelAi: {
|
|
33
45
|
type: String,
|
|
34
|
-
required:
|
|
46
|
+
required: false,
|
|
35
47
|
},
|
|
36
48
|
description: {
|
|
37
49
|
type: String,
|
|
38
|
-
required:
|
|
50
|
+
required: false,
|
|
39
51
|
},
|
|
40
52
|
promptTokens: {
|
|
41
53
|
type: Number,
|
|
42
|
-
required:
|
|
54
|
+
required: false,
|
|
43
55
|
},
|
|
44
56
|
completionTokens: {
|
|
45
57
|
type: Number,
|
|
46
|
-
required:
|
|
58
|
+
required: false,
|
|
47
59
|
},
|
|
48
60
|
totalTokens: {
|
|
49
61
|
type: Number,
|
|
50
|
-
required:
|
|
62
|
+
required: false,
|
|
51
63
|
},
|
|
52
64
|
cost: {
|
|
53
65
|
type: Number,
|
|
@@ -6,7 +6,7 @@ type EstimateResult = {
|
|
|
6
6
|
costPerDayUSD: number;
|
|
7
7
|
costPerMonthUSD: number;
|
|
8
8
|
};
|
|
9
|
-
export declare function
|
|
9
|
+
export declare function estimateUploadCost(filePath: string, mimeType: string, storagePricePerGBPerDay?: number): EstimateResult | {
|
|
10
10
|
error: string;
|
|
11
11
|
};
|
|
12
12
|
export {};
|
|
@@ -3,10 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.estimateUploadCost = estimateUploadCost;
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
|
-
function
|
|
9
|
+
function estimateUploadCost(filePath, mimeType, storagePricePerGBPerDay = 0.10) {
|
|
10
10
|
var _a;
|
|
11
11
|
if (!fs_1.default.existsSync(filePath)) {
|
|
12
12
|
return { error: "File not found" };
|