vllm.entrypoints.openai.chat_completion.message_assembly
¶
Functions:
-
assemble_chat_message_fields–Pick the assistant message fields for one parsed chat choice.
-
get_chat_response_role–Role of the response message:
response_role(the server's -
get_echo_content–Text that
echoprepends to the response content. -
keeps_tool_calls–Whether a chat choice returns the tool calls its parser extracts.
assemble_chat_message_fields(request, reasoning, content, tool_calls, *, enable_auto_tools, parser_cls)
¶
Pick the assistant message fields for one parsed chat choice.
Shared by OpenAIServingChat and batch chat derender so both surface the
same reasoning, content and tool_calls for the same parser output.
Parameters:
-
(request¶ChatCompletionRequest) –Supplies
tools,tool_choice,include_reasoningandparallel_tool_calls. -
(reasoning¶str | None) –Reasoning from
Parser.parse. -
(content¶str | None) –Content from
Parser.parseor the raw text without a parser. -
(tool_calls¶list[FunctionCall] | None) –Tool calls from
Parser.parse. -
(enable_auto_tools¶bool) –The server's
--enable-auto-tool-choice. -
(parser_cls¶type[Parser] | None) –The server's parser class, if any.
Returns:
-
ChatMessageFields–The fields for the response
ChatMessage.
Source code in vllm/entrypoints/openai/chat_completion/message_assembly.py
get_chat_response_role(request, response_role)
¶
Role of the response message: response_role (the server's
--response-role), or the last message's role when the request continues
it (add_generation_prompt=False).
Source code in vllm/entrypoints/openai/chat_completion/message_assembly.py
get_echo_content(messages, role)
¶
Text that echo prepends to the response content.
Parameters:
-
(messages¶Sequence[Mapping[str, Any] | Message]) –The conversation, parsed (Harmony messages for gpt-oss) or as sent in the request.
-
(role¶str) –The response role from
get_chat_response_role.
Returns:
-
str–The last message's text when its role is
role, otherwise "". Text -
str–parts of list content are extracted and joined with newlines, as chat
-
str–parsing does. Multimodal parts are left out.
Source code in vllm/entrypoints/openai/chat_completion/message_assembly.py
keeps_tool_calls(request, *, enable_auto_tools, parser_cls)
¶
Whether a chat choice returns the tool calls its parser extracts.
Shared by the non-streaming and streaming chat paths so both apply
tool_choice the same way. Parsers don't all gate on it themselves:
HarmonyParser ignores "none" and null is parsed like "auto".
Parameters:
-
(request¶ChatCompletionRequest) –Supplies
toolsandtool_choice. -
(enable_auto_tools¶bool) –The server's
--enable-auto-tool-choice. -
(parser_cls¶type[Parser] | None) –The server's parser class, if any.
Returns: