Skip to content

Commit e9a2d1e

Browse files
Add a way to disable default template in text gen node. (#13424)
1 parent 1de83f9 commit e9a2d1e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

comfy_extras/nodes_textgen.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,17 @@ def define_schema(cls):
3535
io.Int.Input("max_length", default=256, min=1, max=2048),
3636
io.DynamicCombo.Input("sampling_mode", options=sampling_options, display_name="Sampling Mode"),
3737
io.Boolean.Input("thinking", optional=True, default=False, tooltip="Operate in thinking mode if the model supports it."),
38+
io.Boolean.Input("use_default_template", optional=True, default=True, tooltip="Use the built in system prompt/template if the model has one.", advanced=True),
3839
],
3940
outputs=[
4041
io.String.Output(display_name="generated_text"),
4142
],
4243
)
4344

4445
@classmethod
45-
def execute(cls, clip, prompt, max_length, sampling_mode, image=None, thinking=False) -> io.NodeOutput:
46+
def execute(cls, clip, prompt, max_length, sampling_mode, image=None, thinking=False, use_default_template=True) -> io.NodeOutput:
4647

47-
tokens = clip.tokenize(prompt, image=image, skip_template=False, min_length=1, thinking=thinking)
48+
tokens = clip.tokenize(prompt, image=image, skip_template=not use_default_template, min_length=1, thinking=thinking)
4849

4950
# Get sampling parameters from dynamic combo
5051
do_sample = sampling_mode.get("sampling_mode") == "on"

0 commit comments

Comments
 (0)