A high-throughput and memory-efficient inference and serving engine for LLMs
Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git
Synced Nov 15, 13:30 UTC
[frontend] enhance tool_calls type check (#16882)
Signed-off-by: reidliu41 <reid201711@gmail.com> Co-authored-by: reidliu41 <reid201711@gmail.com>
Reid committed
Apr 22, 2025 at 23:40 UTC
f34410715f9758a2ee2d45acd56179f9c1c06fc3
1 file changed
+5
-1
vllm/entrypoints/chat_utils.py
+5
-1
@@ -1095,7 +1095,11 @@ def _parse_chat_message_content(
1095
if role == 'assistant':
1096
parsed_msg = _AssistantParser(message)
1097
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):
1103
result_msg["tool_calls"] = list(parsed_msg["tool_calls"])
1104
elif role == "tool":
1105
parsed_msg = _ToolParser(message)