Allow custom templates with Ideogram4 TE (#14374)

This commit is contained in:
Jukka Seppänen 2026-06-09 16:11:05 +03:00 committed by GitHub
parent f89999289a
commit 8ed7f458d0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -32,7 +32,9 @@ class Ideogram4Tokenizer(sd1_clip.SD1Tokenizer):
self.llama_template = "<|im_start|>user\n{}<|im_end|>\n<|im_start|>assistant\n"
def tokenize_with_weights(self, text, return_word_ids=False, llama_template=None, **kwargs):
if llama_template is None:
if text.startswith('<|im_start|>'):
llama_text = text
elif llama_template is None:
llama_text = self.llama_template.format(text)
else:
llama_text = llama_template.format(text)