Translate think tokens

This commit is contained in:
kijai 2026-04-12 21:25:19 +03:00
parent 387e8d8a4c
commit c857b6c657

View File

@ -71,7 +71,15 @@ class TextGenerate(io.ComfyNode):
seed=seed seed=seed
) )
generated_text = clip.decode(generated_ids, skip_special_tokens=True) generated_text = clip.decode(generated_ids, skip_special_tokens=not thinking)
if thinking:
# Translate Gemma4 thinking channel markers to standard <think>/</think> tags
generated_text = generated_text.replace("<|channel>thought\n", "<think>\n")
generated_text = generated_text.replace("<channel|>", "</think>")
# Strip remaining special tokens
generated_text = generated_text.replace("<turn|>", "").replace("<eos>", "").strip()
return io.NodeOutput(generated_text) return io.NodeOutput(generated_text)