Refactor validation into shared helper function and improve type handling

Co-authored-by: jags111 <5968619+jags111@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-02-03 23:03:17 +00:00
parent 94c9d05e2e
commit 3fa0e8c927
2 changed files with 21 additions and 10 deletions

View File

@@ -53,6 +53,7 @@ from .py import city96_latent_upscaler
from .py import ttl_nn_latent_upscaler
from .py import bnk_tiled_samplers
from .py import bnk_adv_encode
from .py.bnk_adv_encode import normalize_prompt_text
sys.path.remove(my_dir)
from comfy import samplers
@@ -73,10 +74,8 @@ def encode_prompts(positive_prompt, negative_prompt, token_normalization, weight
return_type="both"):
# Ensure prompts are valid strings to prevent tokenization errors
if positive_prompt is None or (isinstance(positive_prompt, str) and not positive_prompt.strip()):
positive_prompt = " "
if negative_prompt is None or (isinstance(negative_prompt, str) and not negative_prompt.strip()):
negative_prompt = " "
positive_prompt = normalize_prompt_text(positive_prompt)
negative_prompt = normalize_prompt_text(negative_prompt)
positive_encoded = negative_encoded = refiner_positive_encoded = refiner_negative_encoded = None