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
-
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
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 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 | |
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
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 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 | |
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
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