@purpleschool/gptbot-tools 0.0.73 → 0.0.75
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/build/common/errors/errors.js +10 -0
- package/build/tools/enums/index.js +1 -1
- package/build/tools/models/global-tools-config.schema.js +25 -0
- package/build/tools/models/index.js +2 -0
- package/build/tools/models/tools-with-configs.schema.js +55 -0
- package/build/tools/queries/get-global-tools-config.query.js +9 -0
- package/build/tools/queries/get-tools-with-configs.query.js +9 -0
- package/build/tools/queries/index.js +2 -0
- package/build/tools/routes/tools.aqmp.routes.js +2 -0
- package/build/video/enums/video-pricing-rule-type.enum.js +1 -0
- package/build/video/enums/video-strategy.enum.js +1 -0
- package/build/video/models/video-model.schema.js +8 -1
- package/build/video/routes/video.http.routes.js +1 -0
- package/build/video/utils/calculate-video-generation-price.util.js +5 -1
- package/common/errors/errors.ts +10 -0
- package/package.json +1 -1
- package/tools/enums/index.ts +1 -1
- package/tools/models/global-tools-config.schema.ts +25 -0
- package/tools/models/index.ts +2 -0
- package/tools/models/tools-with-configs.schema.ts +75 -0
- package/tools/queries/get-global-tools-config.query.ts +8 -0
- package/tools/queries/get-tools-with-configs.query.ts +8 -0
- package/tools/queries/index.ts +2 -0
- package/tools/routes/tools.aqmp.routes.ts +2 -0
- package/video/enums/video-pricing-rule-type.enum.ts +1 -0
- package/video/enums/video-strategy.enum.ts +1 -0
- package/video/models/video-model.schema.ts +8 -1
- package/video/routes/video.http.routes.ts +1 -0
- package/video/utils/calculate-video-generation-price.util.ts +7 -1
- package/build/tools/enums/{content-type.enum.js → tool-content-type.enum.js} +1 -1
- package/tools/enums/{content-type.enum.ts → tool-content-type.enum.ts} +1 -1
|
@@ -11,6 +11,11 @@ exports.ERRORS = {
|
|
|
11
11
|
message: 'Произошла ошибка при поиске инструмента',
|
|
12
12
|
httpCode: 500,
|
|
13
13
|
},
|
|
14
|
+
GET_GLOBAL_TOOLS_CONFIG_ERROR: {
|
|
15
|
+
code: 'TOOL.GET_GLOBAL_TOOLS_CONFIG_ERROR',
|
|
16
|
+
message: 'Произошла ошибка при получении глобальных конфигураций инструментов',
|
|
17
|
+
httpCode: 500,
|
|
18
|
+
},
|
|
14
19
|
},
|
|
15
20
|
// PARAPHRASE
|
|
16
21
|
PARAPHRASE: {
|
|
@@ -573,6 +578,11 @@ exports.ERRORS = {
|
|
|
573
578
|
message: 'Некорректное соотношение сторон',
|
|
574
579
|
httpCode: 400,
|
|
575
580
|
},
|
|
581
|
+
INVALID_RESOLUTION: {
|
|
582
|
+
code: 'VIDEO.INVALID_RESOLUTION',
|
|
583
|
+
message: 'Некорректное разрешение видео',
|
|
584
|
+
httpCode: 400,
|
|
585
|
+
},
|
|
576
586
|
RUNWAY_CONTENT_POLICY: {
|
|
577
587
|
code: 'VIDEO.RUNWAY_CONTENT_POLICY',
|
|
578
588
|
message: 'Запрос на создание видео был отклонен, т.к. он не соответствует требованиям политики безопасности Runway.',
|
|
@@ -16,4 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./job-status.enum"), exports);
|
|
18
18
|
__exportStar(require("./tool-type.enum"), exports);
|
|
19
|
-
__exportStar(require("./content-type.enum"), exports);
|
|
19
|
+
__exportStar(require("./tool-content-type.enum"), exports);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GlobalToolsConfigSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const enums_1 = require("../enums");
|
|
6
|
+
const video_1 = require("../../video");
|
|
7
|
+
const music_1 = require("../../music");
|
|
8
|
+
const writer_1 = require("../../writer");
|
|
9
|
+
const image_editor_1 = require("../../image-editor");
|
|
10
|
+
const paraphrase_1 = require("../../paraphrase");
|
|
11
|
+
const presentation_1 = require("../../presentation");
|
|
12
|
+
const video_editor_1 = require("../../video-editor");
|
|
13
|
+
const tts_1 = require("../../tts");
|
|
14
|
+
const stt_1 = require("../../stt");
|
|
15
|
+
exports.GlobalToolsConfigSchema = zod_1.z.object({
|
|
16
|
+
[enums_1.TOOL_CONTENT_TYPE.VIDEO]: video_1.VideoConfigSchema,
|
|
17
|
+
[enums_1.TOOL_CONTENT_TYPE.MUSIC]: music_1.MusicConfigSchema,
|
|
18
|
+
[enums_1.TOOL_CONTENT_TYPE.WRITER]: writer_1.WriterConfigSchema,
|
|
19
|
+
[enums_1.TOOL_CONTENT_TYPE.IMAGE_EDITOR]: image_editor_1.ImageEditorConfigSchema,
|
|
20
|
+
[enums_1.TOOL_CONTENT_TYPE.REPHRASE]: paraphrase_1.ParaphraseToolConfigSchema,
|
|
21
|
+
[enums_1.TOOL_CONTENT_TYPE.PRESENTATION]: presentation_1.PresentationConfigSchema,
|
|
22
|
+
[enums_1.TOOL_CONTENT_TYPE.VIDEO_EDITOR]: video_editor_1.VideoEditorConfigSchema,
|
|
23
|
+
[enums_1.TOOL_CONTENT_TYPE.TEXT_TO_SPEECH]: tts_1.TTSConfigSchema,
|
|
24
|
+
[enums_1.TOOL_CONTENT_TYPE.SPEECH_TO_TEXT]: stt_1.STTConfigSchema,
|
|
25
|
+
});
|
|
@@ -16,3 +16,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./tool-job.schema"), exports);
|
|
18
18
|
__exportStar(require("./tool.schema"), exports);
|
|
19
|
+
__exportStar(require("./global-tools-config.schema"), exports);
|
|
20
|
+
__exportStar(require("./tools-with-configs.schema"), exports);
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ToolsWithConfigsSchema = exports.ToolWithConfigSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const enums_1 = require("../enums");
|
|
6
|
+
const video_1 = require("../../video");
|
|
7
|
+
const music_1 = require("../../music");
|
|
8
|
+
const writer_1 = require("../../writer");
|
|
9
|
+
const image_editor_1 = require("../../image-editor");
|
|
10
|
+
const paraphrase_1 = require("../../paraphrase");
|
|
11
|
+
const presentation_1 = require("../../presentation");
|
|
12
|
+
const video_editor_1 = require("../../video-editor");
|
|
13
|
+
const tts_1 = require("../../tts");
|
|
14
|
+
const stt_1 = require("../../stt");
|
|
15
|
+
const tool_schema_1 = require("./tool.schema");
|
|
16
|
+
// Discriminated union array: Tools with their configs
|
|
17
|
+
exports.ToolWithConfigSchema = zod_1.z.discriminatedUnion('contentType', [
|
|
18
|
+
tool_schema_1.ToolSchema.merge(zod_1.z.object({
|
|
19
|
+
contentType: zod_1.z.literal(enums_1.TOOL_CONTENT_TYPE.VIDEO),
|
|
20
|
+
config: video_1.VideoConfigSchema,
|
|
21
|
+
})),
|
|
22
|
+
tool_schema_1.ToolSchema.merge(zod_1.z.object({
|
|
23
|
+
contentType: zod_1.z.literal(enums_1.TOOL_CONTENT_TYPE.MUSIC),
|
|
24
|
+
config: music_1.MusicConfigSchema,
|
|
25
|
+
})),
|
|
26
|
+
tool_schema_1.ToolSchema.merge(zod_1.z.object({
|
|
27
|
+
contentType: zod_1.z.literal(enums_1.TOOL_CONTENT_TYPE.WRITER),
|
|
28
|
+
config: writer_1.WriterConfigSchema,
|
|
29
|
+
})),
|
|
30
|
+
tool_schema_1.ToolSchema.merge(zod_1.z.object({
|
|
31
|
+
contentType: zod_1.z.literal(enums_1.TOOL_CONTENT_TYPE.IMAGE_EDITOR),
|
|
32
|
+
config: image_editor_1.ImageEditorConfigSchema,
|
|
33
|
+
})),
|
|
34
|
+
tool_schema_1.ToolSchema.merge(zod_1.z.object({
|
|
35
|
+
contentType: zod_1.z.literal(enums_1.TOOL_CONTENT_TYPE.REPHRASE),
|
|
36
|
+
config: paraphrase_1.ParaphraseToolConfigSchema,
|
|
37
|
+
})),
|
|
38
|
+
tool_schema_1.ToolSchema.merge(zod_1.z.object({
|
|
39
|
+
contentType: zod_1.z.literal(enums_1.TOOL_CONTENT_TYPE.PRESENTATION),
|
|
40
|
+
config: presentation_1.PresentationConfigSchema,
|
|
41
|
+
})),
|
|
42
|
+
tool_schema_1.ToolSchema.merge(zod_1.z.object({
|
|
43
|
+
contentType: zod_1.z.literal(enums_1.TOOL_CONTENT_TYPE.VIDEO_EDITOR),
|
|
44
|
+
config: video_editor_1.VideoEditorConfigSchema,
|
|
45
|
+
})),
|
|
46
|
+
tool_schema_1.ToolSchema.merge(zod_1.z.object({
|
|
47
|
+
contentType: zod_1.z.literal(enums_1.TOOL_CONTENT_TYPE.TEXT_TO_SPEECH),
|
|
48
|
+
config: tts_1.TTSConfigSchema,
|
|
49
|
+
})),
|
|
50
|
+
tool_schema_1.ToolSchema.merge(zod_1.z.object({
|
|
51
|
+
contentType: zod_1.z.literal(enums_1.TOOL_CONTENT_TYPE.SPEECH_TO_TEXT),
|
|
52
|
+
config: stt_1.STTConfigSchema,
|
|
53
|
+
})),
|
|
54
|
+
]);
|
|
55
|
+
exports.ToolsWithConfigsSchema = zod_1.z.array(exports.ToolWithConfigSchema);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetGlobalToolsConfigQuery = void 0;
|
|
4
|
+
const command_response_schema_1 = require("../../common/models/command-response.schema");
|
|
5
|
+
const models_1 = require("../models");
|
|
6
|
+
var GetGlobalToolsConfigQuery;
|
|
7
|
+
(function (GetGlobalToolsConfigQuery) {
|
|
8
|
+
GetGlobalToolsConfigQuery.ResponseSchema = (0, command_response_schema_1.ICommandResponseSchema)(models_1.GlobalToolsConfigSchema);
|
|
9
|
+
})(GetGlobalToolsConfigQuery || (exports.GetGlobalToolsConfigQuery = GetGlobalToolsConfigQuery = {}));
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetToolsWithConfigsQuery = void 0;
|
|
4
|
+
const command_response_schema_1 = require("../../common/models/command-response.schema");
|
|
5
|
+
const models_1 = require("../models");
|
|
6
|
+
var GetToolsWithConfigsQuery;
|
|
7
|
+
(function (GetToolsWithConfigsQuery) {
|
|
8
|
+
GetToolsWithConfigsQuery.ResponseSchema = (0, command_response_schema_1.ICommandResponseSchema)(models_1.ToolsWithConfigsSchema);
|
|
9
|
+
})(GetToolsWithConfigsQuery || (exports.GetToolsWithConfigsQuery = GetToolsWithConfigsQuery = {}));
|
|
@@ -15,3 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./find-all-tools.query"), exports);
|
|
18
|
+
__exportStar(require("./get-global-tools-config.query"), exports);
|
|
19
|
+
__exportStar(require("./get-tools-with-configs.query"), exports);
|
|
@@ -4,4 +4,5 @@ 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";
|
|
7
8
|
})(VIDEO_PRICING_RULE_TYPE || (exports.VIDEO_PRICING_RULE_TYPE = VIDEO_PRICING_RULE_TYPE = {}));
|
|
@@ -9,4 +9,5 @@ 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";
|
|
12
13
|
})(VIDEO_GENERATION_STRATEGY || (exports.VIDEO_GENERATION_STRATEGY = VIDEO_GENERATION_STRATEGY = {}));
|
|
@@ -18,15 +18,22 @@ 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(),
|
|
21
26
|
});
|
|
22
27
|
exports.VideoGenerationRequestParamsSchema = zod_1.z.object({
|
|
23
28
|
imageUrls: zod_1.z.string().array().optional(),
|
|
24
29
|
duration: zod_1.z.number(),
|
|
25
30
|
aspectRatio: zod_1.z.string().optional(),
|
|
26
31
|
quality: zod_1.z.string().optional(),
|
|
32
|
+
resolution: zod_1.z.string().optional(),
|
|
27
33
|
});
|
|
28
34
|
exports.VideoModelPricingRuleConditionSchema = zod_1.z.object({
|
|
29
|
-
aspectRatio: zod_1.z.string(),
|
|
35
|
+
aspectRatio: zod_1.z.string().optional(),
|
|
36
|
+
resolution: zod_1.z.string().optional(),
|
|
30
37
|
});
|
|
31
38
|
exports.VideoModelPricingRulesSchema = zod_1.z.array(zod_1.z.object({
|
|
32
39
|
type: zod_1.z.nativeEnum(enums_1.VIDEO_PRICING_RULE_TYPE),
|
|
@@ -17,7 +17,11 @@ function matchesCondition(condition, params) {
|
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
19
|
function calculateVideoGenerationPrice({ pricePerSecond, params, rules, }) {
|
|
20
|
-
const
|
|
20
|
+
const perSecondRule = rules
|
|
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;
|
|
21
25
|
const flatMarkup = rules.reduce((sum, r) => {
|
|
22
26
|
if (r.type !== enums_1.VIDEO_PRICING_RULE_TYPE.FLAT) {
|
|
23
27
|
return sum;
|
package/common/errors/errors.ts
CHANGED
|
@@ -9,6 +9,11 @@ export const ERRORS = {
|
|
|
9
9
|
message: 'Произошла ошибка при поиске инструмента',
|
|
10
10
|
httpCode: 500,
|
|
11
11
|
},
|
|
12
|
+
GET_GLOBAL_TOOLS_CONFIG_ERROR: {
|
|
13
|
+
code: 'TOOL.GET_GLOBAL_TOOLS_CONFIG_ERROR',
|
|
14
|
+
message: 'Произошла ошибка при получении глобальных конфигураций инструментов',
|
|
15
|
+
httpCode: 500,
|
|
16
|
+
},
|
|
12
17
|
},
|
|
13
18
|
|
|
14
19
|
// PARAPHRASE
|
|
@@ -572,6 +577,11 @@ export const ERRORS = {
|
|
|
572
577
|
message: 'Некорректное соотношение сторон',
|
|
573
578
|
httpCode: 400,
|
|
574
579
|
},
|
|
580
|
+
INVALID_RESOLUTION: {
|
|
581
|
+
code: 'VIDEO.INVALID_RESOLUTION',
|
|
582
|
+
message: 'Некорректное разрешение видео',
|
|
583
|
+
httpCode: 400,
|
|
584
|
+
},
|
|
575
585
|
RUNWAY_CONTENT_POLICY: {
|
|
576
586
|
code: 'VIDEO.RUNWAY_CONTENT_POLICY',
|
|
577
587
|
message:
|
package/package.json
CHANGED
package/tools/enums/index.ts
CHANGED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { TOOL_CONTENT_TYPE } from '../enums';
|
|
3
|
+
import { VideoConfigSchema } from '../../video';
|
|
4
|
+
import { MusicConfigSchema } from '../../music';
|
|
5
|
+
import { WriterConfigSchema } from '../../writer';
|
|
6
|
+
import { ImageEditorConfigSchema } from '../../image-editor';
|
|
7
|
+
import { ParaphraseToolConfigSchema } from '../../paraphrase';
|
|
8
|
+
import { PresentationConfigSchema } from '../../presentation';
|
|
9
|
+
import { VideoEditorConfigSchema } from '../../video-editor';
|
|
10
|
+
import { TTSConfigSchema } from '../../tts';
|
|
11
|
+
import { STTConfigSchema } from '../../stt';
|
|
12
|
+
|
|
13
|
+
export const GlobalToolsConfigSchema = z.object({
|
|
14
|
+
[TOOL_CONTENT_TYPE.VIDEO]: VideoConfigSchema,
|
|
15
|
+
[TOOL_CONTENT_TYPE.MUSIC]: MusicConfigSchema,
|
|
16
|
+
[TOOL_CONTENT_TYPE.WRITER]: WriterConfigSchema,
|
|
17
|
+
[TOOL_CONTENT_TYPE.IMAGE_EDITOR]: ImageEditorConfigSchema,
|
|
18
|
+
[TOOL_CONTENT_TYPE.REPHRASE]: ParaphraseToolConfigSchema,
|
|
19
|
+
[TOOL_CONTENT_TYPE.PRESENTATION]: PresentationConfigSchema,
|
|
20
|
+
[TOOL_CONTENT_TYPE.VIDEO_EDITOR]: VideoEditorConfigSchema,
|
|
21
|
+
[TOOL_CONTENT_TYPE.TEXT_TO_SPEECH]: TTSConfigSchema,
|
|
22
|
+
[TOOL_CONTENT_TYPE.SPEECH_TO_TEXT]: STTConfigSchema,
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export type GlobalToolsConfig = z.infer<typeof GlobalToolsConfigSchema>;
|
package/tools/models/index.ts
CHANGED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { TOOL_CONTENT_TYPE } from '../enums';
|
|
3
|
+
import { VideoConfigSchema } from '../../video';
|
|
4
|
+
import { MusicConfigSchema } from '../../music';
|
|
5
|
+
import { WriterConfigSchema } from '../../writer';
|
|
6
|
+
import { ImageEditorConfigSchema } from '../../image-editor';
|
|
7
|
+
import { ParaphraseToolConfigSchema } from '../../paraphrase';
|
|
8
|
+
import { PresentationConfigSchema } from '../../presentation';
|
|
9
|
+
import { VideoEditorConfigSchema } from '../../video-editor';
|
|
10
|
+
import { TTSConfigSchema } from '../../tts';
|
|
11
|
+
import { STTConfigSchema } from '../../stt';
|
|
12
|
+
import { ToolSchema } from './tool.schema';
|
|
13
|
+
|
|
14
|
+
// Discriminated union array: Tools with their configs
|
|
15
|
+
export const ToolWithConfigSchema = z.discriminatedUnion('contentType', [
|
|
16
|
+
ToolSchema.merge(
|
|
17
|
+
z.object({
|
|
18
|
+
contentType: z.literal(TOOL_CONTENT_TYPE.VIDEO),
|
|
19
|
+
config: VideoConfigSchema,
|
|
20
|
+
}),
|
|
21
|
+
),
|
|
22
|
+
ToolSchema.merge(
|
|
23
|
+
z.object({
|
|
24
|
+
contentType: z.literal(TOOL_CONTENT_TYPE.MUSIC),
|
|
25
|
+
config: MusicConfigSchema,
|
|
26
|
+
}),
|
|
27
|
+
),
|
|
28
|
+
ToolSchema.merge(
|
|
29
|
+
z.object({
|
|
30
|
+
contentType: z.literal(TOOL_CONTENT_TYPE.WRITER),
|
|
31
|
+
config: WriterConfigSchema,
|
|
32
|
+
}),
|
|
33
|
+
),
|
|
34
|
+
ToolSchema.merge(
|
|
35
|
+
z.object({
|
|
36
|
+
contentType: z.literal(TOOL_CONTENT_TYPE.IMAGE_EDITOR),
|
|
37
|
+
config: ImageEditorConfigSchema,
|
|
38
|
+
}),
|
|
39
|
+
),
|
|
40
|
+
ToolSchema.merge(
|
|
41
|
+
z.object({
|
|
42
|
+
contentType: z.literal(TOOL_CONTENT_TYPE.REPHRASE),
|
|
43
|
+
config: ParaphraseToolConfigSchema,
|
|
44
|
+
}),
|
|
45
|
+
),
|
|
46
|
+
ToolSchema.merge(
|
|
47
|
+
z.object({
|
|
48
|
+
contentType: z.literal(TOOL_CONTENT_TYPE.PRESENTATION),
|
|
49
|
+
config: PresentationConfigSchema,
|
|
50
|
+
}),
|
|
51
|
+
),
|
|
52
|
+
ToolSchema.merge(
|
|
53
|
+
z.object({
|
|
54
|
+
contentType: z.literal(TOOL_CONTENT_TYPE.VIDEO_EDITOR),
|
|
55
|
+
config: VideoEditorConfigSchema,
|
|
56
|
+
}),
|
|
57
|
+
),
|
|
58
|
+
ToolSchema.merge(
|
|
59
|
+
z.object({
|
|
60
|
+
contentType: z.literal(TOOL_CONTENT_TYPE.TEXT_TO_SPEECH),
|
|
61
|
+
config: TTSConfigSchema,
|
|
62
|
+
}),
|
|
63
|
+
),
|
|
64
|
+
ToolSchema.merge(
|
|
65
|
+
z.object({
|
|
66
|
+
contentType: z.literal(TOOL_CONTENT_TYPE.SPEECH_TO_TEXT),
|
|
67
|
+
config: STTConfigSchema,
|
|
68
|
+
}),
|
|
69
|
+
),
|
|
70
|
+
]);
|
|
71
|
+
|
|
72
|
+
export type ToolWithConfig = z.infer<typeof ToolWithConfigSchema>;
|
|
73
|
+
|
|
74
|
+
export const ToolsWithConfigsSchema = z.array(ToolWithConfigSchema);
|
|
75
|
+
export type ToolsWithConfigs = z.infer<typeof ToolsWithConfigsSchema>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ICommandResponseSchema } from '../../common/models/command-response.schema';
|
|
3
|
+
import { GlobalToolsConfigSchema } from '../models';
|
|
4
|
+
|
|
5
|
+
export namespace GetGlobalToolsConfigQuery {
|
|
6
|
+
export const ResponseSchema = ICommandResponseSchema(GlobalToolsConfigSchema);
|
|
7
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ICommandResponseSchema } from '../../common/models/command-response.schema';
|
|
3
|
+
import { ToolsWithConfigsSchema } from '../models';
|
|
4
|
+
|
|
5
|
+
export namespace GetToolsWithConfigsQuery {
|
|
6
|
+
export const ResponseSchema = ICommandResponseSchema(ToolsWithConfigsSchema);
|
|
7
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
8
|
+
}
|
package/tools/queries/index.ts
CHANGED
|
@@ -5,4 +5,5 @@ 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',
|
|
8
9
|
}
|
|
@@ -20,6 +20,11 @@ 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(),
|
|
23
28
|
});
|
|
24
29
|
|
|
25
30
|
export type VideoModelParams = z.infer<typeof VideoModelParamsSchema>;
|
|
@@ -29,11 +34,13 @@ export const VideoGenerationRequestParamsSchema = z.object({
|
|
|
29
34
|
duration: z.number(),
|
|
30
35
|
aspectRatio: z.string().optional(),
|
|
31
36
|
quality: z.string().optional(),
|
|
37
|
+
resolution: z.string().optional(),
|
|
32
38
|
});
|
|
33
39
|
export type VideoGenerationRequestParams = z.infer<typeof VideoGenerationRequestParamsSchema>;
|
|
34
40
|
|
|
35
41
|
export const VideoModelPricingRuleConditionSchema = z.object({
|
|
36
|
-
aspectRatio: z.string(),
|
|
42
|
+
aspectRatio: z.string().optional(),
|
|
43
|
+
resolution: z.string().optional(),
|
|
37
44
|
});
|
|
38
45
|
export type VideoModelPricingRuleCondition = z.infer<typeof VideoModelPricingRuleConditionSchema>;
|
|
39
46
|
|
|
@@ -36,7 +36,13 @@ export function calculateVideoGenerationPrice({
|
|
|
36
36
|
params: VideoGenerationRequestParams;
|
|
37
37
|
rules: VideoModelPricingRules;
|
|
38
38
|
}) {
|
|
39
|
-
const
|
|
39
|
+
const perSecondRule = rules
|
|
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;
|
|
40
46
|
|
|
41
47
|
const flatMarkup = rules.reduce((sum, r) => {
|
|
42
48
|
if (r.type !== VIDEO_PRICING_RULE_TYPE.FLAT) {
|
|
@@ -11,6 +11,6 @@ var TOOL_CONTENT_TYPE;
|
|
|
11
11
|
TOOL_CONTENT_TYPE["PRESENTATION"] = "PRESENTATION";
|
|
12
12
|
TOOL_CONTENT_TYPE["WRITER"] = "WRITER";
|
|
13
13
|
TOOL_CONTENT_TYPE["VIDEO_EDITOR"] = "VIDEO_EDITOR";
|
|
14
|
-
TOOL_CONTENT_TYPE["NONE"] = "NONE";
|
|
15
14
|
TOOL_CONTENT_TYPE["MUSIC"] = "MUSIC";
|
|
15
|
+
TOOL_CONTENT_TYPE["NONE"] = "NONE";
|
|
16
16
|
})(TOOL_CONTENT_TYPE || (exports.TOOL_CONTENT_TYPE = TOOL_CONTENT_TYPE = {}));
|