Skip to content

Commit 7237384

Browse files
committed
fix: convert list/tuple to iterator before calling next() on tool_calls_validator
The current implementation assigns raw_tool_calls directly to tool_calls_validator. If raw_tool_calls is a list or tuple (which are iterable but not iterators), calling next() will raise a TypeError. Explicitly convert lists/tuples using iter() to ensure tool_calls_validator is always an actual iterator before next() is called. Signed-off-by: Elizabeth Thomas <email2eliza@gmail.com>
1 parent 0103fb8 commit 7237384

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

vllm/tokenizers/mistral.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,10 @@ def maybe_serialize_tool_calls(request: "MistralChatCompletionRequest"):
7474
f"'tool_calls' must be a list of tool call objects, "
7575
f"got {type(raw_tool_calls).__name__}"
7676
)
77-
tool_calls_validator = raw_tool_calls
77+
if isinstance(raw_tool_calls, (list, tuple)):
78+
tool_calls_validator = iter(raw_tool_calls)
79+
else:
80+
tool_calls_validator = raw_tool_calls
7881
validated_tool_calls = []
7982
while True:
8083
try:

0 commit comments

Comments
 (0)