|  | 
| 1 |  | -from nodes import MAX_RESOLUTION | 
|  | 1 | +from typing_extensions import override | 
|  | 2 | +import nodes | 
|  | 3 | +from comfy_api.latest import ComfyExtension, io | 
| 2 | 4 | 
 | 
| 3 |  | -class CLIPTextEncodePixArtAlpha: | 
|  | 5 | +class CLIPTextEncodePixArtAlpha(io.ComfyNode): | 
| 4 | 6 |     @classmethod | 
| 5 |  | -    def INPUT_TYPES(s): | 
| 6 |  | -        return {"required": { | 
| 7 |  | -            "width": ("INT", {"default": 1024.0, "min": 0, "max": MAX_RESOLUTION}), | 
| 8 |  | -            "height": ("INT", {"default": 1024.0, "min": 0, "max": MAX_RESOLUTION}), | 
| 9 |  | -            # "aspect_ratio": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.01}), | 
| 10 |  | -            "text": ("STRING", {"multiline": True, "dynamicPrompts": True}), "clip": ("CLIP", ), | 
| 11 |  | -            }} | 
|  | 7 | +    def define_schema(cls): | 
|  | 8 | +        return io.Schema( | 
|  | 9 | +            node_id="CLIPTextEncodePixArtAlpha", | 
|  | 10 | +            category="advanced/conditioning", | 
|  | 11 | +            description="Encodes text and sets the resolution conditioning for PixArt Alpha. Does not apply to PixArt Sigma.", | 
|  | 12 | +            inputs=[ | 
|  | 13 | +                io.Int.Input("width", default=1024, min=0, max=nodes.MAX_RESOLUTION), | 
|  | 14 | +                io.Int.Input("height", default=1024, min=0, max=nodes.MAX_RESOLUTION), | 
|  | 15 | +                # "aspect_ratio": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.01}), | 
|  | 16 | +                io.String.Input("text", multiline=True, dynamic_prompts=True), | 
|  | 17 | +                io.Clip.Input("clip"), | 
|  | 18 | +            ], | 
|  | 19 | +            outputs=[ | 
|  | 20 | +                io.Conditioning.Output(), | 
|  | 21 | +            ], | 
|  | 22 | +        ) | 
| 12 | 23 | 
 | 
| 13 |  | -    RETURN_TYPES = ("CONDITIONING",) | 
| 14 |  | -    FUNCTION = "encode" | 
| 15 |  | -    CATEGORY = "advanced/conditioning" | 
| 16 |  | -    DESCRIPTION = "Encodes text and sets the resolution conditioning for PixArt Alpha. Does not apply to PixArt Sigma." | 
| 17 |  | - | 
| 18 |  | -    def encode(self, clip, width, height, text): | 
|  | 24 | +    @classmethod | 
|  | 25 | +    def execute(cls, clip, width, height, text): | 
| 19 | 26 |         tokens = clip.tokenize(text) | 
| 20 |  | -        return (clip.encode_from_tokens_scheduled(tokens, add_dict={"width": width, "height": height}),) | 
|  | 27 | +        return io.NodeOutput(clip.encode_from_tokens_scheduled(tokens, add_dict={"width": width, "height": height})) | 
|  | 28 | + | 
|  | 29 | + | 
|  | 30 | +class PixArtExtension(ComfyExtension): | 
|  | 31 | +    @override | 
|  | 32 | +    async def get_node_list(self) -> list[type[io.ComfyNode]]: | 
|  | 33 | +        return [ | 
|  | 34 | +            CLIPTextEncodePixArtAlpha, | 
|  | 35 | +        ] | 
| 21 | 36 | 
 | 
| 22 |  | -NODE_CLASS_MAPPINGS = { | 
| 23 |  | -    "CLIPTextEncodePixArtAlpha": CLIPTextEncodePixArtAlpha, | 
| 24 |  | -} | 
|  | 37 | +async def comfy_entrypoint() -> PixArtExtension: | 
|  | 38 | +    return PixArtExtension() | 
0 commit comments