vllm.entrypoints.openai.responses.utils
¶
Functions:
-
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.
-
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
311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 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 | |
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
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