Skip to content

Commit d43d6d4

Browse files
committed
[Partner Nodes] feat(Pixverse): add Pixverse V6 model support
Signed-off-by: Alexander Piskun <bigcat88@icloud.com>
1 parent a1079ba commit d43d6d4

2 files changed

Lines changed: 757 additions & 90 deletions

File tree

comfy_api_nodes/apis/pixverse.py

Lines changed: 136 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
from __future__ import annotations
2-
31
from enum import Enum
4-
from typing import Optional
52

63
from pydantic import BaseModel, Field
74

@@ -60,87 +57,174 @@ class PixverseStyle(str, Enum):
6057
cyberpunk = "cyberpunk"
6158

6259

63-
# NOTE: forgoing descriptions for now in return for dev speed
6460
class PixverseTextVideoRequest(BaseModel):
6561
aspect_ratio: PixverseAspectRatio = Field(...)
6662
quality: PixverseQuality = Field(...)
6763
duration: PixverseDuration = Field(...)
68-
model: Optional[str] = Field("v3.5")
69-
motion_mode: Optional[PixverseMotionMode] = Field(PixverseMotionMode.normal)
64+
model: str | None = Field("v3.5")
65+
motion_mode: PixverseMotionMode | None = Field(PixverseMotionMode.normal)
7066
prompt: str = Field(...)
71-
negative_prompt: Optional[str] = Field(None)
72-
seed: Optional[int] = Field(None)
73-
style: Optional[str] = Field(None)
74-
template_id: Optional[int] = Field(None)
75-
water_mark: Optional[bool] = Field(None)
67+
negative_prompt: str | None = Field(None)
68+
seed: int | None = Field(None)
69+
style: str | None = Field(None)
70+
template_id: int | None = Field(None)
71+
water_mark: bool | None = Field(None)
7672

7773

7874
class PixverseImageVideoRequest(BaseModel):
7975
quality: PixverseQuality = Field(...)
8076
duration: PixverseDuration = Field(...)
8177
img_id: int = Field(...)
82-
model: Optional[str] = Field("v3.5")
83-
motion_mode: Optional[PixverseMotionMode] = Field(PixverseMotionMode.normal)
78+
model: str | None = Field("v3.5")
79+
motion_mode: PixverseMotionMode | None = Field(PixverseMotionMode.normal)
8480
prompt: str = Field(...)
85-
negative_prompt: Optional[str] = Field(None)
86-
seed: Optional[int] = Field(None)
87-
style: Optional[str] = Field(None)
88-
template_id: Optional[int] = Field(None)
89-
water_mark: Optional[bool] = Field(None)
81+
negative_prompt: str | None = Field(None)
82+
seed: int | None = Field(None)
83+
style: str | None = Field(None)
84+
template_id: int | None = Field(None)
85+
water_mark: bool | None = Field(None)
9086

9187

9288
class PixverseTransitionVideoRequest(BaseModel):
9389
quality: PixverseQuality = Field(...)
9490
duration: PixverseDuration = Field(...)
9591
first_frame_img: int = Field(...)
9692
last_frame_img: int = Field(...)
97-
model: Optional[str] = Field("v3.5")
98-
motion_mode: Optional[PixverseMotionMode] = Field(PixverseMotionMode.normal)
93+
model: str | None = Field("v3.5")
94+
motion_mode: PixverseMotionMode | None = Field(PixverseMotionMode.normal)
9995
prompt: str = Field(...)
100-
# negative_prompt: Optional[str] = Field(None)
101-
seed: Optional[int] = Field(None)
102-
# style: Optional[str] = Field(None)
103-
# template_id: Optional[int] = Field(None)
104-
# water_mark: Optional[bool] = Field(None)
96+
seed: int | None = Field(None)
97+
98+
99+
class PixverseImgIdResponseObject(BaseModel):
100+
img_id: int | None = None
105101

106102

107103
class PixverseImageUploadResponse(BaseModel):
108-
ErrCode: Optional[int] = None
109-
ErrMsg: Optional[str] = None
110-
Resp: Optional[PixverseImgIdResponseObject] = Field(None, alias='Resp')
104+
ErrCode: int | None = None
105+
ErrMsg: str | None = None
106+
Resp: PixverseImgIdResponseObject | None = Field(None)
111107

112108

113-
class PixverseImgIdResponseObject(BaseModel):
114-
img_id: Optional[int] = None
109+
class PixverseVideoIdResponseObject(BaseModel):
110+
video_id: int = Field(...)
111+
credits: int | None = Field(None)
115112

116113

117114
class PixverseVideoResponse(BaseModel):
118-
ErrCode: Optional[int] = Field(None)
119-
ErrMsg: Optional[str] = Field(None)
120-
Resp: Optional[PixverseVideoIdResponseObject] = Field(None)
115+
ErrCode: int | None = Field(None)
116+
ErrMsg: str | None = Field(None)
117+
Resp: PixverseVideoIdResponseObject | None = Field(None)
121118

122119

