Skip to content

Commit db67c52

Browse files
reidliu41Mu Huai
authored andcommitted
[frontend] enhance tool_calls type check (vllm-project#16882)
Signed-off-by: reidliu41 <[email protected]> Co-authored-by: reidliu41 <[email protected]> Signed-off-by: Mu Huai <[email protected]>
1 parent c37b033 commit db67c52

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

vllm/entrypoints/chat_utils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1095,7 +1095,11 @@ def _parse_chat_message_content(
10951095
if role == 'assistant':
10961096
parsed_msg = _AssistantParser(message)
10971097

1098-
if "tool_calls" in parsed_msg:
1098+
# The 'tool_calls' is not None check ensures compatibility.
1099+
# It's needed only if downstream code doesn't strictly
1100+
# follow the OpenAI spec.
1101+
if ("tool_calls" in parsed_msg
1102+
and parsed_msg["tool_calls"] is not None):
10991103
result_msg["tool_calls"] = list(parsed_msg["tool_calls"])
11001104
elif role == "tool":
11011105
parsed_msg = _ToolParser(message)

0 commit comments

Comments
 (0)