Skip to content

Commit

Permalink
Fix repeated
Browse files Browse the repository at this point in the history
Signed-off-by: DarkLight1337 <[email protected]>
  • Loading branch information
DarkLight1337 committed Nov 4, 2024
1 parent 26725f5 commit 9d0af9f
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions vllm/entrypoints/chat_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,13 @@ def _iter_nodes_define_message(chat_template_ast: jinja2.nodes.Template):
for loop_ast in chat_template_ast.find_all(jinja2.nodes.For):
loop_target = loop_ast.target

for loop_iter_desc in _iter_self_and_descendants(loop_ast.iter):
if _is_var_access(loop_iter_desc, "messages"):
assert isinstance(loop_target, jinja2.nodes.Name)
yield loop_ast, loop_target.name
# yapf: disable
if any(
_is_var_access(loop_iter_desc, "messages") for loop_iter_desc
in _iter_self_and_descendants(loop_ast.iter)
): # yapf: enable
assert isinstance(loop_target, jinja2.nodes.Name)
yield loop_ast, loop_target.name


def _iter_nodes_define_content_item(chat_template_ast: jinja2.nodes.Template):
Expand All @@ -185,10 +188,13 @@ def _iter_nodes_define_content_item(chat_template_ast: jinja2.nodes.Template):
for loop_ast in node.find_all(jinja2.nodes.For):
loop_target = loop_ast.target

for loop_iter_desc in _iter_self_and_descendants(loop_ast.iter):
if _is_attr_access(loop_iter_desc, message_varname, "content"):
assert isinstance(loop_target, jinja2.nodes.Name)
yield loop_iter_desc, loop_target.name
# yapf: disable
if any(
_is_attr_access(loop_iter_desc, message_varname, "content")
for loop_iter_desc in _iter_self_and_descendants(loop_ast.iter)
): # yapf: enable
assert isinstance(loop_target, jinja2.nodes.Name)
yield loop_ast, loop_target.name


def _detect_content_format(
Expand Down

0 comments on commit 9d0af9f

Please sign in to comment.