From a531001cc772305364a319a760fcd5034e28411a Mon Sep 17 00:00:00 2001
From: comfyanonymous <comfyanonymous@protonmail.com>
Date: Thu, 1 Aug 2024 18:53:25 -0400
Subject: [PATCH] Add CLIPTextEncodeFlux.

---
 comfy_extras/nodes_flux.py | 27 +++++++++++++++++++++++++++
 nodes.py                   |  1 +
 2 files changed, 28 insertions(+)
 create mode 100644 comfy_extras/nodes_flux.py

diff --git a/comfy_extras/nodes_flux.py b/comfy_extras/nodes_flux.py
new file mode 100644
index 00000000..6c1e8b0e
--- /dev/null
+++ b/comfy_extras/nodes_flux.py
@@ -0,0 +1,27 @@
+
+class CLIPTextEncodeFlux:
+    @classmethod
+    def INPUT_TYPES(s):
+        return {"required": {
+            "clip": ("CLIP", ),
+            "clip_l": ("STRING", {"multiline": True, "dynamicPrompts": True}),
+            "t5xxl": ("STRING", {"multiline": True, "dynamicPrompts": True}),
+            "guidance": ("FLOAT", {"default": 3.5, "min": 0.0, "max": 100.0, "step": 0.1}),
+            }}
+    RETURN_TYPES = ("CONDITIONING",)
+    FUNCTION = "encode"
+
+    CATEGORY = "advanced/conditioning"
+
+    def encode(self, clip, clip_l, t5xxl, guidance):
+        tokens = clip.tokenize(clip_l)
+        tokens["t5xxl"] = clip.tokenize(t5xxl)["t5xxl"]
+
+        output = clip.encode_from_tokens(tokens, return_pooled=True, return_dict=True)
+        cond = output.pop("cond")
+        output["guidance"] = guidance
+        return ([[cond, output]], )
+
+NODE_CLASS_MAPPINGS = {
+    "CLIPTextEncodeFlux": CLIPTextEncodeFlux,
+}
diff --git a/nodes.py b/nodes.py
index 5b6321b6..1994f119 100644
--- a/nodes.py
+++ b/nodes.py
@@ -2043,6 +2043,7 @@ def init_builtin_extra_nodes():
         "nodes_gits.py",
         "nodes_controlnet.py",
         "nodes_hunyuan.py",
+        "nodes_flux.py",
     ]
 
     import_failed = []