@purpleschool/gptbot-tools 0.0.75 → 0.0.76-ai-proxy
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/ai-proxy/index.ts +1 -0
- package/ai-proxy/routes/ai-proxy.routes.ts +6 -0
- package/ai-proxy/routes/index.ts +1 -0
- package/build/ai-proxy/index.js +17 -0
- package/build/ai-proxy/routes/ai-proxy.routes.js +8 -0
- package/build/ai-proxy/routes/index.js +17 -0
- package/build/common/errors/errors.js +0 -5
- package/build/index.js +1 -0
- package/build/video/enums/video-pricing-rule-type.enum.js +0 -1
- package/build/video/enums/video-strategy.enum.js +0 -1
- package/build/video/models/video-model.schema.js +1 -8
- package/build/video/routes/video.http.routes.js +0 -1
- package/build/video/utils/calculate-video-generation-price.util.js +1 -5
- package/common/errors/errors.ts +0 -5
- package/index.ts +1 -0
- package/package.json +1 -1
- package/video/enums/video-pricing-rule-type.enum.ts +0 -1
- package/video/enums/video-strategy.enum.ts +0 -1
- package/video/models/video-model.schema.ts +1 -8
- package/video/routes/video.http.routes.ts +0 -1
- package/video/utils/calculate-video-generation-price.util.ts +1 -7
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './routes';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ai-proxy.routes';
|
|
@@ -0,0 +1,17 @@
|
|
|
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("./routes"), exports);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AI_PROXY_ROUTES = exports.AI_PROXY_CONTROLLER = void 0;
|
|
4
|
+
exports.AI_PROXY_CONTROLLER = 'ai-proxy';
|
|
5
|
+
exports.AI_PROXY_ROUTES = {
|
|
6
|
+
VIDEO_CALLBACK: 'video/callback',
|
|
7
|
+
VIDEO_EDITOR_CALLBACK: 'video-editor/callback',
|
|
8
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
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("./ai-proxy.routes"), exports);
|
|
@@ -578,11 +578,6 @@ exports.ERRORS = {
|
|
|
578
578
|
message: 'Некорректное соотношение сторон',
|
|
579
579
|
httpCode: 400,
|
|
580
580
|
},
|
|
581
|
-
INVALID_RESOLUTION: {
|
|
582
|
-
code: 'VIDEO.INVALID_RESOLUTION',
|
|
583
|
-
message: 'Некорректное разрешение видео',
|
|
584
|
-
httpCode: 400,
|
|
585
|
-
},
|
|
586
581
|
RUNWAY_CONTENT_POLICY: {
|
|
587
582
|
code: 'VIDEO.RUNWAY_CONTENT_POLICY',
|
|
588
583
|
message: 'Запрос на создание видео был отклонен, т.к. он не соответствует требованиям политики безопасности Runway.',
|
package/build/index.js
CHANGED
|
@@ -48,6 +48,7 @@ __exportStar(require("./writer"), exports);
|
|
|
48
48
|
__exportStar(require("./image-editor"), exports);
|
|
49
49
|
__exportStar(require("./video-editor"), exports);
|
|
50
50
|
__exportStar(require("./music"), exports);
|
|
51
|
+
__exportStar(require("./ai-proxy"), exports);
|
|
51
52
|
const common = __importStar(require("./common"));
|
|
52
53
|
const paraphrase = __importStar(require("./paraphrase"));
|
|
53
54
|
const tools = __importStar(require("./tools"));
|
|
@@ -4,5 +4,4 @@ exports.VIDEO_PRICING_RULE_TYPE = void 0;
|
|
|
4
4
|
var VIDEO_PRICING_RULE_TYPE;
|
|
5
5
|
(function (VIDEO_PRICING_RULE_TYPE) {
|
|
6
6
|
VIDEO_PRICING_RULE_TYPE["FLAT"] = "flat";
|
|
7
|
-
VIDEO_PRICING_RULE_TYPE["PER_SECOND"] = "per_second";
|
|
8
7
|
})(VIDEO_PRICING_RULE_TYPE || (exports.VIDEO_PRICING_RULE_TYPE = VIDEO_PRICING_RULE_TYPE = {}));
|
|
@@ -9,5 +9,4 @@ var VIDEO_GENERATION_STRATEGY;
|
|
|
9
9
|
VIDEO_GENERATION_STRATEGY["RUNWAY_CALLBACK"] = "RUNWAY_CALLBACK";
|
|
10
10
|
VIDEO_GENERATION_STRATEGY["SORA_2_VIDEO_GENERATION_POLLING"] = "SORA_2_VIDEO_GENERATION_POLLING";
|
|
11
11
|
VIDEO_GENERATION_STRATEGY["SORA_2_VIDEO_GENERATION_CALLBACK"] = "SORA_2_VIDEO_GENERATION_CALLBACK";
|
|
12
|
-
VIDEO_GENERATION_STRATEGY["SEEDANCE_VIDEO_GENERATION_CALLBACK"] = "SEEDANCE_VIDEO_GENERATION_CALLBACK";
|
|
13
12
|
})(VIDEO_GENERATION_STRATEGY || (exports.VIDEO_GENERATION_STRATEGY = VIDEO_GENERATION_STRATEGY = {}));
|
|
@@ -18,22 +18,15 @@ exports.VideoModelParamsSchema = zod_1.z.object({
|
|
|
18
18
|
})
|
|
19
19
|
.optional(),
|
|
20
20
|
quality: zod_1.z.string().optional(),
|
|
21
|
-
resolution: zod_1.z
|
|
22
|
-
.object({
|
|
23
|
-
options: zod_1.z.array(zod_1.z.string()),
|
|
24
|
-
})
|
|
25
|
-
.optional(),
|
|
26
21
|
});
|
|
27
22
|
exports.VideoGenerationRequestParamsSchema = zod_1.z.object({
|
|
28
23
|
imageUrls: zod_1.z.string().array().optional(),
|
|
29
24
|
duration: zod_1.z.number(),
|
|
30
25
|
aspectRatio: zod_1.z.string().optional(),
|
|
31
26
|
quality: zod_1.z.string().optional(),
|
|
32
|
-
resolution: zod_1.z.string().optional(),
|
|
33
27
|
});
|
|
34
28
|
exports.VideoModelPricingRuleConditionSchema = zod_1.z.object({
|
|
35
|
-
aspectRatio: zod_1.z.string()
|
|
36
|
-
resolution: zod_1.z.string().optional(),
|
|
29
|
+
aspectRatio: zod_1.z.string(),
|
|
37
30
|
});
|
|
38
31
|
exports.VideoModelPricingRulesSchema = zod_1.z.array(zod_1.z.object({
|
|
39
32
|
type: zod_1.z.nativeEnum(enums_1.VIDEO_PRICING_RULE_TYPE),
|
|
@@ -17,11 +17,7 @@ function matchesCondition(condition, params) {
|
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
19
|
function calculateVideoGenerationPrice({ pricePerSecond, params, rules, }) {
|
|
20
|
-
const
|
|
21
|
-
.filter((r) => r.type === enums_1.VIDEO_PRICING_RULE_TYPE.PER_SECOND)
|
|
22
|
-
.find((r) => matchesCondition(r.condition, params));
|
|
23
|
-
const effectivePricePerSecond = perSecondRule ? perSecondRule.value : pricePerSecond;
|
|
24
|
-
const base = effectivePricePerSecond * params.duration;
|
|
20
|
+
const base = pricePerSecond * params.duration;
|
|
25
21
|
const flatMarkup = rules.reduce((sum, r) => {
|
|
26
22
|
if (r.type !== enums_1.VIDEO_PRICING_RULE_TYPE.FLAT) {
|
|
27
23
|
return sum;
|
package/common/errors/errors.ts
CHANGED
|
@@ -577,11 +577,6 @@ export const ERRORS = {
|
|
|
577
577
|
message: 'Некорректное соотношение сторон',
|
|
578
578
|
httpCode: 400,
|
|
579
579
|
},
|
|
580
|
-
INVALID_RESOLUTION: {
|
|
581
|
-
code: 'VIDEO.INVALID_RESOLUTION',
|
|
582
|
-
message: 'Некорректное разрешение видео',
|
|
583
|
-
httpCode: 400,
|
|
584
|
-
},
|
|
585
580
|
RUNWAY_CONTENT_POLICY: {
|
|
586
581
|
code: 'VIDEO.RUNWAY_CONTENT_POLICY',
|
|
587
582
|
message:
|
package/index.ts
CHANGED
package/package.json
CHANGED
|
@@ -5,5 +5,4 @@ export enum VIDEO_GENERATION_STRATEGY {
|
|
|
5
5
|
RUNWAY_CALLBACK = 'RUNWAY_CALLBACK',
|
|
6
6
|
SORA_2_VIDEO_GENERATION_POLLING = 'SORA_2_VIDEO_GENERATION_POLLING',
|
|
7
7
|
SORA_2_VIDEO_GENERATION_CALLBACK = 'SORA_2_VIDEO_GENERATION_CALLBACK',
|
|
8
|
-
SEEDANCE_VIDEO_GENERATION_CALLBACK = 'SEEDANCE_VIDEO_GENERATION_CALLBACK',
|
|
9
8
|
}
|
|
@@ -20,11 +20,6 @@ export const VideoModelParamsSchema = z.object({
|
|
|
20
20
|
})
|
|
21
21
|
.optional(),
|
|
22
22
|
quality: z.string().optional(),
|
|
23
|
-
resolution: z
|
|
24
|
-
.object({
|
|
25
|
-
options: z.array(z.string()),
|
|
26
|
-
})
|
|
27
|
-
.optional(),
|
|
28
23
|
});
|
|
29
24
|
|
|
30
25
|
export type VideoModelParams = z.infer<typeof VideoModelParamsSchema>;
|
|
@@ -34,13 +29,11 @@ export const VideoGenerationRequestParamsSchema = z.object({
|
|
|
34
29
|
duration: z.number(),
|
|
35
30
|
aspectRatio: z.string().optional(),
|
|
36
31
|
quality: z.string().optional(),
|
|
37
|
-
resolution: z.string().optional(),
|
|
38
32
|
});
|
|
39
33
|
export type VideoGenerationRequestParams = z.infer<typeof VideoGenerationRequestParamsSchema>;
|
|
40
34
|
|
|
41
35
|
export const VideoModelPricingRuleConditionSchema = z.object({
|
|
42
|
-
aspectRatio: z.string()
|
|
43
|
-
resolution: z.string().optional(),
|
|
36
|
+
aspectRatio: z.string(),
|
|
44
37
|
});
|
|
45
38
|
export type VideoModelPricingRuleCondition = z.infer<typeof VideoModelPricingRuleConditionSchema>;
|
|
46
39
|
|
|
@@ -36,13 +36,7 @@ export function calculateVideoGenerationPrice({
|
|
|
36
36
|
params: VideoGenerationRequestParams;
|
|
37
37
|
rules: VideoModelPricingRules;
|
|
38
38
|
}) {
|
|
39
|
-
const
|
|
40
|
-
.filter((r) => r.type === VIDEO_PRICING_RULE_TYPE.PER_SECOND)
|
|
41
|
-
.find((r) => matchesCondition(r.condition, params));
|
|
42
|
-
|
|
43
|
-
const effectivePricePerSecond = perSecondRule ? perSecondRule.value : pricePerSecond;
|
|
44
|
-
|
|
45
|
-
const base = effectivePricePerSecond * params.duration;
|
|
39
|
+
const base = pricePerSecond * params.duration;
|
|
46
40
|
|
|
47
41
|
const flatMarkup = rules.reduce((sum, r) => {
|
|
48
42
|
if (r.type !== VIDEO_PRICING_RULE_TYPE.FLAT) {
|