Combine the comments and choices into a single function to ease

integration into various nodes.
This commit is contained in:
Barry Downes 2023-08-06 08:47:19 +10:00
parent 6e881cfd4f
commit 9efdda21a8
2 changed files with 8 additions and 3 deletions

View File

@ -6,6 +6,13 @@ import random
import comfy.parse as parse
from comfy.parse import ParseError, ParseLogicError
from comfy.comments import strip_c_comments
def translate_choices_with_c_comments(text, seed=None, strict=True, reescape=frozenset()):
text = strip_c_comments(text, strict=strict)
text = translate(text, seed=seed, strict=strict, reescape = reescape)
return text
def get_random_seed():
return int.from_bytes(os.urandom(8))

View File

@ -15,7 +15,6 @@ import numpy as np
import safetensors.torch
import comfy.choices
import comfy.comments
sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(__file__)), "comfy"))
@ -1482,8 +1481,7 @@ class DynamicPrompt:
CATEGORY = "conditioning"
def dynamic_prompt(self, text, seed):
text = comfy.comments.strip_c_comments(text)
text = comfy.choices.translate(text, seed=seed, strict=False, reescape=r'\()')
text = comfy.choices.translate_choices_with_c_comments(text, seed=seed, strict=False, reescape=r'\()')
return (text,)