diff --git a/comfy_api_nodes/apis/recraft_api.py b/comfy_api_nodes/apis/recraft_api.py index aee3d39b6..da6232992 100644 --- a/comfy_api_nodes/apis/recraft_api.py +++ b/comfy_api_nodes/apis/recraft_api.py @@ -71,11 +71,12 @@ class RecraftControls: class RecraftStyle: - def __init__(self, style: str, substyle: str=None): + def __init__(self, style: str=None, substyle: str=None, style_id: str=None): self.style = style if substyle == "None": substyle = None self.substyle = substyle + self.style_id = style_id class RecraftIO: @@ -244,6 +245,7 @@ class RecraftImageGenerationRequest(BaseModel): style: Optional[str] = Field(None, description='The style to apply to the generated image (e.g., "digital_illustration")') substyle: Optional[str] = Field(None, description='The substyle to apply to the generated image, depending on the style input') controls: Optional[RecraftControlsObject] = Field(None, description='A set of custom parameters to tweak generation process') + style_id: Optional[str] = Field(None, description='Use a previously uploaded style as a reference; UUID') # text_layout diff --git a/comfy_api_nodes/nodes_recraft.py b/comfy_api_nodes/nodes_recraft.py index fd93ea7d5..80cccd969 100644 --- a/comfy_api_nodes/nodes_recraft.py +++ b/comfy_api_nodes/nodes_recraft.py @@ -48,6 +48,7 @@ class SaveSVGNode: self.prefix_append = "" RETURN_TYPES = () + DESCRIPTION = cleandoc(__doc__ or "") # Handle potential None value FUNCTION = "save_svg" CATEGORY = "api node/image/Recraft" OUTPUT_NODE = True @@ -100,6 +101,7 @@ class RecraftColorRGBNode: """ RETURN_TYPES = (RecraftIO.COLOR,) + DESCRIPTION = cleandoc(__doc__ or "") # Handle potential None value RETURN_NAMES = ("recraft_color",) FUNCTION = "create_color" CATEGORY = "api node/image/Recraft" @@ -145,6 +147,7 @@ class RecraftControlsNode: RETURN_TYPES = (RecraftIO.CONTROLS,) RETURN_NAMES = ("recraft_controls",) + DESCRIPTION = cleandoc(__doc__ or "") # Handle potential None value FUNCTION = "create_controls" CATEGORY = "api node/image/Recraft" @@ -170,6 +173,7 @@ class RecraftStyleV3RealisticImageNode: RETURN_TYPES = (RecraftIO.STYLEV3,) RETURN_NAMES = ("recraft_style",) + DESCRIPTION = cleandoc(__doc__ or "") # Handle potential None value FUNCTION = "create_style" CATEGORY = "api node/image/Recraft" @@ -221,6 +225,34 @@ class RecraftStyleV3LogoRasterNode(RecraftStyleV3RealisticImageNode): RECRAFT_STYLE = RecraftStyleV3.logo_raster +class RecraftStyleInfiniteStyleLibrary: + """ + Select style based on preexisting UUID from the Infinite Style Library. + """ + + RETURN_TYPES = (RecraftIO.STYLEV3,) + RETURN_NAMES = ("recraft_style",) + DESCRIPTION = cleandoc(__doc__ or "") # Handle potential None value + FUNCTION = "create_style" + CATEGORY = "api node/image/Recraft" + + @classmethod + def INPUT_TYPES(s): + return { + "required": { + "style_id": (IO.STRING, { + "default": "", + "tooltip": "UUID of style from Infinite Style Library.", + }) + } + } + + def create_style(self, style_id: str): + if not style_id: + raise Exception("The style_id input cannot be empty.") + return (RecraftStyle(style_id=style_id),) + + class RecraftTextToImageNode: """ Generates images synchronously based on prompt and resolution. @@ -305,7 +337,7 @@ class RecraftTextToImageNode: auth_token=None, **kwargs, ): - default_style = RecraftStyle(RecraftStyleV3.digital_illustration) + default_style = RecraftStyle(RecraftStyleV3.realistic_image) if recraft_style is None: recraft_style = default_style @@ -331,6 +363,7 @@ class RecraftTextToImageNode: n=n, style=recraft_style.style, substyle=recraft_style.substyle, + style_id=recraft_style.style_id, controls=controls_api, ), auth_token=auth_token, @@ -478,6 +511,7 @@ NODE_CLASS_MAPPINGS = { "RecraftStyleV3RealisticImage": RecraftStyleV3RealisticImageNode, "RecraftStyleV3DigitalIllustration": RecraftStyleV3DigitalIllustrationNode, "RecraftStyleV3LogoRaster": RecraftStyleV3LogoRasterNode, + "RecraftStyleV3InfiniteStyleLibrary": RecraftStyleInfiniteStyleLibrary, "RecraftColorRGB": RecraftColorRGBNode, "RecraftControls": RecraftControlsNode, "SaveSVG": SaveSVGNode, @@ -490,6 +524,7 @@ NODE_DISPLAY_NAME_MAPPINGS = { "RecraftStyleV3RealisticImage": "Recraft Style - Realistic Image", "RecraftStyleV3DigitalIllustration": "Recraft Style - Digital Illustration", "RecraftStyleV3LogoRaster": "Recraft Style - Logo Raster", + "RecraftStyleV3InfiniteStyleLibrary": "Recraft Style - Infinite Style Library", "RecraftColorRGB": "Recraft Color RGB", "RecraftControls": "Recraft Controls", "SaveSVG": "Save SVG",