mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-06-23 08:19:32 +08:00
Combine the comments and choices into a single function to ease
integration into various nodes.
This commit is contained in:
parent
6e881cfd4f
commit
9efdda21a8
@ -6,6 +6,13 @@ import random
|
|||||||
import comfy.parse as parse
|
import comfy.parse as parse
|
||||||
from comfy.parse import ParseError, ParseLogicError
|
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():
|
def get_random_seed():
|
||||||
return int.from_bytes(os.urandom(8))
|
return int.from_bytes(os.urandom(8))
|
||||||
|
|
||||||
|
|||||||
4
nodes.py
4
nodes.py
@ -15,7 +15,6 @@ import numpy as np
|
|||||||
import safetensors.torch
|
import safetensors.torch
|
||||||
|
|
||||||
import comfy.choices
|
import comfy.choices
|
||||||
import comfy.comments
|
|
||||||
|
|
||||||
sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(__file__)), "comfy"))
|
sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(__file__)), "comfy"))
|
||||||
|
|
||||||
@ -1482,8 +1481,7 @@ class DynamicPrompt:
|
|||||||
CATEGORY = "conditioning"
|
CATEGORY = "conditioning"
|
||||||
|
|
||||||
def dynamic_prompt(self, text, seed):
|
def dynamic_prompt(self, text, seed):
|
||||||
text = comfy.comments.strip_c_comments(text)
|
text = comfy.choices.translate_choices_with_c_comments(text, seed=seed, strict=False, reescape=r'\()')
|
||||||
text = comfy.choices.translate(text, seed=seed, strict=False, reescape=r'\()')
|
|
||||||
return (text,)
|
return (text,)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user