Skip to content

Commit 8796b47

Browse files
committed
fix
Signed-off-by: Alexandros Koumparoulis <[email protected]>
1 parent 7c2319f commit 8796b47

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

nemo_automodel/_transformers/auto_tokenizer.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,13 @@ def apply_chat_template(
7272
tokenizer_kwargs: Optional[dict[str, Any]] = None,
7373
**kwargs,
7474
) -> Union[str, list[int], list[str], list[list[int]], transformers.tokenization_utils_base.BatchEncoding]:
75-
if not self.supports_system_role and conversation[0].get("role", None) == "system":
76-
if not any(map(lambda x: x.get("role", None) == "system", conversation[1:])):
75+
if not self.supports_system_role:
76+
if conversation[0].get("role", None) == "system" \
77+
and not any(map(lambda x: x.get("role", None) == "system", conversation[1:])):
7778
# in this case we will drop the first message
7879
conversation = conversation[1:]
7980
else:
80-
raise ValueError("System role appeared in multiple messages.")
81+
raise ValueError("System role appears in multiple messages.")
8182

8283
return super().apply_chat_template(
8384
conversation,

0 commit comments

Comments
 (0)