Skip to content

Commit 4459375

Browse files
committed
kling
1 parent 3bebc08 commit 4459375

9 files changed

Lines changed: 56 additions & 105 deletions

File tree

.github/workflows/docker-image.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
uses: docker/login-action@v2
2020
with:
2121
username: kadxy
22-
password: ${{ secrets.DOCKER_PASSWORD }}
22+
password: ${{ secrets.DOCKER_PASSWORD }}
2323

2424
- name: Push the Docker image
2525
run: |

app/home.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import DalleIcon from "@/app/icons/dalle.svg";
1616
import PikaIcon from "@/app/icons/pika.svg";
1717
import LumaIcon from "@/app/icons/luma.svg";
1818
import BiBiGPTIcon from "@/app/icons/bibi-gpt.svg";
19-
import KelingIcon from "./providers/keling-ai/assets/logo_basic_mono.svg";
19+
import KlingIcon from "@/app/providers/kling/assets/logo_basic_mono.svg";
2020
import { HashRouter as Router, Route, Routes, useLocation, useNavigate } from "react-router-dom";
2121
import { Theme, useAppConfig } from "@/app/store";
2222
import { ProConfigProvider, ProLayout, type ProTokenType } from "@ant-design/pro-components";
@@ -138,8 +138,8 @@ const Doc2XPage = dynamic(async () => (await import("./pages/Doc2X")).default, {
138138
loading: () => <Loading />,
139139
});
140140

