[Bugfix] Fix incorrect chat template format for Qwen3.5 (#42660)
Signed-off-by: DarkLight1337 <tlleungac@connect.ust.hk>
This commit is contained in:
@@ -402,6 +402,7 @@ def _iter_nodes_assign_content_item(root: jinja2.nodes.Node):
|
||||
]
|
||||
|
||||
# Search for {%- for content in message['content'] -%} loops
|
||||
# or {%- for item in content -%} loops
|
||||
for loop_ast in root.find_all(jinja2.nodes.For):
|
||||
loop_iter = loop_ast.iter
|
||||
loop_target = loop_ast.target
|
||||
@@ -412,6 +413,10 @@ def _iter_nodes_assign_content_item(root: jinja2.nodes.Node):
|
||||
yield loop_ast, loop_target.name
|
||||
break
|
||||
|
||||
if isinstance(loop_iter, jinja2.nodes.Name) and loop_iter.name == "content":
|
||||
assert isinstance(loop_target, jinja2.nodes.Name)
|
||||
yield loop_ast, loop_target.name
|
||||
|
||||
|
||||
def _try_extract_ast(chat_template: str) -> jinja2.nodes.Template | None:
|
||||
import transformers.utils.chat_template_utils as hf_chat_utils
|
||||
|
||||
Reference in New Issue
Block a user