Skip to content
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions vllm/entrypoints/openai/serving_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,10 +538,12 @@ async def chat_completion_stream_generator(
# any tokens that were generated but previously
# matched by partial json parsing
# only happens if we are NOT using guided decoding
tools_called = False
if tool_parser:
index = len(
tool_parser.prev_tool_call_arr) - 1 if len(
tool_parser.prev_tool_call_arr) > 0 else 0
tools_called = len(
tool_parser.prev_tool_call_arr) > 0
index = len(tool_parser.prev_tool_call_arr
) - 1 if tools_called else 0
else:
index = 0

Expand Down Expand Up @@ -576,9 +578,7 @@ async def chat_completion_stream_generator(
delta=delta_message,
logprobs=logprobs,
finish_reason=output.finish_reason
if not (tool_parser
and len(tool_parser.prev_tool_call_arr))
else "tool_calls",
if not tools_called else "tool_calls",
stop_reason=output.stop_reason)
chunk = ChatCompletionStreamResponse(
id=request_id,
Expand Down Expand Up @@ -703,7 +703,6 @@ async def chat_completion_full_generator(
name=request.tool_choice.function.name,
arguments=output.text))
])
tools_called = True

# if the request doesn't use tool choice
# OR specifies to not use a tool
Expand Down