[Bugfix] Add bot_task option of think_recaption for hunyuanimage3 it2i (#3551)

Signed-off-by: zengchuang <zengchuang3@huawei.com>
This commit is contained in:
Zeng Chuang authored and GitHub committed 2026-05-13 22:10:35 +08:00
1 parent b9cb57b631
commit 16a84b29d5
3 files changed
+5 -2

No files matched your search

@@ -136,7 +136,7 @@ def main():
if task not in _TASK_PRESETS: if task not in _TASK_PRESETS:
valid_bot_tasks = { valid_bot_tasks = {
"text2img": ["think", "recaption", "vanilla"], "text2img": ["think", "recaption", "vanilla"],
"img2img": ["think", "recaption"], "img2img": ["think", "recaption", "think_recaption"],
"img2text": ["auto"], "img2text": ["auto"],
"text2text": ["auto"], "text2text": ["auto"],
}[args.modality] }[args.modality]
@@ -78,6 +78,7 @@ def test_available_tasks_covers_all_modalities():
"i2t", "i2t",
"it2i_think", "it2i_think",
"it2i_recaption", "it2i_recaption",
"it2i_think_recaption",
"t2i_think", "t2i_think",
"t2i_recaption", "t2i_recaption",
"t2i_vanilla", "t2i_vanilla",
@@ -99,6 +100,7 @@ def test_resolve_stop_token_ids_uses_answer_for_generation_tasks():
"i2t", "i2t",
"it2i_think", "it2i_think",
"it2i_recaption", "it2i_recaption",
"it2i_think_recaption",
"t2i_think", "t2i_think",
"t2i_recaption", "t2i_recaption",
], ],
@@ -125,7 +127,7 @@ def test_build_prompt_string_structure_chat_template(task: str):
# documentation, so substring index() catches the wrong occurrence -- use # documentation, so substring index() catches the wrong occurrence -- use
# endswith() which directly captures "trigger is at the tail" (the Part A # endswith() which directly captures "trigger is at the tail" (the Part A
# fix: trigger goes AFTER `Assistant: `, not before user_prompt). # fix: trigger goes AFTER `Assistant: `, not before user_prompt).
if task in ("it2i_think", "t2i_think"): if task in ("it2i_think", "t2i_think", "it2i_think_recaption"):
assert s.endswith("Assistant: <think>"), ( assert s.endswith("Assistant: <think>"), (
f"Trigger <think> must be appended right after `Assistant: ` (Part A fix). Got tail: ...{s[-40:]!r}" f"Trigger <think> must be appended right after `Assistant: ` (Part A fix). Got tail: ...{s[-40:]!r}"
) )
@@ -51,6 +51,7 @@ _TASK_PRESETS: dict[str, tuple[str, str | None, str | None]] = {
"i2t": ("en_unified", None, None), "i2t": ("en_unified", None, None),
"it2i_think": ("en_unified", "think", "<think>"), "it2i_think": ("en_unified", "think", "<think>"),
"it2i_recaption": ("en_unified", "recaption", "<recaption>"), "it2i_recaption": ("en_unified", "recaption", "<recaption>"),
"it2i_think_recaption": ("en_unified", "think_recaption", "<think>"),
"t2i": ("en_unified", "image", None), "t2i": ("en_unified", "image", None),
"t2i_vanilla": ("en_vanilla", "image", None), "t2i_vanilla": ("en_vanilla", "image", None),
"t2i_think": ("en_unified", "think", "<think>"), "t2i_think": ("en_unified", "think", "<think>"),