vllm.entrypoints.openai.responses.utils
¶
Functions:
-
build_response_output_items–Build the output items of one generation.
-
construct_chat_messages_with_tool_call–Build chat messages from response items.
-
convert_tool_responses_to_completions_format–Convert a flat Responses tool schema:
-
decode_custom_tool_input–Payload of a completed shim call; bare text is passed through.
-
decode_custom_tool_input_prefix–Longest decodable payload prefix of partial shim arguments, so that
-
extend_custom_tool_input_prefix–:func:
decode_custom_tool_input_prefixof arguments, decoding only -
extract_tool_types–Extracts the tool types from the given tools.
-
response_item_status–Status of the output item that ended a generation with
finish_reason. -
reuse_streamed_item_ids–Give rebuilt output items the ids already streamed for the same message.
-
should_continue_final_message–Determine if the last input message is a partial assistant message
_construct_message_from_response_item(item, prev_msg=None)
¶
Returns a new message or None. If None, prev_msg might be updated.
If prev_msg is None, a new message is always returned.
Source code in vllm/entrypoints/openai/responses/utils.py
371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 | |
build_response_output_items(reasoning, content, tool_calls, logprobs=None, tools=None, finish_reason=None)
¶
Build the output items of one generation.
Only the last item can have been cut short, so finish_reason decides
that item's status and every earlier item is completed.
Source code in vllm/entrypoints/openai/responses/utils.py
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 | |
construct_chat_messages_with_tool_call(input_messages)
¶
Build chat messages from response items.
Some chat messages span multiple response items (e.g., reasoning + tool calls).
Source code in vllm/entrypoints/openai/responses/utils.py
convert_tool_responses_to_completions_format(tool)
¶
Convert a flat Responses tool schema
{"type": "function", "name": "...", "description": "...", "parameters": {...}}
into a Chat Completions tool param for chat-template rendering.
Source code in vllm/entrypoints/openai/responses/utils.py
decode_custom_tool_input(arguments)
¶
Payload of a completed shim call; bare text is passed through.
Source code in vllm/entrypoints/openai/responses/utils.py
decode_custom_tool_input_prefix(arguments)
¶
Longest decodable payload prefix of partial shim arguments, so that
streamed custom_tool_call_input deltas stay a prefix of the final input.
Source code in vllm/entrypoints/openai/responses/utils.py
extend_custom_tool_input_prefix(arguments, payload, end)
¶
:func:decode_custom_tool_input_prefix of arguments, decoding only
arguments[end:]. payload and end come from the previous call on a
prefix of arguments ("" and 0 at first). Returns None when the
arguments do not start as :func:encode_custom_tool_input writes them,
or once the payload string closes; only a full decode is exact then.
Source code in vllm/entrypoints/openai/responses/utils.py
extract_tool_types(tools)
¶
Extracts the tool types from the given tools.
Source code in vllm/entrypoints/openai/responses/utils.py
response_item_status(finish_reason)
¶
Status of the output item that ended a generation with finish_reason.
Source code in vllm/entrypoints/openai/responses/utils.py
reuse_streamed_item_ids(items, streamed_items)
¶
Give rebuilt output items the ids already streamed for the same message.
Items are paired by type in order; an item without a streamed counterpart keeps its own id.
Source code in vllm/entrypoints/openai/responses/utils.py
should_continue_final_message(request_input)
¶
Determine if the last input message is a partial assistant message that should be continued rather than starting a new generation.
This enables partial message completion similar to Anthropic's Messages API, where users can provide an incomplete assistant message and have the model continue from where it left off.
A message is considered partial if: 1. It's a ResponseOutputMessage or ResponseReasoningItem 2. Its status is "in_progress" or "incomplete"
Parameters:
Returns:
-
bool–True if the final message should be continued, False otherwise