[Partner Nodes] feat(Seedream): add widget to disable thinking (#14853)

Signed-off-by: bigcat88 <bigcat88@icloud.com>
Co-authored-by: Daxiong (Lin) <contact@comfyui-wiki.com>
This commit is contained in:
Alexander Piskun 2026-07-10 11:58:22 +03:00 committed by GitHub
parent 8e2e54e2b8
commit 89ecc5cf8c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 26 additions and 0 deletions

View File

@ -17,6 +17,10 @@ class Seedream4Options(BaseModel):
max_images: int = Field(15) max_images: int = Field(15)
class Seedream5OptimizePromptOptions(BaseModel):
thinking: Literal["auto", "enabled", "disabled"] = Field(...)
class Seedream4TaskCreationRequest(BaseModel): class Seedream4TaskCreationRequest(BaseModel):
model: str = Field(...) model: str = Field(...)
prompt: str = Field(...) prompt: str = Field(...)
@ -28,6 +32,7 @@ class Seedream4TaskCreationRequest(BaseModel):
sequential_image_generation_options: Seedream4Options | None = Field(Seedream4Options(max_images=15)) sequential_image_generation_options: Seedream4Options | None = Field(Seedream4Options(max_images=15))
watermark: bool = Field(False) watermark: bool = Field(False)
output_format: str | None = None output_format: str | None = None
optimize_prompt_options: Seedream5OptimizePromptOptions | None = None
class ImageTaskCreationResponse(BaseModel): class ImageTaskCreationResponse(BaseModel):

View File

@ -34,6 +34,7 @@ from comfy_api_nodes.apis.bytedance import (
SeedanceVirtualLibraryCreateAssetRequest, SeedanceVirtualLibraryCreateAssetRequest,
Seedream4Options, Seedream4Options,
Seedream4TaskCreationRequest, Seedream4TaskCreationRequest,
Seedream5OptimizePromptOptions,
TaskAudioContent, TaskAudioContent,
TaskAudioContentUrl, TaskAudioContentUrl,
TaskCreationResponse, TaskCreationResponse,
@ -875,6 +876,17 @@ class ByteDanceSeedreamNodeV2(IO.ComfyNode):
tooltip='Whether to add an "AI generated" watermark to the image.', tooltip='Whether to add an "AI generated" watermark to the image.',
advanced=True, advanced=True,
), ),
IO.Boolean.Input(
"thinking",
default=True,
tooltip=(
"Enable the model's prompt-optimization reasoning ('thinking') for better adherence. "
"Can substantially increase generation time — notably on Seedream 5.0 Pro. "
"Can only be disabled for text-to-image (not when reference images are provided)."
),
optional=True,
advanced=True,
),
], ],
outputs=[ outputs=[
IO.Image.Output(), IO.Image.Output(),
@ -920,6 +932,7 @@ class ByteDanceSeedreamNodeV2(IO.ComfyNode):
model: dict, model: dict,
seed: int = 0, seed: int = 0,
watermark: bool = False, watermark: bool = False,
thinking: bool = True,
) -> IO.NodeOutput: ) -> IO.NodeOutput:
validate_string(prompt, strip_whitespace=True, min_length=1) validate_string(prompt, strip_whitespace=True, min_length=1)
model_id = SEEDREAM_MODELS[model["model"]] model_id = SEEDREAM_MODELS[model["model"]]
@ -979,6 +992,10 @@ class ByteDanceSeedreamNodeV2(IO.ComfyNode):
raise ValueError( raise ValueError(
"The maximum number of generated images plus the number of reference images cannot exceed 15." "The maximum number of generated images plus the number of reference images cannot exceed 15."
) )
if not thinking and n_input_images > 0:
raise ValueError(
"'thinking' can only be disabled for text-to-image; enable it when using reference images."
)
reference_images_urls: list[str] = [] reference_images_urls: list[str] = []
if image_tensors: if image_tensors:
@ -992,6 +1009,9 @@ class ByteDanceSeedreamNodeV2(IO.ComfyNode):
wait_label="Uploading reference images", wait_label="Uploading reference images",
) )
optimize_prompt_options = None
if n_input_images == 0:
optimize_prompt_options = Seedream5OptimizePromptOptions(thinking="enabled" if thinking else "disabled")
response = await sync_op( response = await sync_op(
cls, cls,
ApiEndpoint(path=BYTEPLUS_IMAGE_ENDPOINT, method="POST"), ApiEndpoint(path=BYTEPLUS_IMAGE_ENDPOINT, method="POST"),
@ -1005,6 +1025,7 @@ class ByteDanceSeedreamNodeV2(IO.ComfyNode):
sequential_image_generation=None if is_pro else sequential_image_generation, sequential_image_generation=None if is_pro else sequential_image_generation,
sequential_image_generation_options=None if is_pro else Seedream4Options(max_images=max_images), sequential_image_generation_options=None if is_pro else Seedream4Options(max_images=max_images),
watermark=watermark, watermark=watermark,
optimize_prompt_options=optimize_prompt_options,
), ),
) )
if len(response.data) == 1: if len(response.data) == 1: