Skip to content

Commit ac26065

Browse files
authored
chore(api-nodes): remove non-used; extract model to separate files (#11927)
* chore(api-nodes): remove non-used; extract model to separate files * chore(api-nodes): remove non-needed prefix in filenames
1 parent 190c441 commit ac26065

40 files changed

+825
-641
lines changed

comfy_api_nodes/README.md

Lines changed: 0 additions & 65 deletions
This file was deleted.

comfy_api_nodes/apis/ideogram.py

Lines changed: 292 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,292 @@
1+
from enum import Enum
2+
from typing import Optional, List, Dict, Any, Union
3+
from datetime import datetime
4+
5+
from pydantic import BaseModel, Field, RootModel, StrictBytes
6+
7+
8+
class IdeogramColorPalette1(BaseModel):
9+
name: str = Field(..., description='Name of the preset color palette')
10+
11+
12+
class Member(BaseModel):
13+
color: Optional[str] = Field(
14+
None, description='Hexadecimal color code', pattern='^#[0-9A-Fa-f]{6}$'
15+
)
16+
weight: Optional[float] = Field(
17+
None, description='Optional weight for the color (0-1)', ge=0.0, le=1.0
18+
)
19+
20+
21+
class IdeogramColorPalette2(BaseModel):
22+
members: List[Member] = Field(
23+
..., description='Array of color definitions with optional weights'
24+
)
25+
26+
27+
class IdeogramColorPalette(
28+
RootModel[Union[IdeogramColorPalette1, IdeogramColorPalette2]]
29+
):
30+
root: Union[IdeogramColorPalette1, IdeogramColorPalette2] = Field(
31+
...,
32+
description='A color palette specification that can either use a preset name or explicit color definitions with weights',
33+
)
34+
35+
36+
class ImageRequest(BaseModel):
37+
aspect_ratio: Optional[str] = Field(
38+
None,
39+
description="Optional. The aspect ratio (e.g., 'ASPECT_16_9', 'ASPECT_1_1'). Cannot be used with resolution. Defaults to 'ASPECT_1_1' if unspecified.",
40+
)
41+
color_palette: Optional[Dict[str, Any]] = Field(
42+
None, description='Optional. Color palette object. Only for V_2, V_2_TURBO.'
43+
)
44+
magic_prompt_option: Optional[str] = Field(
45+
None, description="Optional. MagicPrompt usage ('AUTO', 'ON', 'OFF')."
46+
)
47+
model: str = Field(..., description="The model used (e.g., 'V_2', 'V_2A_TURBO')")
48+
negative_prompt: Optional[str] = Field(
49+
None,
50+
description='Optional. Description of what to exclude. Only for V_1, V_1_TURBO, V_2, V_2_TURBO.',
51+
)
52+
num_images: Optional[int] = Field(
53+
1,
54+
description='Optional. Number of images to generate (1-8). Defaults to 1.',
55+
ge=1,
56+
le=8,
57+
)
58+
prompt: str = Field(
59+
..., description='Required. The prompt to use to generate the image.'
60+
)
61+
resolution: Optional[str] = Field(
62+
None,
63+
description="Optional. Resolution (e.g., 'RESOLUTION_1024_1024'). Only for model V_2. Cannot be used with aspect_ratio.",
64+
)
65+
seed: Optional[int] = Field(
66+
None,
67+
description='Optional. A number between 0 and 2147483647.',
68+
ge=0,
69+
le=2147483647,
70+
)
71+
style_type: Optional[str] = Field(
72+
None,
73+
description="Optional. Style type ('AUTO', 'GENERAL', 'REALISTIC', 'DESIGN', 'RENDER_3D', 'ANIME'). Only for models V_2 and above.",
74+
)
75+
76+
77+
class IdeogramGenerateRequest(BaseModel):
78+
image_request: ImageRequest = Field(
79+
..., description='The image generation request parameters.'
80+
)
81+
82+
83+
class Datum(BaseModel):
84+
is_image_safe: Optional[bool] = Field(
85+
None, description='Indicates whether the image is considered safe.'
86+
)
87+
prompt: Optional[str] = Field(
88+
None, description='The prompt used to generate this image.'
89+
)
90+
resolution: Optional[str] = Field(
91+
None, description="The resolution of the generated image (e.g., '1024x1024')."
92+
)
93+
seed: Optional[int] = Field(
94+
None, description='The seed value used for this generation.'
95+
)
96+
style_type: Optional[str] = Field(
97+
None,
98+
description="The style type used for generation (e.g., 'REALISTIC', 'ANIME').",
99+
)
100+
url: Optional[str] = Field(None, description='URL to the generated image.')
101+
102+
103+
class IdeogramGenerateResponse(BaseModel):
104+
created: Optional[datetime] = Field(
105+
None, description='Timestamp when the generation was created.'
106+
)
107+
data: Optional[List[Datum]] = Field(
108+
None, description='Array of generated image information.'
109+
)
110+
111+
112+
class StyleCode(RootModel[str]):
113+
root: str = Field(..., pattern='^[0-9A-Fa-f]{8}$')
114+
115+
116+
class Datum1(BaseModel):
117+
is_image_safe: Optional[bool] = None
118+
prompt: Optional[str] = None
119+
resolution: Optional[str] = None
120+
seed: Optional[int] = None
121+
style_type: Optional[str] = None
122+
url: Optional[str] = None
123+
124+
125+
class IdeogramV3IdeogramResponse(BaseModel):
126+
created: Optional[datetime] = None
127+
data: Optional[List[Datum1]] = None
128+
129+
130+
class RenderingSpeed1(str, Enum):
131+
TURBO = 'TURBO'
132+
DEFAULT = 'DEFAULT'
133+
QUALITY = 'QUALITY'
134+
135+
136+
class IdeogramV3ReframeRequest(BaseModel):
137+
color_palette: Optional[Dict[str, Any]] = None
138+
image: Optional[StrictBytes] = None
139+
num_images: Optional[int] = Field(None, ge=1, le=8)
140+
rendering_speed: Optional[RenderingSpeed1] = None
141+
resolution: str
142+
seed: Optional[int] = Field(None, ge=0, le=2147483647)
143+
style_codes: Optional[List[str]] = None
144+
style_reference_images: Optional[List[StrictBytes]] = None
145+
146+
147+
class MagicPrompt(str, Enum):
148+
AUTO = 'AUTO'
149+
ON = 'ON'
150+
OFF = 'OFF'
151+
152+
153+
class StyleType(str, Enum):
154+
AUTO = 'AUTO'
155+
GENERAL = 'GENERAL'
156+
REALISTIC = 'REALISTIC'
157+
DESIGN = 'DESIGN'
158+
159+
160+
class IdeogramV3RemixRequest(BaseModel):
161+
aspect_ratio: Optional[str] = None
162+
color_palette: Optional[Dict[str, Any]] = None
163+
image: Optional[StrictBytes] = None
164+
image_weight: Optional[int] = Field(50, ge=1, le=100)
165+
magic_prompt: Optional[MagicPrompt] = None
166+
negative_prompt: Optional[str] = None
167+
num_images: Optional[int] = Field(None, ge=1, le=8)
168+
prompt: str
169+
rendering_speed: Optional[RenderingSpeed1] = None
170+
resolution: Optional[str] = None
171+
seed: Optional[int] = Field(None, ge=0, le=2147483647)
172+
style_codes: Optional[List[str]] = None
173+
style_reference_images: Optional[List[StrictBytes]] = None
174+
style_type: Optional[StyleType] = None
175+
176+
177+
class IdeogramV3ReplaceBackgroundRequest(BaseModel):
178+
color_palette: Optional[Dict[str, Any]] = None
179+
image: Optional[StrictBytes] = None
180+
magic_prompt: Optional[MagicPrompt] = None
181+
num_images: Optional[int] = Field(None, ge=1, le=8)
182+
prompt: str
183+
rendering_speed: Optional[RenderingSpeed1] = None
184+
seed: Optional[int] = Field(None, ge=0, le=2147483647)
185+
style_codes: Optional[List[str]] = None
186+
style_reference_images: Optional[List[StrictBytes]] = None
187+
188+
189+
class ColorPalette(BaseModel):
190+
name: str = Field(..., description='Name of the color palette', examples=['PASTEL'])
191+
192+
193+
class MagicPrompt2(str, Enum):
194+
ON = 'ON'
195+
OFF = 'OFF'
196+
197+
198+
class StyleType1(str, Enum):
199+
AUTO = 'AUTO'
200+
GENERAL = 'GENERAL'
201+
REALISTIC = 'REALISTIC'
202+
DESIGN = 'DESIGN'
203+
FICTION = 'FICTION'
204+
205+
206+
class RenderingSpeed(str, Enum):
207+
DEFAULT = 'DEFAULT'
208+
TURBO = 'TURBO'
209+
QUALITY = 'QUALITY'
210+
211+
212+
class IdeogramV3EditRequest(BaseModel):
213+
color_palette: Optional[IdeogramColorPalette] = None
214+
image: Optional[StrictBytes] = Field(
215+
None,
216+
description='The image being edited (max size 10MB); only JPEG, WebP and PNG formats are supported at this time.',
217+
)
218+
magic_prompt: Optional[str] = Field(
219+
None,
220+
description='Determine if MagicPrompt should be used in generating the request or not.',
221+
)
222+
mask: Optional[StrictBytes] = Field(
223+
None,
224+
description='A black and white image of the same size as the image being edited (max size 10MB). Black regions in the mask should match up with the regions of the image that you would like to edit; only JPEG, WebP and PNG formats are supported at this time.',
225+
)
226+
num_images: Optional[int] = Field(
227+
None, description='The number of images to generate.'
228+
)
229+
prompt: str = Field(
230+
..., description='The prompt used to describe the edited result.'
231+
)
232+
rendering_speed: RenderingSpeed
233+
seed: Optional[int] = Field(
234+
None, description='Random seed. Set for reproducible generation.'
235+
)
236+
style_codes: Optional[List[StyleCode]] = Field(
237+
None,
238+
description='A list of 8 character hexadecimal codes representing the style of the image. Cannot be used in conjunction with style_reference_images or style_type.',
239+
)
240+
style_reference_images: Optional[List[StrictBytes]] = Field(
241+
None,
242+
description='A set of images to use as style references (maximum total size 10MB across all style references). The images should be in JPEG, PNG or WebP format.',
243+
)
244+
character_reference_images: Optional[List[str]] = Field(
245+
None,
246+
description='Generations with character reference are subject to the character reference pricing. A set of images to use as character references (maximum total size 10MB across all character references), currently only supports 1 character reference image. The images should be in JPEG, PNG or WebP format.'
247+
)
248+
character_reference_images_mask: Optional[List[str]] = Field(
249+
None,
250+
description='Optional masks for character reference images. When provided, must match the number of character_reference_images. Each mask should be a grayscale image of the same dimensions as the corresponding character reference image. The images should be in JPEG, PNG or WebP format.'
251+
)
252+
253+
254+
class IdeogramV3Request(BaseModel):
255+
aspect_ratio: Optional[str] = Field(
256+
None, description='Aspect ratio in format WxH', examples=['1x3']
257+
)
258+
color_palette: Optional[ColorPalette] = None
259+
magic_prompt: Optional[MagicPrompt2] = Field(
260+
None, description='Whether to enable magic prompt enhancement'
261+
)
262+
negative_prompt: Optional[str] = Field(
263+
None, description='Text prompt specifying what to avoid in the generation'
264+
)
265+
num_images: Optional[int] = Field(
266+
None, description='Number of images to generate', ge=1
267+
)
268+
prompt: str = Field(..., description='The text prompt for image generation')
269+
rendering_speed: RenderingSpeed
270+
resolution: Optional[str] = Field(
271+
None, description='Image resolution in format WxH', examples=['1280x800']
272+
)
273+
seed: Optional[int] = Field(
274+
None, description='Seed value for reproducible generation'
275+
)
276+
style_codes: Optional[List[StyleCode]] = Field(
277+
None, description='Array of style codes in hexadecimal format'
278+
)
279+
style_reference_images: Optional[List[str]] = Field(
280+
None, description='Array of reference image URLs or identifiers'
281+
)
282+
style_type: Optional[StyleType1] = Field(
283+
None, description='The type of style to apply'
284+
)
285+
character_reference_images: Optional[List[str]] = Field(
286+
None,
287+
description='Generations with character reference are subject to the character reference pricing. A set of images to use as character references (maximum total size 10MB across all character references), currently only supports 1 character reference image. The images should be in JPEG, PNG or WebP format.'
288+
)
289+
character_reference_images_mask: Optional[List[str]] = Field(
290+
None,
291+
description='Optional masks for character reference images. When provided, must match the number of character_reference_images. Each mask should be a grayscale image of the same dimensions as the corresponding character reference image. The images should be in JPEG, PNG or WebP format.'
292+
)

0 commit comments

Comments
 (0)