vidspotai-shared 1.0.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/lib/globals/aiModels.d.ts +60 -0
- package/lib/globals/aiModels.d.ts.map +1 -0
- package/lib/globals/aiModels.js +463 -0
- package/lib/globals/config.d.ts +4 -0
- package/lib/globals/config.d.ts.map +1 -0
- package/lib/globals/config.js +20 -0
- package/lib/globals/index.d.ts +6 -0
- package/lib/globals/index.d.ts.map +1 -0
- package/lib/globals/index.js +21 -0
- package/lib/globals/plans.d.ts +3 -0
- package/lib/globals/plans.d.ts.map +1 -0
- package/lib/globals/plans.js +60 -0
- package/lib/globals/schemas.d.ts +3 -0
- package/lib/globals/schemas.d.ts.map +1 -0
- package/lib/globals/schemas.js +18 -0
- package/lib/globals/types.d.ts +90 -0
- package/lib/globals/types.d.ts.map +1 -0
- package/lib/globals/types.js +93 -0
- package/lib/index.d.ts +6 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +21 -0
- package/lib/libs/firebase.d.ts +7 -0
- package/lib/libs/firebase.d.ts.map +1 -0
- package/lib/libs/firebase.js +60 -0
- package/lib/libs/index.d.ts +2 -0
- package/lib/libs/index.d.ts.map +1 -0
- package/lib/libs/index.js +17 -0
- package/lib/models/index.d.ts +4 -0
- package/lib/models/index.d.ts.map +1 -0
- package/lib/models/index.js +19 -0
- package/lib/models/script.model.d.ts +39 -0
- package/lib/models/script.model.d.ts.map +1 -0
- package/lib/models/script.model.js +26 -0
- package/lib/models/user.model.d.ts +46 -0
- package/lib/models/user.model.d.ts.map +1 -0
- package/lib/models/user.model.js +2 -0
- package/lib/models/video.model.d.ts +43 -0
- package/lib/models/video.model.d.ts.map +1 -0
- package/lib/models/video.model.js +2 -0
- package/lib/services/aiGen/aiGenFactory.service.d.ts +8 -0
- package/lib/services/aiGen/aiGenFactory.service.d.ts.map +1 -0
- package/lib/services/aiGen/aiGenFactory.service.js +56 -0
- package/lib/services/aiGen/atypes.d.ts +5 -0
- package/lib/services/aiGen/atypes.d.ts.map +1 -0
- package/lib/services/aiGen/atypes.js +8 -0
- package/lib/services/aiGen/helpers.d.ts +3 -0
- package/lib/services/aiGen/helpers.d.ts.map +1 -0
- package/lib/services/aiGen/helpers.js +76 -0
- package/lib/services/aiGen/index.d.ts +5 -0
- package/lib/services/aiGen/index.d.ts.map +1 -0
- package/lib/services/aiGen/index.js +20 -0
- package/lib/services/aiGen/providers/alibaba/alibaba.d.ts +12 -0
- package/lib/services/aiGen/providers/alibaba/alibaba.d.ts.map +1 -0
- package/lib/services/aiGen/providers/alibaba/alibaba.js +146 -0
- package/lib/services/aiGen/providers/alibaba/helpers.d.ts +3 -0
- package/lib/services/aiGen/providers/alibaba/helpers.d.ts.map +1 -0
- package/lib/services/aiGen/providers/alibaba/helpers.js +31 -0
- package/lib/services/aiGen/providers/azure/azure.d.ts +1 -0
- package/lib/services/aiGen/providers/azure/azure.d.ts.map +1 -0
- package/lib/services/aiGen/providers/azure/azure.js +1 -0
- package/lib/services/aiGen/providers/azure/azure.service.d.ts +14 -0
- package/lib/services/aiGen/providers/azure/azure.service.d.ts.map +1 -0
- package/lib/services/aiGen/providers/azure/azure.service.js +125 -0
- package/lib/services/aiGen/providers/azure/index.d.ts +2 -0
- package/lib/services/aiGen/providers/azure/index.d.ts.map +1 -0
- package/lib/services/aiGen/providers/azure/index.js +17 -0
- package/lib/services/aiGen/providers/baseAiGenProvider.service.d.ts +8 -0
- package/lib/services/aiGen/providers/baseAiGenProvider.service.d.ts.map +1 -0
- package/lib/services/aiGen/providers/baseAiGenProvider.service.js +12 -0
- package/lib/services/aiGen/providers/google/google.service.d.ts +10 -0
- package/lib/services/aiGen/providers/google/google.service.d.ts.map +1 -0
- package/lib/services/aiGen/providers/google/google.service.js +96 -0
- package/lib/services/aiGen/providers/google/index.d.ts +2 -0
- package/lib/services/aiGen/providers/google/index.d.ts.map +1 -0
- package/lib/services/aiGen/providers/google/index.js +17 -0
- package/lib/services/aiGen/providers/index.d.ts +8 -0
- package/lib/services/aiGen/providers/index.d.ts.map +1 -0
- package/lib/services/aiGen/providers/index.js +23 -0
- package/lib/services/aiGen/providers/kling/btypes.d.ts +73 -0
- package/lib/services/aiGen/providers/kling/btypes.d.ts.map +1 -0
- package/lib/services/aiGen/providers/kling/btypes.js +2 -0
- package/lib/services/aiGen/providers/kling/index.d.ts +3 -0
- package/lib/services/aiGen/providers/kling/index.d.ts.map +1 -0
- package/lib/services/aiGen/providers/kling/index.js +18 -0
- package/lib/services/aiGen/providers/kling/kling.service.d.ts +13 -0
- package/lib/services/aiGen/providers/kling/kling.service.d.ts.map +1 -0
- package/lib/services/aiGen/providers/kling/kling.service.js +139 -0
- package/lib/services/aiGen/providers/kling/types.d.ts +73 -0
- package/lib/services/aiGen/providers/kling/types.d.ts.map +1 -0
- package/lib/services/aiGen/providers/kling/types.js +2 -0
- package/lib/services/aiGen/providers/minimax/ctypes.d.ts +26 -0
- package/lib/services/aiGen/providers/minimax/ctypes.d.ts.map +1 -0
- package/lib/services/aiGen/providers/minimax/ctypes.js +3 -0
- package/lib/services/aiGen/providers/minimax/index.d.ts +3 -0
- package/lib/services/aiGen/providers/minimax/index.d.ts.map +1 -0
- package/lib/services/aiGen/providers/minimax/index.js +18 -0
- package/lib/services/aiGen/providers/minimax/minimax.service.d.ts +12 -0
- package/lib/services/aiGen/providers/minimax/minimax.service.d.ts.map +1 -0
- package/lib/services/aiGen/providers/minimax/minimax.service.js +115 -0
- package/lib/services/aiGen/providers/minimax/types.d.ts +26 -0
- package/lib/services/aiGen/providers/minimax/types.d.ts.map +1 -0
- package/lib/services/aiGen/providers/minimax/types.js +3 -0
- package/lib/services/aiGen/providers/openai/index.d.ts +2 -0
- package/lib/services/aiGen/providers/openai/index.d.ts.map +1 -0
- package/lib/services/aiGen/providers/openai/index.js +17 -0
- package/lib/services/aiGen/providers/openai/openai.service.d.ts +12 -0
- package/lib/services/aiGen/providers/openai/openai.service.d.ts.map +1 -0
- package/lib/services/aiGen/providers/openai/openai.service.js +97 -0
- package/lib/services/aiGen/providers/runway/dtypes.d.ts +14 -0
- package/lib/services/aiGen/providers/runway/dtypes.d.ts.map +1 -0
- package/lib/services/aiGen/providers/runway/dtypes.js +27 -0
- package/lib/services/aiGen/providers/runway/index.d.ts +3 -0
- package/lib/services/aiGen/providers/runway/index.d.ts.map +1 -0
- package/lib/services/aiGen/providers/runway/index.js +18 -0
- package/lib/services/aiGen/providers/runway/runway.service.d.ts +12 -0
- package/lib/services/aiGen/providers/runway/runway.service.d.ts.map +1 -0
- package/lib/services/aiGen/providers/runway/runway.service.js +122 -0
- package/lib/services/aiGen/providers/runway/types.d.ts +14 -0
- package/lib/services/aiGen/providers/runway/types.d.ts.map +1 -0
- package/lib/services/aiGen/providers/runway/types.js +27 -0
- package/lib/services/aiGen/providers/types.d.ts +49 -0
- package/lib/services/aiGen/providers/types.d.ts.map +1 -0
- package/lib/services/aiGen/providers/types.js +2 -0
- package/lib/services/aiGen/types.d.ts +5 -0
- package/lib/services/aiGen/types.d.ts.map +1 -0
- package/lib/services/aiGen/types.js +8 -0
- package/lib/services/firestore.service.d.ts +66 -0
- package/lib/services/firestore.service.d.ts.map +1 -0
- package/lib/services/firestore.service.js +118 -0
- package/lib/services/index.d.ts +4 -0
- package/lib/services/index.d.ts.map +1 -0
- package/lib/services/index.js +19 -0
- package/lib/services/redis.service.d.ts +19 -0
- package/lib/services/redis.service.d.ts.map +1 -0
- package/lib/services/redis.service.js +97 -0
- package/lib/utils/helpers.d.ts +6 -0
- package/lib/utils/helpers.d.ts.map +1 -0
- package/lib/utils/helpers.js +55 -0
- package/lib/utils/index.d.ts +2 -0
- package/lib/utils/index.d.ts.map +1 -0
- package/lib/utils/index.js +17 -0
- package/package.json +31 -0
|
@@ -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("./google.service"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/services/aiGen/providers/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,6BAA6B,CAAC;AAC5C,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
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("./types"), exports);
|
|
18
|
+
__exportStar(require("./baseAiGenProvider.service"), exports);
|
|
19
|
+
__exportStar(require("./google"), exports);
|
|
20
|
+
__exportStar(require("./openai"), exports);
|
|
21
|
+
__exportStar(require("./kling"), exports);
|
|
22
|
+
__exportStar(require("./runway"), exports);
|
|
23
|
+
__exportStar(require("./minimax"), exports);
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { EVideoMode } from "../../types";
|
|
2
|
+
export interface KlingVideoGenerateResponse {
|
|
3
|
+
code: number;
|
|
4
|
+
message: string;
|
|
5
|
+
request_id: string;
|
|
6
|
+
data: VideoTaskData;
|
|
7
|
+
}
|
|
8
|
+
export interface VideoTaskData {
|
|
9
|
+
task_id: string;
|
|
10
|
+
task_status: "submitted" | "processing" | "succeed" | "failed";
|
|
11
|
+
task_info: TaskInfo;
|
|
12
|
+
created_at: number;
|
|
13
|
+
updated_at: number;
|
|
14
|
+
}
|
|
15
|
+
export interface TaskInfo {
|
|
16
|
+
external_task_id: string;
|
|
17
|
+
}
|
|
18
|
+
export type KlingModelName = "kling-v1" | "kling-v1-6" | "kling-v2-master" | "kling-v2-1-master";
|
|
19
|
+
export type CameraType = "simple" | "down_back" | "forward_up" | "right_turn_forward" | "left_turn_forward";
|
|
20
|
+
export type KlingAspectRatio = "16:9" | "9:16" | "1:1";
|
|
21
|
+
export type KlingDuration = 5 | 10;
|
|
22
|
+
export interface CameraConfig {
|
|
23
|
+
horizontal?: number;
|
|
24
|
+
vertical?: number;
|
|
25
|
+
pan?: number;
|
|
26
|
+
tilt?: number;
|
|
27
|
+
roll?: number;
|
|
28
|
+
zoom?: number;
|
|
29
|
+
}
|
|
30
|
+
export interface CameraControl {
|
|
31
|
+
type?: CameraType;
|
|
32
|
+
config?: CameraConfig;
|
|
33
|
+
}
|
|
34
|
+
export interface KlingVideoGenerateRequest {
|
|
35
|
+
model_name?: KlingModelName;
|
|
36
|
+
prompt: string;
|
|
37
|
+
negative_prompt?: string | null;
|
|
38
|
+
cfg_scale?: number;
|
|
39
|
+
mode?: EVideoMode;
|
|
40
|
+
camera_control?: CameraControl;
|
|
41
|
+
aspect_ratio?: KlingAspectRatio;
|
|
42
|
+
duration?: KlingDuration;
|
|
43
|
+
callback_url?: string;
|
|
44
|
+
external_task_id?: string;
|
|
45
|
+
}
|
|
46
|
+
export interface KlingTaskResponse {
|
|
47
|
+
code: number;
|
|
48
|
+
message: string;
|
|
49
|
+
request_id: string;
|
|
50
|
+
data: QueryTaskData;
|
|
51
|
+
}
|
|
52
|
+
export interface QueryTaskData {
|
|
53
|
+
task_id: string;
|
|
54
|
+
task_status: TaskStatus;
|
|
55
|
+
task_status_msg: string;
|
|
56
|
+
task_info: TaskInfo;
|
|
57
|
+
created_at: number;
|
|
58
|
+
updated_at: number;
|
|
59
|
+
task_result?: TaskResult;
|
|
60
|
+
}
|
|
61
|
+
export type TaskStatus = "submitted" | "processing" | "succeed" | "failed";
|
|
62
|
+
export interface TaskInfo {
|
|
63
|
+
external_task_id: string;
|
|
64
|
+
}
|
|
65
|
+
export interface TaskResult {
|
|
66
|
+
videos: VideoResult[];
|
|
67
|
+
}
|
|
68
|
+
export interface VideoResult {
|
|
69
|
+
id: string;
|
|
70
|
+
url: string;
|
|
71
|
+
duration: string;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=btypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"btypes.d.ts","sourceRoot":"","sources":["../../../../../src/services/aiGen/providers/kling/btypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,MAAM,WAAW,0BAA0B;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,aAAa,CAAC;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,WAAW,GAAG,YAAY,GAAG,SAAS,GAAG,QAAQ,CAAC;IAC/D,SAAS,EAAE,QAAQ,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,QAAQ;IACvB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,MAAM,cAAc,GACtB,UAAU,GACV,YAAY,GACZ,iBAAiB,GACjB,mBAAmB,CAAC;AAExB,MAAM,MAAM,UAAU,GAClB,QAAQ,GACR,WAAW,GACX,YAAY,GACZ,oBAAoB,GACpB,mBAAmB,CAAC;AAExB,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC;AAEvD,MAAM,MAAM,aAAa,GAAG,CAAC,GAAG,EAAE,CAAC;AAEnC,MAAM,WAAW,YAAY;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB;AAED,MAAM,WAAW,yBAAyB;IACxC,UAAU,CAAC,EAAE,cAAc,CAAC;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,cAAc,CAAC,EAAE,aAAa,CAAC;IAC/B,YAAY,CAAC,EAAE,gBAAgB,CAAC;IAChC,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAGD,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,aAAa,CAAC;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,UAAU,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,QAAQ,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,UAAU,CAAC;CAC1B;AAED,MAAM,MAAM,UAAU,GAAG,WAAW,GAAG,YAAY,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE3E,MAAM,WAAW,QAAQ;IACvB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,WAAW,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;CAClB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/services/aiGen/providers/kling/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC"}
|
|
@@ -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("./kling.service"), exports);
|
|
18
|
+
__exportStar(require("./types"), exports);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BaseAiGenProviderService } from "../baseAiGenProvider.service";
|
|
2
|
+
import { CreditUsageParams, VideoGenerationParams, VideoGenerationResult, VideoStatusParams, VideoStatusResult } from "../types";
|
|
3
|
+
export declare class KlingService extends BaseAiGenProviderService {
|
|
4
|
+
private readonly baseUrl;
|
|
5
|
+
private readonly timeout;
|
|
6
|
+
constructor();
|
|
7
|
+
private request;
|
|
8
|
+
generateVideo(params: VideoGenerationParams): Promise<VideoGenerationResult>;
|
|
9
|
+
checkVideoStatus({ task, outputFilename, outputFilePath, }: VideoStatusParams): Promise<VideoStatusResult | null>;
|
|
10
|
+
encodeJwtToken(): string;
|
|
11
|
+
getCreditUsed({ modelKey, mode, duration, }: CreditUsageParams): number;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=kling.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kling.service.d.ts","sourceRoot":"","sources":["../../../../../src/services/aiGen/providers/kling/kling.service.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,UAAU,CAAC;AAWlB,qBAAa,YAAa,SAAQ,wBAAwB;IACxD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAuC;IAC/D,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;;YAWnB,OAAO;IAgCf,aAAa,CACjB,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,qBAAqB,CAAC;IAkC3B,gBAAgB,CAAC,EACrB,IAAI,EACJ,cAAc,EACd,cAAyB,GAC1B,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC;IA8DxD,cAAc,IAAI,MAAM;IAexB,aAAa,CAAC,EACZ,QAAQ,EACR,IAA8B,EAC9B,QAAY,GACb,EAAE,iBAAiB,GAAG,MAAM;CAM9B"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// kling.service.ts
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.KlingService = void 0;
|
|
8
|
+
const axios_1 = __importDefault(require("axios"));
|
|
9
|
+
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
10
|
+
const aiModels_1 = require("../../../../globals/aiModels");
|
|
11
|
+
const types_1 = require("../../../../globals/types");
|
|
12
|
+
const firebase_1 = require("../../../../libs/firebase");
|
|
13
|
+
const helpers_1 = require("../../helpers");
|
|
14
|
+
const types_2 = require("../../types");
|
|
15
|
+
const baseAiGenProvider_service_1 = require("../baseAiGenProvider.service");
|
|
16
|
+
const helpers_2 = require("../../../../utils/helpers");
|
|
17
|
+
class KlingService extends baseAiGenProvider_service_1.BaseAiGenProviderService {
|
|
18
|
+
constructor() {
|
|
19
|
+
super();
|
|
20
|
+
this.baseUrl = "https://api-singapore.klingai.com";
|
|
21
|
+
this.timeout = 60000; // 1 min
|
|
22
|
+
if (!process.env.KLING_SECRET_KEY || !process.env.KLING_ACCESS_KEY) {
|
|
23
|
+
throw new Error("Missing KLING_SECRET_KEY or KLING_ACCESS_KEY in environment variables");
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
async request(endpoint, method, body) {
|
|
27
|
+
const config = {
|
|
28
|
+
method,
|
|
29
|
+
url: `${this.baseUrl}${endpoint}`,
|
|
30
|
+
headers: {
|
|
31
|
+
Authorization: `Bearer ${this.encodeJwtToken()}`,
|
|
32
|
+
"Content-Type": "application/json",
|
|
33
|
+
},
|
|
34
|
+
timeout: this.timeout,
|
|
35
|
+
data: body,
|
|
36
|
+
};
|
|
37
|
+
try {
|
|
38
|
+
const res = await axios_1.default.request(config);
|
|
39
|
+
return res.data;
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
console.error("Error at Endpoint:", endpoint);
|
|
43
|
+
if (err.response) {
|
|
44
|
+
console.error("Kling API error:", err.response.data);
|
|
45
|
+
}
|
|
46
|
+
else if (err.request) {
|
|
47
|
+
console.error("Kling API request error:", err.message);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
console.error("Unexpected error:", err.message);
|
|
51
|
+
}
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
async generateVideo(params) {
|
|
56
|
+
(0, helpers_1.validateParams)(params);
|
|
57
|
+
const modelId = aiModels_1.aiModelConfigs[params.modelKey]?.modelId;
|
|
58
|
+
if (!modelId)
|
|
59
|
+
throw new Error(`Unknown modelKey: ${params.modelKey}`);
|
|
60
|
+
const request = {
|
|
61
|
+
model_name: modelId,
|
|
62
|
+
prompt: params.prompt,
|
|
63
|
+
aspect_ratio: params.aspectRatio || "16:9",
|
|
64
|
+
duration: params.duration || 5,
|
|
65
|
+
mode: params.mode || types_2.EVideoMode.STANDARD,
|
|
66
|
+
};
|
|
67
|
+
const starttime = Date.now();
|
|
68
|
+
const task = await this.request("/v1/videos/text2video", "POST", request);
|
|
69
|
+
console.log(`Kling generateVideo API call took ${Date.now() - starttime} ms`, task ? `(task ID: ${task.data.task_id})` : "(failed)");
|
|
70
|
+
if (!task) {
|
|
71
|
+
return { status: types_1.EVideoJobStatus.FAILED };
|
|
72
|
+
}
|
|
73
|
+
return { task: task.data.task_id, status: types_1.EVideoJobStatus.TRIGGERED };
|
|
74
|
+
}
|
|
75
|
+
async checkVideoStatus({ task, outputFilename, outputFilePath = "videos", }) {
|
|
76
|
+
const startTime = Date.now();
|
|
77
|
+
const result = await this.request(`/v1/videos/text2video/${task}`, "GET");
|
|
78
|
+
console.log(`Kling checkVideoStatus API call took ${Date.now() - startTime} ms`);
|
|
79
|
+
if (!result) {
|
|
80
|
+
return {
|
|
81
|
+
status: types_1.EVideoJobStatus.FAILED,
|
|
82
|
+
errorMessage: "No response from Kling API",
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
if (result.data.task_status === "succeed") {
|
|
86
|
+
const videoUrl = result.data.task_result?.videos?.[0]?.url;
|
|
87
|
+
if (!videoUrl) {
|
|
88
|
+
return {
|
|
89
|
+
status: types_1.EVideoJobStatus.FAILED,
|
|
90
|
+
errorMessage: "No video URL in response",
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
console.log("Kling video URL:", videoUrl);
|
|
94
|
+
const filePath = `${outputFilePath}/${outputFilename}.mp4`;
|
|
95
|
+
const file = (0, firebase_1.getBucket)().file(filePath);
|
|
96
|
+
// Download video using axios
|
|
97
|
+
const videoResp = await axios_1.default.get(videoUrl, {
|
|
98
|
+
responseType: "arraybuffer",
|
|
99
|
+
timeout: this.timeout,
|
|
100
|
+
});
|
|
101
|
+
const buffer = Buffer.from(videoResp.data);
|
|
102
|
+
await file.save(buffer, { contentType: "video/mp4" });
|
|
103
|
+
const [signedUrl] = await file.getSignedUrl({
|
|
104
|
+
action: "read",
|
|
105
|
+
expires: "03-09-2491",
|
|
106
|
+
});
|
|
107
|
+
return {
|
|
108
|
+
videoUrl: signedUrl,
|
|
109
|
+
status: types_1.EVideoJobStatus.COMPLETED,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
if (result.data.task_status === "failed") {
|
|
113
|
+
return {
|
|
114
|
+
status: types_1.EVideoJobStatus.FAILED,
|
|
115
|
+
errorMessage: `${result.code}: ${result.message}`,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
return { status: types_1.EVideoJobStatus.PENDING };
|
|
119
|
+
}
|
|
120
|
+
encodeJwtToken() {
|
|
121
|
+
const payload = {
|
|
122
|
+
iss: process.env.KLING_ACCESS_KEY,
|
|
123
|
+
exp: Math.floor(Date.now() / 1000) + 1800, // +30 mins
|
|
124
|
+
nbf: Math.floor(Date.now() / 1000) - 5, // -5s
|
|
125
|
+
};
|
|
126
|
+
const options = {
|
|
127
|
+
algorithm: "HS256",
|
|
128
|
+
header: { alg: "HS256", typ: "JWT" },
|
|
129
|
+
};
|
|
130
|
+
return jsonwebtoken_1.default.sign(payload, process.env.KLING_SECRET_KEY, options);
|
|
131
|
+
}
|
|
132
|
+
getCreditUsed({ modelKey, mode = types_2.EVideoMode.PROFESSIONAL, duration = 5, }) {
|
|
133
|
+
const modelConfig = aiModels_1.aiModelConfigs[modelKey];
|
|
134
|
+
return modelConfig.cost?.fixed
|
|
135
|
+
? (0, helpers_2.getCreditsFromCost)(modelConfig?.cost?.table?.[mode]?.[duration])
|
|
136
|
+
: 0;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
exports.KlingService = KlingService;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { EVideoMode } from "../../types";
|
|
2
|
+
export interface KlingVideoGenerateResponse {
|
|
3
|
+
code: number;
|
|
4
|
+
message: string;
|
|
5
|
+
request_id: string;
|
|
6
|
+
data: VideoTaskData;
|
|
7
|
+
}
|
|
8
|
+
export interface VideoTaskData {
|
|
9
|
+
task_id: string;
|
|
10
|
+
task_status: "submitted" | "processing" | "succeed" | "failed";
|
|
11
|
+
task_info: TaskInfo;
|
|
12
|
+
created_at: number;
|
|
13
|
+
updated_at: number;
|
|
14
|
+
}
|
|
15
|
+
export interface TaskInfo {
|
|
16
|
+
external_task_id: string;
|
|
17
|
+
}
|
|
18
|
+
export type KlingModelName = "kling-v1" | "kling-v1-6" | "kling-v2-master" | "kling-v2-1-master";
|
|
19
|
+
export type CameraType = "simple" | "down_back" | "forward_up" | "right_turn_forward" | "left_turn_forward";
|
|
20
|
+
export type KlingAspectRatio = "16:9" | "9:16" | "1:1";
|
|
21
|
+
export type KlingDuration = 5 | 10;
|
|
22
|
+
export interface CameraConfig {
|
|
23
|
+
horizontal?: number;
|
|
24
|
+
vertical?: number;
|
|
25
|
+
pan?: number;
|
|
26
|
+
tilt?: number;
|
|
27
|
+
roll?: number;
|
|
28
|
+
zoom?: number;
|
|
29
|
+
}
|
|
30
|
+
export interface CameraControl {
|
|
31
|
+
type?: CameraType;
|
|
32
|
+
config?: CameraConfig;
|
|
33
|
+
}
|
|
34
|
+
export interface KlingVideoGenerateRequest {
|
|
35
|
+
model_name?: KlingModelName;
|
|
36
|
+
prompt: string;
|
|
37
|
+
negative_prompt?: string | null;
|
|
38
|
+
cfg_scale?: number;
|
|
39
|
+
mode?: EVideoMode;
|
|
40
|
+
camera_control?: CameraControl;
|
|
41
|
+
aspect_ratio?: KlingAspectRatio;
|
|
42
|
+
duration?: KlingDuration;
|
|
43
|
+
callback_url?: string;
|
|
44
|
+
external_task_id?: string;
|
|
45
|
+
}
|
|
46
|
+
export interface KlingTaskResponse {
|
|
47
|
+
code: number;
|
|
48
|
+
message: string;
|
|
49
|
+
request_id: string;
|
|
50
|
+
data: QueryTaskData;
|
|
51
|
+
}
|
|
52
|
+
export interface QueryTaskData {
|
|
53
|
+
task_id: string;
|
|
54
|
+
task_status: TaskStatus;
|
|
55
|
+
task_status_msg: string;
|
|
56
|
+
task_info: TaskInfo;
|
|
57
|
+
created_at: number;
|
|
58
|
+
updated_at: number;
|
|
59
|
+
task_result?: TaskResult;
|
|
60
|
+
}
|
|
61
|
+
export type TaskStatus = "submitted" | "processing" | "succeed" | "failed";
|
|
62
|
+
export interface TaskInfo {
|
|
63
|
+
external_task_id: string;
|
|
64
|
+
}
|
|
65
|
+
export interface TaskResult {
|
|
66
|
+
videos: VideoResult[];
|
|
67
|
+
}
|
|
68
|
+
export interface VideoResult {
|
|
69
|
+
id: string;
|
|
70
|
+
url: string;
|
|
71
|
+
duration: string;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/services/aiGen/providers/kling/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,MAAM,WAAW,0BAA0B;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,aAAa,CAAC;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,WAAW,GAAG,YAAY,GAAG,SAAS,GAAG,QAAQ,CAAC;IAC/D,SAAS,EAAE,QAAQ,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,QAAQ;IACvB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,MAAM,cAAc,GACtB,UAAU,GACV,YAAY,GACZ,iBAAiB,GACjB,mBAAmB,CAAC;AAExB,MAAM,MAAM,UAAU,GAClB,QAAQ,GACR,WAAW,GACX,YAAY,GACZ,oBAAoB,GACpB,mBAAmB,CAAC;AAExB,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC;AAEvD,MAAM,MAAM,aAAa,GAAG,CAAC,GAAG,EAAE,CAAC;AAEnC,MAAM,WAAW,YAAY;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB;AAED,MAAM,WAAW,yBAAyB;IACxC,UAAU,CAAC,EAAE,cAAc,CAAC;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,cAAc,CAAC,EAAE,aAAa,CAAC;IAC/B,YAAY,CAAC,EAAE,gBAAgB,CAAC;IAChC,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAGD,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,aAAa,CAAC;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,UAAU,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,QAAQ,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,UAAU,CAAC;CAC1B;AAED,MAAM,MAAM,UAAU,GAAG,WAAW,GAAG,YAAY,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE3E,MAAM,WAAW,QAAQ;IACvB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,WAAW,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;CAClB"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type MinimaxModelName = "MiniMax-Hailuo-02" | "T2V-01-Director" | "T2V-01";
|
|
2
|
+
export interface MinimaxVideoGenerateRequest {
|
|
3
|
+
model: MinimaxModelName;
|
|
4
|
+
prompt: string;
|
|
5
|
+
resolution?: string;
|
|
6
|
+
duration?: number;
|
|
7
|
+
}
|
|
8
|
+
export interface MinimaxTaskResponse {
|
|
9
|
+
task_id: string;
|
|
10
|
+
status: "Preparing" | "Queueing" | "Processing" | "Success" | "Fail";
|
|
11
|
+
file_id?: string;
|
|
12
|
+
video_width?: number;
|
|
13
|
+
video_height?: number;
|
|
14
|
+
base_resp: {
|
|
15
|
+
status_code: 0 | 1002 | 1004 | 1026 | 1027;
|
|
16
|
+
status_msg: string;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export interface MinimaxVideoGenerateResponse {
|
|
20
|
+
task_id: string;
|
|
21
|
+
base_resp: {
|
|
22
|
+
status_code: 0 | 1002 | 1004 | 1008 | 1026 | 2013 | 2049;
|
|
23
|
+
status_msg: string;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=ctypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ctypes.d.ts","sourceRoot":"","sources":["../../../../../src/services/aiGen/providers/minimax/ctypes.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,gBAAgB,GACxB,mBAAmB,GACnB,iBAAiB,GACjB,QAAQ,CAAC;AAEb,MAAM,WAAW,2BAA2B;IAC1C,KAAK,EAAE,gBAAgB,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,WAAW,GAAG,UAAU,GAAG,YAAY,GAAG,SAAS,GAAG,MAAM,CAAC;IACrE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE;QACT,WAAW,EAAE,CAAC,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;QAC3C,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;CACH;AAED,MAAM,WAAW,4BAA4B;IAC3C,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE;QACT,WAAW,EAAE,CAAC,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;QACzD,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;CACH"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/services/aiGen/providers/minimax/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,mBAAmB,CAAC"}
|
|
@@ -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("./types"), exports);
|
|
18
|
+
__exportStar(require("./minimax.service"), exports);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BaseAiGenProviderService } from "../baseAiGenProvider.service";
|
|
2
|
+
import { CreditUsageParams, VideoGenerationParams, VideoGenerationResult, VideoStatusParams, VideoStatusResult } from "../types";
|
|
3
|
+
export declare class MinimaxService extends BaseAiGenProviderService {
|
|
4
|
+
private readonly baseUrl;
|
|
5
|
+
private readonly apiKey;
|
|
6
|
+
constructor();
|
|
7
|
+
private request;
|
|
8
|
+
generateVideo(params: VideoGenerationParams): Promise<VideoGenerationResult>;
|
|
9
|
+
checkVideoStatus({ task, outputFilename, outputFilePath, }: VideoStatusParams): Promise<VideoStatusResult | null>;
|
|
10
|
+
getCreditUsed({ modelKey, resolution, duration, }: CreditUsageParams): number;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=minimax.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"minimax.service.d.ts","sourceRoot":"","sources":["../../../../../src/services/aiGen/providers/minimax/minimax.service.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,UAAU,CAAC;AASlB,qBAAa,cAAe,SAAQ,wBAAwB;IAC1D,OAAO,CAAC,QAAQ,CAAC,OAAO,CACkC;IAE1D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;;YAUlB,OAAO;IAiCf,aAAa,CACjB,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,qBAAqB,CAAC;IAyB3B,gBAAgB,CAAC,EACrB,IAAI,EACJ,cAAc,EACd,cAAyB,GAC1B,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC;IAyExD,aAAa,CAAC,EACZ,QAAQ,EACR,UAAmB,EACnB,QAAY,GACb,EAAE,iBAAiB,GAAG,MAAM;CAO9B"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.MinimaxService = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const aiModels_1 = require("../../../../globals/aiModels");
|
|
9
|
+
const firebase_1 = require("../../../../libs/firebase");
|
|
10
|
+
const types_1 = require("../../../../globals/types");
|
|
11
|
+
const helpers_1 = require("../../helpers");
|
|
12
|
+
const baseAiGenProvider_service_1 = require("../baseAiGenProvider.service");
|
|
13
|
+
const helpers_2 = require("../../../../utils/helpers");
|
|
14
|
+
class MinimaxService extends baseAiGenProvider_service_1.BaseAiGenProviderService {
|
|
15
|
+
constructor() {
|
|
16
|
+
super();
|
|
17
|
+
this.baseUrl = process.env.MINIMAX_API_URL || "https://api.minimax.io";
|
|
18
|
+
if (!process.env.MINIMAX_ACCESS_KEY) {
|
|
19
|
+
throw new Error("Missing MINIMAX_ACCESS_KEY in environment variables");
|
|
20
|
+
}
|
|
21
|
+
this.apiKey = process.env.MINIMAX_ACCESS_KEY;
|
|
22
|
+
}
|
|
23
|
+
async request(endpoint, method, body, params) {
|
|
24
|
+
const url = `${this.baseUrl}${endpoint}`;
|
|
25
|
+
const config = {
|
|
26
|
+
method,
|
|
27
|
+
url,
|
|
28
|
+
headers: {
|
|
29
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
30
|
+
"Content-Type": "application/json",
|
|
31
|
+
},
|
|
32
|
+
params,
|
|
33
|
+
data: body,
|
|
34
|
+
timeout: 120000, // 2 minutes timeout
|
|
35
|
+
validateStatus: () => true, // we'll manually handle non-2xx
|
|
36
|
+
};
|
|
37
|
+
const response = await axios_1.default.request(config);
|
|
38
|
+
if (response.status < 200 || response.status >= 300) {
|
|
39
|
+
throw new Error(`Minimax API Error: ${response.status} ${response.statusText} — ${JSON.stringify(response.data)}`);
|
|
40
|
+
}
|
|
41
|
+
return response.data;
|
|
42
|
+
}
|
|
43
|
+
async generateVideo(params) {
|
|
44
|
+
(0, helpers_1.validateParams)(params);
|
|
45
|
+
const modelId = aiModels_1.aiModelConfigs[params.modelKey]?.modelId;
|
|
46
|
+
if (!modelId) {
|
|
47
|
+
throw new Error(`Unknown modelKey: ${params.modelKey}`);
|
|
48
|
+
}
|
|
49
|
+
const requestBody = {
|
|
50
|
+
model: modelId,
|
|
51
|
+
prompt: params.prompt,
|
|
52
|
+
resolution: params.resolution || "512P",
|
|
53
|
+
duration: params.duration || 6,
|
|
54
|
+
};
|
|
55
|
+
const task = await this.request("/platform/text_to_video", "POST", requestBody);
|
|
56
|
+
const taskId = task.task_id;
|
|
57
|
+
return { task: taskId, status: types_1.EVideoJobStatus.PENDING };
|
|
58
|
+
}
|
|
59
|
+
async checkVideoStatus({ task, outputFilename, outputFilePath = "videos", }) {
|
|
60
|
+
const result = await this.request(`/v1/query/video_generation`, "GET", undefined, { task_id: `${task}` });
|
|
61
|
+
if (result.status === "Success") {
|
|
62
|
+
if (!result.file_id) {
|
|
63
|
+
return {
|
|
64
|
+
status: types_1.EVideoJobStatus.FAILED,
|
|
65
|
+
errorMessage: "No file_id in response",
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
// Get file metadata and download URL
|
|
69
|
+
const fileInfo = await this.request(`/v1/files/retrieve`, "GET", undefined, { file_id: result.file_id });
|
|
70
|
+
if (!fileInfo.download_url) {
|
|
71
|
+
return {
|
|
72
|
+
status: types_1.EVideoJobStatus.FAILED,
|
|
73
|
+
errorMessage: `File retrieval failed: ${fileInfo.base_resp?.status_code} ${fileInfo.base_resp?.status_msg}`,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
// Download the video as binary
|
|
77
|
+
const videoResp = await axios_1.default.get(fileInfo.download_url, {
|
|
78
|
+
responseType: "arraybuffer",
|
|
79
|
+
timeout: 180000, // 3 minutes
|
|
80
|
+
});
|
|
81
|
+
if (videoResp.status !== 200) {
|
|
82
|
+
return {
|
|
83
|
+
status: types_1.EVideoJobStatus.FAILED,
|
|
84
|
+
errorMessage: `Failed to download video: ${videoResp.status}`,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
const buffer = Buffer.from(videoResp.data);
|
|
88
|
+
const filePath = `${outputFilePath}/${outputFilename}.mp4`;
|
|
89
|
+
const file = (0, firebase_1.getBucket)().file(filePath);
|
|
90
|
+
await file.save(buffer, { contentType: "video/mp4" });
|
|
91
|
+
const [signedUrl] = await file.getSignedUrl({
|
|
92
|
+
action: "read",
|
|
93
|
+
expires: "03-09-2491",
|
|
94
|
+
});
|
|
95
|
+
return {
|
|
96
|
+
videoUrl: signedUrl,
|
|
97
|
+
status: types_1.EVideoJobStatus.COMPLETED,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
if (result.status === "Fail") {
|
|
101
|
+
return {
|
|
102
|
+
status: types_1.EVideoJobStatus.FAILED,
|
|
103
|
+
errorMessage: `${result.base_resp.status_code} ${result.base_resp.status_msg}`,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
return { status: types_1.EVideoJobStatus.PENDING };
|
|
107
|
+
}
|
|
108
|
+
getCreditUsed({ modelKey, resolution = "512P", duration = 6, }) {
|
|
109
|
+
const modelConfig = aiModels_1.aiModelConfigs[modelKey];
|
|
110
|
+
const cost = modelConfig.cost?.fixed ??
|
|
111
|
+
modelConfig.cost?.table?.[resolution]?.[duration];
|
|
112
|
+
return (0, helpers_2.getCreditsFromCost)(cost ?? 0);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
exports.MinimaxService = MinimaxService;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type MinimaxModelName = "MiniMax-Hailuo-02" | "T2V-01-Director" | "T2V-01";
|
|
2
|
+
export interface MinimaxVideoGenerateRequest {
|
|
3
|
+
model: MinimaxModelName;
|
|
4
|
+
prompt: string;
|
|
5
|
+
resolution?: string;
|
|
6
|
+
duration?: number;
|
|
7
|
+
}
|
|
8
|
+
export interface MinimaxTaskResponse {
|
|
9
|
+
task_id: string;
|
|
10
|
+
status: "Preparing" | "Queueing" | "Processing" | "Success" | "Fail";
|
|
11
|
+
file_id?: string;
|
|
12
|
+
video_width?: number;
|
|
13
|
+
video_height?: number;
|
|
14
|
+
base_resp: {
|
|
15
|
+
status_code: 0 | 1002 | 1004 | 1026 | 1027;
|
|
16
|
+
status_msg: string;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export interface MinimaxVideoGenerateResponse {
|
|
20
|
+
task_id: string;
|
|
21
|
+
base_resp: {
|
|
22
|
+
status_code: 0 | 1002 | 1004 | 1008 | 1026 | 2013 | 2049;
|
|
23
|
+
status_msg: string;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/services/aiGen/providers/minimax/types.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,gBAAgB,GACxB,mBAAmB,GACnB,iBAAiB,GACjB,QAAQ,CAAC;AAEb,MAAM,WAAW,2BAA2B;IAC1C,KAAK,EAAE,gBAAgB,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,WAAW,GAAG,UAAU,GAAG,YAAY,GAAG,SAAS,GAAG,MAAM,CAAC;IACrE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE;QACT,WAAW,EAAE,CAAC,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;QAC3C,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;CACH;AAED,MAAM,WAAW,4BAA4B;IAC3C,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE;QACT,WAAW,EAAE,CAAC,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;QACzD,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;CACH"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/services/aiGen/providers/openai/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
|