141-
const KelingPage = dynamic(async () => (await import("./pages/Keling")).default, {
142-
loading: () => <Loading logo={<KelingIcon />} />,
141+
const KlingPage = dynamic(async () => (await import("./pages/Kling")).default, {
142+
loading: () => <Loading logo={<KlingIcon />} />,
143143
});
144144

145145
const printCopyRight = () => console.log("@Kadxy 2024.");
@@ -276,9 +276,9 @@ const App = (props: { dark: boolean; updateConfig: any }) => {
276276
icon: <FolderOpenFilled />,
277277
},
278278
{
279-
path: Path.Keling,
280-
name: "Keling",
281-
icon: <Icon component={KelingIcon} />,
279+
path: Path.Kling,
280+
name: "Kling",
281+
icon: <Icon component={KlingIcon} />,
282282
},
283283
{
284284
path: Path.Pricing,
@@ -317,7 +317,7 @@ const App = (props: { dark: boolean; updateConfig: any }) => {
317317
<Route path={Path.Doc2X} element={<Doc2XPage />} />
318318
<Route path={Path.BiBiGPT} element={<BiBiGPTPage />} />
319319
<Route path={Path.GPTs} element={<GPTsPage />} />
320-
<Route path={Path.Keling} element={<KelingPage />} />
320+
<Route path={Path.Kling} element={<KlingPage />} />
321321
<Route path={Path.Pricing} element={<PricingPage />} />
322322
<Route path={Path.Tools} element={<ToolsPage />} />
323323
<Route path={Path.Settings} element={<Settings />} />
Lines changed: 36 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import {
1212
} from "@ant-design/pro-components";
1313
import { COL_SCROLL_STYLE, PRO_FORM_PROPS, SEGMENTED_PROPS } from "@/constant";
1414
import { useAppConfig } from "@/app/store";
15-
import { Alert, Col, Divider, message, Segmented } from "antd";
16-
import { KelingAI, KelingApiTypes } from "@/app/providers/keling-ai";
15+
import { Alert, Col, Divider, message, Segmented, SegmentedProps } from "antd";
16+
import { Kling, KlingApiTypes } from "@/app/providers/kling";
1717
import { RenderSubmitter } from "../render";
1818

1919
const MODE_OPTIONS = [
@@ -26,13 +26,20 @@ const DURATION_OPTIONS = [
2626
{ label: "10s", value: "10" },
2727
];
2828

29+
const TASK_TYPE_OPTIONS = [
30+
{ label: "文生视频", value: "text2video" },
31+
{ label: "图生视频", value: "image2video" },
32+
// { label: "图片生成", value: "generations", disabled: true },
33+
{ label: "任务查询", value: "queryTask" },
34+
];
35+
2936
const MODEL_OPTIONS = [{ label: "kling-v1", value: "kling-v1" }];
3037

31-
const KelingPage = () => {
38+
const KlingPage = () => {
3239
const appConfig = useAppConfig();
33-
const api = new KelingAI("sk-sFplfAcnWY3sFCCs02Ac93Ce9cEf4984A7EdF93e70969c18");
40+
const api = new Kling("sk-sFplfAcnWY3sFCCs02Ac93Ce9cEf4984A7EdF93e70969c18");
3441

35-
const [taskType, setTaskType] = useState<"text2video" | "image2video" | "queryTask">("text2video");
42+
const [taskType, setTaskType] = useState("text2video");
3643
const [klingText2VideoForm] = ProForm.useForm();
3744
const [klingImage2VideoForm] = ProForm.useForm();
3845
const [klingQueryTaskForm] = ProForm.useForm();
@@ -42,7 +49,7 @@ const KelingPage = () => {
4249

4350
const Text2VideoForm = (props: {
4451
form: ProFormInstance;
45-
api: KelingAI;
52+
api: Kling;
4653
updateTask: (data: any[]) => void;
4754
updateError: (error: any) => void;
4855
}) => {
@@ -53,7 +60,7 @@ const KelingPage = () => {
5360
const [abortController, setAbortController] = useState<AbortController | null>(null);
5461
const [submitting, setSubmitting] = useState(false);
5562
return (
56-
<ProForm<KelingApiTypes["generateText2VideoTask"]["req"]>
63+
<ProForm<KlingApiTypes["generateText2VideoTask"]["req"]>
5764
{...PRO_FORM_PROPS}
5865
form={props.form}
5966
initialValues={{
@@ -100,25 +107,14 @@ const KelingPage = () => {
100107
<ProFormTextArea
101108
name={"prompt"}
102109
label={"Prompt"}
103-
rules={[
104-
{ required: true },
105-
{
106-
type: "string",
107-
max: 2500,
108-
},
109-
]}
110+
rules={[{ required: true }, { type: "string", max: 2500 }]}
110111
fieldProps={{ autoSize: { minRows: 3 } }}
111112
tooltip={"正向文本提示"}
112113
/>
113114
<ProFormTextArea
114115
name={"negative_prompt"}
115116
label={"Negative Prompt"}
116-
rules={[
117-
{
118-
type: "string",
119-
max: 2500,
120-
},
121-
]}
117+
rules={[{ type: "string", max: 2500 }]}
122118
fieldProps={{ autoSize: { minRows: 2 } }}
123119
tooltip={"负向文本提示,用于排除不需要的元素或风格"}
124120
/>
@@ -128,13 +124,7 @@ const KelingPage = () => {
128124
min={0}
129125
max={1}
130126
step={0.01}
131-
marks={{
132-
0: "0",
133-
0.25: "0.25",
134-
0.5: "0.5",
135-
0.75: "0.75",
136-
1: "1",
137-
}}
127+
marks={{ 0: "0", 0.25: "0.25", 0.5: "0.5", 0.75: "0.75", 1: "1" }}
138128
tooltip={"生成视频的自由度,值越大,模型自由度越小,与用户输入的提示词相关性越强"}
139129
/>
140130

@@ -152,26 +142,11 @@ const KelingPage = () => {
152142
name={["camera_control", "type"]}
153143
label={"Type"}
154144
options={[
155-
{
156-
label: "Simple",
157-
value: "simple",
158-
},
159-
{
160-
label: "Down Back",
161-
value: "down_back",
162-
},
163-
{
164-
label: "Forward Up",
165-
value: "forward_up",
166-
},
167-
{
168-
label: "Right Turn Forward",
169-
value: "right_turn_forward",
170-
},
171-
{
172-
label: "Left Turn Forward",
173-
value: "left_turn_forward",
174-
},
145+
{ label: "Simple", value: "simple" },
146+
{ label: "Down Back", value: "down_back" },
147+
{ label: "Forward Up", value: "forward_up" },
148+
{ label: "Right Turn Forward", value: "right_turn_forward" },
149+
{ label: "Left Turn Forward", value: "left_turn_forward" },
175150
]}
176151
tooltip={
177152
<>
@@ -312,7 +287,7 @@ const KelingPage = () => {
312287

313288
const Image2VideoForm = (props: {
314289
form: ProFormInstance;
315-
api: KelingAI;
290+
api: Kling;
316291
updateTask: (data: any[]) => void;
317292
updateError: (error: any) => void;
318293
}) => {
@@ -341,7 +316,7 @@ const KelingPage = () => {
341316
};
342317

343318
return (
344-
<ProForm<KelingApiTypes["generateImage2VideoTask"]["req"]>
319+
<ProForm<KlingApiTypes["generateImage2VideoTask"]["req"]>
345320
{...PRO_FORM_PROPS}
346321
form={props.form}
347322
initialValues={{
@@ -442,14 +417,14 @@ const KelingPage = () => {
442417

443418
const QueryTaskForm = (props: {
444419
form: ProFormInstance;
445-
api: KelingAI;
420+
api: Kling;
446421
updateTask: (data: any[]) => void;
447422
updateError: (error: any) => void;
448423
}) => {
449424
const [abortController, setAbortController] = useState<AbortController | null>(null);
450425
const [submitting, setSubmitting] = useState(false);
451426
return (
452-
<ProForm<KelingApiTypes["queryTask"]["endpoint_params"]>
427+
<ProForm<KlingApiTypes["queryTask"]["endpoint_params"]>
453428
{...PRO_FORM_PROPS}
454429
form={props.form}
455430
initialValues={{
@@ -485,21 +460,19 @@ const KelingPage = () => {
485460
>
486461
<ProFormRadio.Group
487462
name={"action"}
488-
// label={"Action"}
489463
label={"目标类型"}
490-
options={["images", "videos"]}
464+
options={[
465+
{ label: "视频", value: "videos" },
466+
{ label: "图片", value: "images", disabled: true },
467+
]}
491468
/>
492469
<ProFormRadio.Group
493470
name={"action2"}
494-
// label={"Action2"}
495471
label={"任务类型"}
496472
options={[
497-
// { label: "生成", value: "generations" },
498-
// { label: "视频", value: "text2video" },
499-
// { label: "图片", value: "image2video" },
500-
"generations",
501-
"text2video",
502-
"image2video",
473+
{ label: "文生视频", value: "text2video" },
474+
{ label: "图生视频", value: "image2video" },
475+
{ label: "图片生成", value: "generations", disabled: true },
503476
]}
504477
/>
505478
<ProFormText name={"task_id"} label={"任务ID"} rules={[{ required: true }, { type: "string" }]} />
@@ -509,26 +482,8 @@ const KelingPage = () => {
509482

510483
return (
511484
<>
512-
<Col flex="340px" style={COL_SCROLL_STYLE}>
513-
<Segmented
514-
{...SEGMENTED_PROPS}
515-
options={[
516-
{
517-
label: "文生视频",
518-
value: "text2video",
519-
},
520-
{
521-
label: "图生视频",
522-
value: "image2video",
523-
},
524-
{
525-
label: "任务查询",
526-
value: "queryTask",
527-
},
528-
]}
529-
value={taskType}
530-
onChange={setTaskType}
531-
/>
485+
<Col flex="360px" style={COL_SCROLL_STYLE}>
486+
<Segmented {...SEGMENTED_PROPS} options={TASK_TYPE_OPTIONS} value={taskType} onChange={setTaskType} />
532487
{taskType === "text2video" && (
533488
<Text2VideoForm form={klingText2VideoForm} api={api} updateTask={setTaskData} updateError={setErrorData} />
534489
)}
@@ -548,4 +503,4 @@ const KelingPage = () => {
548503
);
549504
};
550505

551-
export default KelingPage;
506+
export default KlingPage;
File renamed without changes.
Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ interface GenerateImage2VideoTaskRequest {
240240
callback_url?: string;
241241
}
242242

243-
export interface KelingApiTypes extends CommonApiTypes {
243+
export interface KlingApiTypes extends CommonApiTypes {
244244
generateText2VideoTask: {
245245
req: GenerateText2VideoTaskRequest;
246246
res: GenerateText2VideoTaskResponse;
@@ -262,9 +262,9 @@ export interface KelingApiTypes extends CommonApiTypes {
262262
};
263263
}
264264

265-
export class KelingAI implements AIProvider {
265+
export class Kling implements AIProvider {
266266
readonly name: ProviderName = {
267-
en: "Keling AI",
267+
en: "Kling",
268268
zh: "可灵 AI",
269269
};
270270

@@ -315,7 +315,7 @@ export class KelingAI implements AIProvider {
315315
},
316316
];
317317

318-
readonly api_config: ProviderAPIConfig<KelingApiTypes> = {
318+
readonly api_config: ProviderAPIConfig<KlingApiTypes> = {
319319
base_url: BASE_URL_B,
320320
authorization: "Bearer xxx",
321321
call_map: {
@@ -396,12 +396,7 @@ export class KelingAI implements AIProvider {
396396
this.api_config.authorization = apiKey;
397397
}
398398

399-
callApi: CallApiFunction<KelingApiTypes> = ({ callKey, params, endpoint_params, signal }) => {
400-
console.log(`KelingAI callApi triggered for ${callKey}`, {
401-
params,
402-
endpoint_params,
403-
});
404-
399+
callApi: CallApiFunction<KlingApiTypes> = ({ callKey, params, endpoint_params, signal }) => {
405400
const headers: HeadersInit = {
406401
Authorization: `Bearer ${this.api_config.authorization}`,
407402
};

constant/system.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export enum Path {
1818
Luma = "/luma",
1919
GPTs = "/gpts",
2020
Doc2X = "/doc2x",
21-
Keling = "/keling",
21+
Kling = "/kling",
2222
BiBiGPT = "/bibi-gpt",
2323
StableDiffusion = "/stable-diffusion",
2424
Pricing = "/pricing",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"@tauri-apps/cli": "1.6.2",
4343
"@types/ali-oss": "^6.16.11",
4444
"@types/lodash": "^4.17.9",
45-
"@types/node": "^20.9.0",
45+
"@types/node": "^22.7.2",
4646
"@types/react": "^18.3.9",
4747
"@types/react-dom": "^18.2.7",
4848
"@types/react-katex": "^3.0.0",

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"compilerOptions": {
33
"target": "ES2015",
4+
"types": ["node"],
45
"lib": ["dom", "dom.iterable", "esnext"],
56
"allowJs": true,
67
"skipLibCheck": true,

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2031,10 +2031,10 @@
20312031
dependencies:
20322032
undici-types "~6.19.2"
20332033

2034-
"@types/node@^20.9.0":
2035-
version "20.16.5"
2036-
resolved "https://registry.yarnpkg.com/@types/node/-/node-20.16.5.tgz#d43c7f973b32ffdf9aa7bd4f80e1072310fd7a53"
2037-
integrity sha512-VwYCweNo3ERajwy0IUlqqcyZ8/A7Zwa9ZP3MnENWcB11AejO+tLy3pu850goUW2FC/IJMdZUfKpX/yxL1gymCA==
2034+
"@types/node@^22.7.2":
2035+
version "22.7.2"
2036+
resolved "https://registry.yarnpkg.com/@types/node/-/node-22.7.2.tgz#80ed66c0a5025ffa037587fd69a816f29b54e4c7"
2037+
integrity sha512-866lXSrpGpgyHBZUa2m9YNWqHDjjM0aBTJlNtYaGEw4rqY/dcD7deRVTbBBAJelfA7oaGDbNftXF/TL/A6RgoA==
20382038
dependencies:
20392039
undici-types "~6.19.2"
20402040

0 commit comments

Comments
 (0)