bizyengine 1.2.45__py3-none-any.whl → 1.2.71__py3-none-any.whl
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.
- bizyengine/bizy_server/errno.py +21 -0
- bizyengine/bizy_server/server.py +130 -160
- bizyengine/bizy_server/utils.py +3 -0
- bizyengine/bizyair_extras/__init__.py +38 -31
- bizyengine/bizyair_extras/third_party_api/__init__.py +15 -0
- bizyengine/bizyair_extras/third_party_api/nodes_doubao.py +535 -0
- bizyengine/bizyair_extras/third_party_api/nodes_flux.py +173 -0
- bizyengine/bizyair_extras/third_party_api/nodes_gemini.py +403 -0
- bizyengine/bizyair_extras/third_party_api/nodes_gpt.py +101 -0
- bizyengine/bizyair_extras/third_party_api/nodes_hailuo.py +115 -0
- bizyengine/bizyair_extras/third_party_api/nodes_kling.py +404 -0
- bizyengine/bizyair_extras/third_party_api/nodes_sora.py +218 -0
- bizyengine/bizyair_extras/third_party_api/nodes_veo3.py +193 -0
- bizyengine/bizyair_extras/third_party_api/nodes_wan_api.py +198 -0
- bizyengine/bizyair_extras/third_party_api/trd_nodes_base.py +183 -0
- bizyengine/bizyair_extras/utils/aliyun_oss.py +92 -0
- bizyengine/bizyair_extras/utils/audio.py +88 -0
- bizyengine/bizybot/__init__.py +12 -0
- bizyengine/bizybot/client.py +774 -0
- bizyengine/bizybot/config.py +129 -0
- bizyengine/bizybot/coordinator.py +556 -0
- bizyengine/bizybot/exceptions.py +186 -0
- bizyengine/bizybot/mcp/__init__.py +3 -0
- bizyengine/bizybot/mcp/manager.py +520 -0
- bizyengine/bizybot/mcp/models.py +46 -0
- bizyengine/bizybot/mcp/registry.py +129 -0
- bizyengine/bizybot/mcp/routing.py +378 -0
- bizyengine/bizybot/models.py +344 -0
- bizyengine/core/__init__.py +1 -0
- bizyengine/core/commands/servers/prompt_server.py +10 -1
- bizyengine/core/common/client.py +8 -7
- bizyengine/core/common/utils.py +30 -1
- bizyengine/core/image_utils.py +12 -283
- bizyengine/misc/llm.py +32 -15
- bizyengine/misc/utils.py +179 -2
- bizyengine/version.txt +1 -1
- {bizyengine-1.2.45.dist-info → bizyengine-1.2.71.dist-info}/METADATA +3 -1
- {bizyengine-1.2.45.dist-info → bizyengine-1.2.71.dist-info}/RECORD +40 -16
- {bizyengine-1.2.45.dist-info → bizyengine-1.2.71.dist-info}/WHEEL +0 -0
- {bizyengine-1.2.45.dist-info → bizyengine-1.2.71.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
from bizyairsdk import tensor_to_bytesio
|
|
2
|
+
|
|
3
|
+
from .trd_nodes_base import BizyAirTrdApiBaseNode
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Hailuo2_3_T2V(BizyAirTrdApiBaseNode):
|
|
7
|
+
@classmethod
|
|
8
|
+
def INPUT_TYPES(cls):
|
|
9
|
+
return {
|
|
10
|
+
"required": {
|
|
11
|
+
"prompt": (
|
|
12
|
+
"STRING",
|
|
13
|
+
{
|
|
14
|
+
"multiline": True,
|
|
15
|
+
"default": "",
|
|
16
|
+
},
|
|
17
|
+
),
|
|
18
|
+
"model": (
|
|
19
|
+
["MiniMax-Hailuo-2.3"],
|
|
20
|
+
{"default": "MiniMax-Hailuo-2.3"},
|
|
21
|
+
),
|
|
22
|
+
"duration": ([6, 10], {"default": 6}),
|
|
23
|
+
"resolution": (
|
|
24
|
+
["768P", "1080P"],
|
|
25
|
+
{"default": "1080P"},
|
|
26
|
+
),
|
|
27
|
+
},
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
NODE_DISPLAY_NAME = "Hailuo2.3 Text To Video"
|
|
31
|
+
RETURN_TYPES = ("VIDEO",)
|
|
32
|
+
RETURN_NAMES = ("video",)
|
|
33
|
+
CATEGORY = "☁️BizyAir/External APIs/Hailuo"
|
|
34
|
+
|
|
35
|
+
def handle_inputs(self, headers, prompt_id, **kwargs):
|
|
36
|
+
model = kwargs.get("model", "MiniMax-Hailuo-2.3")
|
|
37
|
+
duration = kwargs.get("duration", 6)
|
|
38
|
+
prompt = kwargs.get("prompt", "")
|
|
39
|
+
resolution = kwargs.get("resolution", "1080P")
|
|
40
|
+
if resolution == "1080P" and duration == 10:
|
|
41
|
+
raise ValueError(
|
|
42
|
+
"Hailuo2.3 1080P resolution + 10s duration is not supported"
|
|
43
|
+
)
|
|
44
|
+
data = {
|
|
45
|
+
"model": model,
|
|
46
|
+
"duration": duration,
|
|
47
|
+
"prompt": prompt,
|
|
48
|
+
"resolution": resolution,
|
|
49
|
+
}
|
|
50
|
+
return data, "MiniMax-Hailuo-2.3-t2v"
|
|
51
|
+
|
|
52
|
+
def handle_outputs(self, outputs):
|
|
53
|
+
return (outputs[0][0],)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
class Hailuo2_3_I2V(BizyAirTrdApiBaseNode):
|
|
57
|
+
@classmethod
|
|
58
|
+
def INPUT_TYPES(cls):
|
|
59
|
+
return {
|
|
60
|
+
"required": {
|
|
61
|
+
"first_frame_image": ("IMAGE",),
|
|
62
|
+
"prompt": (
|
|
63
|
+
"STRING",
|
|
64
|
+
{
|
|
65
|
+
"multiline": True,
|
|
66
|
+
"default": "",
|
|
67
|
+
},
|
|
68
|
+
),
|
|
69
|
+
"model": (
|
|
70
|
+
["MiniMax-Hailuo-2.3", "MiniMax-Hailuo-2.3-Fast"],
|
|
71
|
+
{"default": "MiniMax-Hailuo-2.3"},
|
|
72
|
+
),
|
|
73
|
+
"duration": ([6, 10], {"default": 6}),
|
|
74
|
+
"resolution": (
|
|
75
|
+
["768P", "1080P"],
|
|
76
|
+
{"default": "1080P"},
|
|
77
|
+
),
|
|
78
|
+
},
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
NODE_DISPLAY_NAME = "Hailuo2.3 Image To Video"
|
|
82
|
+
RETURN_TYPES = ("VIDEO",)
|
|
83
|
+
RETURN_NAMES = ("video",)
|
|
84
|
+
CATEGORY = "☁️BizyAir/External APIs/Hailuo"
|
|
85
|
+
|
|
86
|
+
def handle_inputs(self, headers, prompt_id, **kwargs):
|
|
87
|
+
model = kwargs.get("model", "MiniMax-Hailuo-2.3")
|
|
88
|
+
duration = kwargs.get("duration", 6)
|
|
89
|
+
prompt = kwargs.get("prompt", "")
|
|
90
|
+
resolution = kwargs.get("resolution", "1080P")
|
|
91
|
+
first_frame_image = kwargs.get("first_frame_image", None)
|
|
92
|
+
if first_frame_image is None:
|
|
93
|
+
raise ValueError("First frame image is required")
|
|
94
|
+
if resolution == "1080P" and duration == 10:
|
|
95
|
+
raise ValueError(
|
|
96
|
+
"Hailuo2.3 1080P resolution + 10s duration is not supported"
|
|
97
|
+
)
|
|
98
|
+
# 上传首帧图片
|
|
99
|
+
first_frame_image_url = self.upload_file(
|
|
100
|
+
tensor_to_bytesio(image=first_frame_image, total_pixels=4096 * 4096),
|
|
101
|
+
f"{prompt_id}.png",
|
|
102
|
+
headers,
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
data = {
|
|
106
|
+
"model": model,
|
|
107
|
+
"duration": duration,
|
|
108
|
+
"prompt": prompt,
|
|
109
|
+
"resolution": resolution,
|
|
110
|
+
"first_frame_image": first_frame_image_url,
|
|
111
|
+
}
|
|
112
|
+
return data, "MiniMax-Hailuo-2.3-i2v"
|
|
113
|
+
|
|
114
|
+
def handle_outputs(self, outputs):
|
|
115
|
+
return (outputs[0][0],)
|
|
@@ -0,0 +1,404 @@
|
|
|
1
|
+
from bizyairsdk import tensor_to_bytesio
|
|
2
|
+
|
|
3
|
+
from .trd_nodes_base import BizyAirTrdApiBaseNode
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Kling_2_1_T2V_API(BizyAirTrdApiBaseNode):
|
|
7
|
+
NODE_DISPLAY_NAME = "Kling 2.1 Text To Video"
|
|
8
|
+
RETURN_TYPES = ("VIDEO",)
|
|
9
|
+
RETURN_NAMES = ("video",)
|
|
10
|
+
CATEGORY = "☁️BizyAir/External APIs/Kling"
|
|
11
|
+
|
|
12
|
+
@classmethod
|
|
13
|
+
def INPUT_TYPES(cls):
|
|
14
|
+
return {
|
|
15
|
+
"required": {
|
|
16
|
+
"prompt": (
|
|
17
|
+
"STRING",
|
|
18
|
+
{
|
|
19
|
+
"multiline": True,
|
|
20
|
+
"default": "",
|
|
21
|
+
},
|
|
22
|
+
),
|
|
23
|
+
"negative_prompt": (
|
|
24
|
+
"STRING",
|
|
25
|
+
{
|
|
26
|
+
"multiline": True,
|
|
27
|
+
"default": "",
|
|
28
|
+
},
|
|
29
|
+
),
|
|
30
|
+
"model_name": (["kling-v2-1-master"], {"default": "kling-v2-1-master"}),
|
|
31
|
+
"duration": ([5, 10], {"default": 5}),
|
|
32
|
+
"aspect_ratio": (["16:9", "9:16", "1:1"], {"default": "16:9"}),
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
def handle_inputs(self, headers, prompt_id, **kwargs):
|
|
37
|
+
model = kwargs.get("model_name", "kling-v2-1-master")
|
|
38
|
+
prompt = kwargs.get("prompt", "")
|
|
39
|
+
negative_prompt = kwargs.get("negative_prompt", "")
|
|
40
|
+
duration = kwargs.get("duration", 5)
|
|
41
|
+
aspect_ratio = kwargs.get("aspect_ratio", "16:9")
|
|
42
|
+
if prompt is None or prompt.strip() == "":
|
|
43
|
+
raise ValueError("Prompt is required")
|
|
44
|
+
if len(prompt) > 2500 or len(negative_prompt) > 2500:
|
|
45
|
+
raise ValueError(
|
|
46
|
+
"Prompt and negative prompt must be less than 2500 characters"
|
|
47
|
+
)
|
|
48
|
+
data = {
|
|
49
|
+
"model_name": model,
|
|
50
|
+
"negative_prompt": negative_prompt,
|
|
51
|
+
"duration": duration,
|
|
52
|
+
"aspect_ratio": aspect_ratio,
|
|
53
|
+
"prompt": prompt,
|
|
54
|
+
}
|
|
55
|
+
return data, "kling-v2-1"
|
|
56
|
+
|
|
57
|
+
def handle_outputs(self, outputs):
|
|
58
|
+
return (outputs[0][0],)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
class Kling_2_1_I2V_API(BizyAirTrdApiBaseNode):
|
|
62
|
+
NODE_DISPLAY_NAME = "Kling 2.1 Image To Video"
|
|
63
|
+
RETURN_TYPES = ("VIDEO",)
|
|
64
|
+
RETURN_NAMES = ("video",)
|
|
65
|
+
CATEGORY = "☁️BizyAir/External APIs/Kling"
|
|
66
|
+
|
|
67
|
+
@classmethod
|
|
68
|
+
def INPUT_TYPES(cls):
|
|
69
|
+
return {
|
|
70
|
+
"required": {
|
|
71
|
+
"first_frame_image": ("IMAGE", {"tooltip": "首帧图片"}),
|
|
72
|
+
"prompt": (
|
|
73
|
+
"STRING",
|
|
74
|
+
{
|
|
75
|
+
"multiline": True,
|
|
76
|
+
"default": "",
|
|
77
|
+
},
|
|
78
|
+
),
|
|
79
|
+
"negative_prompt": (
|
|
80
|
+
"STRING",
|
|
81
|
+
{
|
|
82
|
+
"multiline": True,
|
|
83
|
+
"default": "",
|
|
84
|
+
},
|
|
85
|
+
),
|
|
86
|
+
"model_name": (
|
|
87
|
+
["kling-v2-1-std", "kling-v2-1-pro", "kling-v2-1-master"],
|
|
88
|
+
{"default": "kling-v2-1-std"},
|
|
89
|
+
),
|
|
90
|
+
"duration": ([5, 10], {"default": 5}),
|
|
91
|
+
"aspect_ratio": (["16:9", "9:16", "1:1"], {"default": "16:9"}),
|
|
92
|
+
},
|
|
93
|
+
"optional": {
|
|
94
|
+
"last_frame_image": ("IMAGE", {"tooltip": "末帧图片,只有pro支持"}),
|
|
95
|
+
},
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
def handle_inputs(self, headers, prompt_id, **kwargs):
|
|
99
|
+
model = kwargs.get("model_name", "kling-v2-1-std")
|
|
100
|
+
prompt = kwargs.get("prompt", "")
|
|
101
|
+
negative_prompt = kwargs.get("negative_prompt", "")
|
|
102
|
+
duration = kwargs.get("duration", 5)
|
|
103
|
+
aspect_ratio = kwargs.get("aspect_ratio", "16:9")
|
|
104
|
+
first_frame_image = kwargs.get("first_frame_image", None)
|
|
105
|
+
last_frame_image = kwargs.get("last_frame_image", None)
|
|
106
|
+
if first_frame_image is None:
|
|
107
|
+
raise ValueError("First frame image is required")
|
|
108
|
+
if len(prompt) > 2500 or len(negative_prompt) > 2500:
|
|
109
|
+
raise ValueError(
|
|
110
|
+
"Prompt and negative prompt must be less than 2500 characters"
|
|
111
|
+
)
|
|
112
|
+
# 上传图片
|
|
113
|
+
url = self.upload_file(
|
|
114
|
+
tensor_to_bytesio(image=first_frame_image, total_pixels=4096 * 4096),
|
|
115
|
+
f"{prompt_id}_first.png",
|
|
116
|
+
headers,
|
|
117
|
+
)
|
|
118
|
+
data = {
|
|
119
|
+
"model_name": model,
|
|
120
|
+
"prompt": prompt,
|
|
121
|
+
"negative_prompt": negative_prompt,
|
|
122
|
+
"first_frame_image": url,
|
|
123
|
+
"duration": duration,
|
|
124
|
+
"aspect_ratio": aspect_ratio,
|
|
125
|
+
}
|
|
126
|
+
if last_frame_image is not None:
|
|
127
|
+
last_frame_image_url = self.upload_file(
|
|
128
|
+
tensor_to_bytesio(image=last_frame_image, total_pixels=4096 * 4096),
|
|
129
|
+
f"{prompt_id}_last.png",
|
|
130
|
+
headers,
|
|
131
|
+
)
|
|
132
|
+
data["last_frame_image"] = last_frame_image_url
|
|
133
|
+
return data, "kling-v2-1"
|
|
134
|
+
|
|
135
|
+
def handle_outputs(self, outputs):
|
|
136
|
+
return (outputs[0][0],)
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
# class Kling_2_1_PRO_I2V_API(BizyAirTrdApiBaseNode):
|
|
140
|
+
# NODE_DISPLAY_NAME = "Kling 2.1 Pro Image To Video"
|
|
141
|
+
# RETURN_TYPES = ("VIDEO",)
|
|
142
|
+
# RETURN_NAMES = ("video",)
|
|
143
|
+
# CATEGORY = "☁️BizyAir/External APIs/Kling"
|
|
144
|
+
|
|
145
|
+
# @classmethod
|
|
146
|
+
# def INPUT_TYPES(cls):
|
|
147
|
+
# return {
|
|
148
|
+
# "required": {
|
|
149
|
+
# "first_frame_image": ("IMAGE", {"tooltip": "首帧图片"}),
|
|
150
|
+
# "prompt": (
|
|
151
|
+
# "STRING",
|
|
152
|
+
# {
|
|
153
|
+
# "multiline": True,
|
|
154
|
+
# "default": "",
|
|
155
|
+
# },
|
|
156
|
+
# ),
|
|
157
|
+
# "negative_prompt": (
|
|
158
|
+
# "STRING",
|
|
159
|
+
# {
|
|
160
|
+
# "multiline": True,
|
|
161
|
+
# "default": "",
|
|
162
|
+
# },
|
|
163
|
+
# ),
|
|
164
|
+
# "model_name": (["kling-v2-1", "kling-v2-1-master"], {"default": "kling-v2-1"}),
|
|
165
|
+
# "duration": ([5, 10], {"default": 5}),
|
|
166
|
+
# "aspect_ratio": (["16:9", "9:16", "1:1"], {"default": "16:9"}),
|
|
167
|
+
# },
|
|
168
|
+
# "optional": {
|
|
169
|
+
# "last_frame_image": ("IMAGE", {"tooltip": "末帧图片"}),
|
|
170
|
+
# },
|
|
171
|
+
# }
|
|
172
|
+
|
|
173
|
+
# def handle_inputs(self, headers, prompt_id, **kwargs):
|
|
174
|
+
# model = kwargs.get("model_name", "kling-v2-1")
|
|
175
|
+
# prompt = kwargs.get("prompt", "")
|
|
176
|
+
# negative_prompt = kwargs.get("negative_prompt", "")
|
|
177
|
+
# duration = kwargs.get("duration", 5)
|
|
178
|
+
# aspect_ratio = kwargs.get("aspect_ratio", "16:9")
|
|
179
|
+
# first_frame_image = kwargs.get("first_frame_image", None)
|
|
180
|
+
# last_frame_image = kwargs.get("last_frame_image", None)
|
|
181
|
+
# if first_frame_image is None:
|
|
182
|
+
# raise ValueError("First frame image is required")
|
|
183
|
+
# if len(prompt) > 2500 or len(negative_prompt) > 2500:
|
|
184
|
+
# raise ValueError("Prompt and negative prompt must be less than 2500 characters")
|
|
185
|
+
# # 上传图片
|
|
186
|
+
# first_frame_image_url = self.upload_file(
|
|
187
|
+
# tensor_to_bytesio(image=first_frame_image, total_pixels=4096 * 4096),
|
|
188
|
+
# f"{prompt_id}_first.png",
|
|
189
|
+
# headers,
|
|
190
|
+
# )
|
|
191
|
+
# data = {
|
|
192
|
+
# "model_name": model,
|
|
193
|
+
# "prompt": prompt,
|
|
194
|
+
# "negative_prompt": negative_prompt,
|
|
195
|
+
# "first_frame_image": first_frame_image_url,
|
|
196
|
+
# "duration": duration,
|
|
197
|
+
# "aspect_ratio": aspect_ratio,
|
|
198
|
+
# }
|
|
199
|
+
# if model == "kling-v2-1":
|
|
200
|
+
# data["mode"] = "pro"
|
|
201
|
+
# if last_frame_image is not None:
|
|
202
|
+
# last_frame_image_url = self.upload_file(
|
|
203
|
+
# tensor_to_bytesio(image=last_frame_image, total_pixels=4096 * 4096),
|
|
204
|
+
# f"{prompt_id}_last.png",
|
|
205
|
+
# headers,
|
|
206
|
+
# )
|
|
207
|
+
# data["last_frame_image"] = last_frame_image_url
|
|
208
|
+
# return data, model
|
|
209
|
+
|
|
210
|
+
# def handle_outputs(self, outputs):
|
|
211
|
+
# return (outputs[0][0],)
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
class Kling_2_5_I2V_API(BizyAirTrdApiBaseNode):
|
|
215
|
+
NODE_DISPLAY_NAME = "Kling 2.5 Image To Video"
|
|
216
|
+
RETURN_TYPES = ("VIDEO",)
|
|
217
|
+
RETURN_NAMES = ("video",)
|
|
218
|
+
CATEGORY = "☁️BizyAir/External APIs/Kling"
|
|
219
|
+
|
|
220
|
+
@classmethod
|
|
221
|
+
def INPUT_TYPES(cls):
|
|
222
|
+
return {
|
|
223
|
+
"required": {
|
|
224
|
+
"first_frame_image": ("IMAGE", {"tooltip": "首帧图片"}),
|
|
225
|
+
"prompt": (
|
|
226
|
+
"STRING",
|
|
227
|
+
{
|
|
228
|
+
"multiline": True,
|
|
229
|
+
"default": "",
|
|
230
|
+
},
|
|
231
|
+
),
|
|
232
|
+
"negative_prompt": (
|
|
233
|
+
"STRING",
|
|
234
|
+
{
|
|
235
|
+
"multiline": True,
|
|
236
|
+
"default": "",
|
|
237
|
+
},
|
|
238
|
+
),
|
|
239
|
+
"model_name": (["kling-v2-5-turbo"], {"default": "kling-v2-5-turbo"}),
|
|
240
|
+
"duration": ([5, 10], {"default": 5}),
|
|
241
|
+
},
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
def handle_inputs(self, headers, prompt_id, **kwargs):
|
|
245
|
+
model = kwargs.get("model_name", "kling-v2-5-turbo")
|
|
246
|
+
prompt = kwargs.get("prompt", "")
|
|
247
|
+
negative_prompt = kwargs.get("negative_prompt", "")
|
|
248
|
+
duration = kwargs.get("duration", 5)
|
|
249
|
+
first_frame_image = kwargs.get("first_frame_image", None)
|
|
250
|
+
if first_frame_image is None:
|
|
251
|
+
raise ValueError("First frame image is required")
|
|
252
|
+
if len(prompt) > 2500 or len(negative_prompt) > 2500:
|
|
253
|
+
raise ValueError(
|
|
254
|
+
"Prompt and negative prompt must be less than 2500 characters"
|
|
255
|
+
)
|
|
256
|
+
# 上传图片
|
|
257
|
+
url = self.upload_file(
|
|
258
|
+
tensor_to_bytesio(image=first_frame_image, total_pixels=4096 * 4096),
|
|
259
|
+
f"{prompt_id}.png",
|
|
260
|
+
headers,
|
|
261
|
+
)
|
|
262
|
+
data = {
|
|
263
|
+
"model_name": model,
|
|
264
|
+
"prompt": prompt,
|
|
265
|
+
"negative_prompt": negative_prompt,
|
|
266
|
+
"duration": duration,
|
|
267
|
+
"first_frame_image": url,
|
|
268
|
+
}
|
|
269
|
+
return data, "kling-v2-5"
|
|
270
|
+
|
|
271
|
+
def handle_outputs(self, outputs):
|
|
272
|
+
return (outputs[0][0],)
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
class Kling_2_T2I_API(BizyAirTrdApiBaseNode):
|
|
276
|
+
NODE_DISPLAY_NAME = "Kling 2 Text To Image"
|
|
277
|
+
RETURN_TYPES = ("IMAGE",)
|
|
278
|
+
RETURN_NAMES = ("images",)
|
|
279
|
+
CATEGORY = "☁️BizyAir/External APIs/Kling"
|
|
280
|
+
|
|
281
|
+
@classmethod
|
|
282
|
+
def INPUT_TYPES(cls):
|
|
283
|
+
return {
|
|
284
|
+
"required": {
|
|
285
|
+
"prompt": (
|
|
286
|
+
"STRING",
|
|
287
|
+
{
|
|
288
|
+
"multiline": True,
|
|
289
|
+
"default": "",
|
|
290
|
+
},
|
|
291
|
+
),
|
|
292
|
+
"negative_prompt": (
|
|
293
|
+
"STRING",
|
|
294
|
+
{
|
|
295
|
+
"multiline": True,
|
|
296
|
+
"default": "",
|
|
297
|
+
},
|
|
298
|
+
),
|
|
299
|
+
"model_name": (["kling-v2"], {"default": "kling-v2"}),
|
|
300
|
+
"aspect_ratio": (
|
|
301
|
+
["16:9", "9:16", "1:1", "4:3", "3:4", "3:2", "2:3", "21:9"],
|
|
302
|
+
{"default": "16:9"},
|
|
303
|
+
),
|
|
304
|
+
"resolution": (["1K", "2K"], {"default": "1K"}),
|
|
305
|
+
"variants": ("INT", {"default": 1, "min": 1, "max": 9}),
|
|
306
|
+
"image_fidelity": (
|
|
307
|
+
"FLOAT",
|
|
308
|
+
{"default": 0.5, "min": 0.0, "max": 1.0, "step": 0.01},
|
|
309
|
+
),
|
|
310
|
+
},
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
def handle_inputs(self, headers, prompt_id, **kwargs):
|
|
314
|
+
model = kwargs.get("model_name", "kling-v2")
|
|
315
|
+
prompt = kwargs.get("prompt", "")
|
|
316
|
+
negative_prompt = kwargs.get("negative_prompt", "")
|
|
317
|
+
aspect_ratio = kwargs.get("aspect_ratio", "16:9")
|
|
318
|
+
resolution = kwargs.get("resolution", "1K").lower()
|
|
319
|
+
variants = kwargs.get("variants", 1)
|
|
320
|
+
image_fidelity = kwargs.get("image_fidelity", 0.5)
|
|
321
|
+
if len(prompt) > 2500 or len(negative_prompt) > 2500:
|
|
322
|
+
raise ValueError(
|
|
323
|
+
"Prompt and negative prompt must be less than 2500 characters"
|
|
324
|
+
)
|
|
325
|
+
data = {
|
|
326
|
+
"model_name": model,
|
|
327
|
+
"prompt": prompt,
|
|
328
|
+
"negative_prompt": negative_prompt,
|
|
329
|
+
"aspect_ratio": aspect_ratio,
|
|
330
|
+
"resolution": resolution,
|
|
331
|
+
"variants": variants,
|
|
332
|
+
"image_fidelity": image_fidelity,
|
|
333
|
+
}
|
|
334
|
+
return data, "kling-v2"
|
|
335
|
+
|
|
336
|
+
def handle_outputs(self, outputs):
|
|
337
|
+
images = self.combine_images(outputs[1])
|
|
338
|
+
return (images,)
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
class Kling_2_I2I_API(BizyAirTrdApiBaseNode):
|
|
342
|
+
NODE_DISPLAY_NAME = "Kling 2 Image To Image"
|
|
343
|
+
RETURN_TYPES = ("IMAGE",)
|
|
344
|
+
RETURN_NAMES = ("images",)
|
|
345
|
+
CATEGORY = "☁️BizyAir/External APIs/Kling"
|
|
346
|
+
|
|
347
|
+
@classmethod
|
|
348
|
+
def INPUT_TYPES(cls):
|
|
349
|
+
return {
|
|
350
|
+
"required": {
|
|
351
|
+
"image": ("IMAGE", {"tooltip": "输入图片"}),
|
|
352
|
+
"prompt": (
|
|
353
|
+
"STRING",
|
|
354
|
+
{
|
|
355
|
+
"multiline": True,
|
|
356
|
+
"default": "",
|
|
357
|
+
},
|
|
358
|
+
),
|
|
359
|
+
"model_name": (["kling-v2"], {"default": "kling-v2"}),
|
|
360
|
+
"aspect_ratio": (
|
|
361
|
+
["16:9", "9:16", "1:1", "4:3", "3:4", "3:2", "2:3", "21:9"],
|
|
362
|
+
{"default": "16:9"},
|
|
363
|
+
),
|
|
364
|
+
"resolution": (["1K"], {"default": "1K"}),
|
|
365
|
+
"variants": ("INT", {"default": 1, "min": 1, "max": 9}),
|
|
366
|
+
"image_fidelity": (
|
|
367
|
+
"FLOAT",
|
|
368
|
+
{"default": 0.5, "min": 0.0, "max": 1.0, "step": 0.01},
|
|
369
|
+
),
|
|
370
|
+
},
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
def handle_inputs(self, headers, prompt_id, **kwargs):
|
|
374
|
+
model = kwargs.get("model_name", "kling-v2")
|
|
375
|
+
prompt = kwargs.get("prompt", "")
|
|
376
|
+
aspect_ratio = kwargs.get("aspect_ratio", "16:9")
|
|
377
|
+
resolution = kwargs.get("resolution", "1K").lower()
|
|
378
|
+
variants = kwargs.get("variants", 1)
|
|
379
|
+
image = kwargs.get("image", None)
|
|
380
|
+
image_fidelity = kwargs.get("image_fidelity", 0.5)
|
|
381
|
+
if image is None:
|
|
382
|
+
raise ValueError("Image is required")
|
|
383
|
+
if len(prompt) > 2500:
|
|
384
|
+
raise ValueError("Prompt must be less than 2500 characters")
|
|
385
|
+
# 上传图片
|
|
386
|
+
image_url = self.upload_file(
|
|
387
|
+
tensor_to_bytesio(image=image, total_pixels=4096 * 4096),
|
|
388
|
+
f"{prompt_id}.png",
|
|
389
|
+
headers,
|
|
390
|
+
)
|
|
391
|
+
data = {
|
|
392
|
+
"model_name": model,
|
|
393
|
+
"prompt": prompt,
|
|
394
|
+
"image": image_url,
|
|
395
|
+
"aspect_ratio": aspect_ratio,
|
|
396
|
+
"resolution": resolution,
|
|
397
|
+
"variants": variants,
|
|
398
|
+
"image_fidelity": image_fidelity,
|
|
399
|
+
}
|
|
400
|
+
return data, "kling-v2"
|
|
401
|
+
|
|
402
|
+
def handle_outputs(self, outputs):
|
|
403
|
+
images = self.combine_images(outputs[1])
|
|
404
|
+
return (images,)
|