123-
class PixverseVideoIdResponseObject(BaseModel):
124-
video_id: int = Field(..., description='Video_id')
120+
class PixverseGenerationStatusResponseObject(BaseModel):
121+
create_time: str | None = Field(None)
122+
id: int | None = Field(None)
123+
modify_time: str | None = Field(None)
124+
negative_prompt: str | None = Field(None)
125+
outputHeight: int | None = Field(None)
126+
outputWidth: int | None = Field(None)
127+
prompt: str | None = Field(None)
128+
resolution_ratio: int | None = Field(None)
129+
seed: int | None = Field(None)
130+
size: int | None = Field(None)
131+
status: int | None = Field(None)
132+
style: str | None = Field(None)
133+
has_audio: bool | None = Field(None)
134+
credits: int | None = Field(None)
135+
url: str | None = Field(None)
125136

126137

127138
class PixverseGenerationStatusResponse(BaseModel):
128-
ErrCode: Optional[int] = Field(None)
129-
ErrMsg: Optional[str] = Field(None)
130-
Resp: Optional[PixverseGenerationStatusResponseObject] = Field(None)
139+
ErrCode: int | None = Field(None)
140+
ErrMsg: str | None = Field(None)
141+
Resp: PixverseGenerationStatusResponseObject | None = Field(None)
131142

132143

133-
class PixverseGenerationStatusResponseObject(BaseModel):
134-
create_time: Optional[str] = Field(None)
135-
id: Optional[int] = Field(None)
136-
modify_time: Optional[str] = Field(None)
137-
negative_prompt: Optional[str] = Field(None)
138-
outputHeight: Optional[int] = Field(None)
139-
outputWidth: Optional[int] = Field(None)
140-
prompt: Optional[str] = Field(None)
141-
resolution_ratio: Optional[int] = Field(None)
142-
seed: Optional[int] = Field(None)
143-
size: Optional[int] = Field(None)
144-
status: Optional[int] = Field(None)
145-
style: Optional[str] = Field(None)
146-
url: Optional[str] = Field(None)
144+
class PixverseV6AspectRatio(str, Enum):
145+
ratio_16_9 = "16:9"
146+
ratio_4_3 = "4:3"
147+
ratio_1_1 = "1:1"
148+
ratio_3_4 = "3:4"
149+
ratio_9_16 = "9:16"
150+
ratio_2_3 = "2:3"
151+
ratio_3_2 = "3:2"
152+
ratio_21_9 = "21:9"
153+
154+
155+
class PixverseV6Style(str, Enum):
156+
none = "none"
157+
anime = "anime"
158+
animation_3d = "3d_animation"
159+
clay = "clay"
160+
comic = "comic"
161+
cyberpunk = "cyberpunk"
162+
realistic = "realistic"
163+
164+
165+
class PixverseReferenceType(str, Enum):
166+
subject = "subject"
167+
background = "background"
168+
169+
170+
class PixverseImageReference(BaseModel):
171+
img_id: int = Field(...)
172+
ref_name: str = Field(...)
173+
type: PixverseReferenceType = Field(...)
174+
175+
176+
class PixverseVideoReference(BaseModel):
177+
ref_name: str = Field(...)
178+
video_media_id: int | None = Field(None)
179+
source_video_id: int | None = Field(None)
180+
181+
182+
class PixverseV6BaseRequest(BaseModel):
183+
model: str = Field("v6")
184+
prompt: str = Field(...)
185+
duration: int = Field(...)
186+
quality: PixverseQuality = Field(...)
187+
negative_prompt: str | None = Field(None)
188+
seed: int | None = Field(None)
189+
style: str | None = Field(None)
190+
generate_audio_switch: bool | None = Field(None)
191+
192+
193+
class PixverseV6TextVideoRequest(PixverseV6BaseRequest):
194+
aspect_ratio: PixverseV6AspectRatio = Field(...)
195+
generate_multi_clip_switch: bool | None = Field(None)
196+
197+
198+
class PixverseV6ImageVideoRequest(PixverseV6BaseRequest):
199+
img_id: int = Field(...)
200+
generate_multi_clip_switch: bool | None = Field(None)
201+
202+
203+
class PixverseV6TransitionVideoRequest(PixverseV6BaseRequest):
204+
first_frame_img: int = Field(...)
205+
last_frame_img: int = Field(...)
206+
207+
208+
class PixverseV6ExtendVideoRequest(PixverseV6BaseRequest):
209+
video_media_id: int = Field(...)
210+
211+
212+
class PixverseV6FusionVideoRequest(PixverseV6BaseRequest):
213+
aspect_ratio: str = Field(...)
214+
image_references: list[PixverseImageReference] | None = Field(None)
215+
video_references: list[PixverseVideoReference] | None = Field(None)
216+
reference_mode: str | None = Field(None)
217+
218+
219+
class PixverseMediaIdResponseObject(BaseModel):
220+
media_id: int | None = Field(None)
221+
media_type: str | None = Field(None)
222+
url: str | None = Field(None)
223+
width: int | None = Field(None)
224+
height: int | None = Field(None)
225+
226+
227+
class PixverseMediaUploadResponse(BaseModel):
228+
ErrCode: int | None = Field(None)
229+
ErrMsg: str | None = Field(None)
230+
Resp: PixverseMediaIdResponseObject | None = Field(None)

0 commit comments

Comments
 (0)