From bceccbcf0697e339d03a1e75320cd376ce570aed Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 3 Feb 2026 23:03:53 +0000 Subject: [PATCH] Improve documentation for normalize_prompt_text function Co-authored-by: jags111 <5968619+jags111@users.noreply.github.com> --- py/bnk_adv_encode.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/py/bnk_adv_encode.py b/py/bnk_adv_encode.py index 2b97df6..10795ee 100644 --- a/py/bnk_adv_encode.py +++ b/py/bnk_adv_encode.py @@ -9,8 +9,21 @@ from comfy.sdxl_clip import SDXLClipModel, SDXLRefinerClipModel, SDXLClipG def normalize_prompt_text(text): """ Normalize prompt text to prevent tokenization errors. + Converts None, empty strings, or whitespace-only strings to a single space. - Ensures the input is a string type. + Ensures the input is a string type by converting non-string values. + This function is designed to handle edge cases gracefully without crashing, + which is important for ComfyUI workflows where users might have empty prompts. + + Parameters: + text: The input prompt text to normalize. Can be of any type, though + string, None, or convertible types are expected. + + Returns: + str: A normalized string that is safe to pass to the tokenizer. + Returns " " (single space) for None, empty, or whitespace-only inputs. + Returns the original text unchanged if it's a valid non-empty string. + Returns str(text) for non-string types. """ if text is None: return " "