vllm.entrypoints.openai.chat_completion.stream_processor
¶
Classes:
-
ChatStreamProcessor–Turn one chat choice generated chunks into stream deltas.
-
ChatStreamStep–
ChatStreamProcessor
¶
Turn one chat choice generated chunks into stream deltas.
Shared by OpenAIServingChat streaming and streaming chat derender, so
both emit the same reasoning / content / tool_calls deltas and
finish_reason for the same chunks. Use one instance per choice and call
step once per chunk, in order and with the chunking the engine produced.
Methods:
-
step–Parse one chunk and resolve its chat
finish_reason.
step(delta_text, delta_token_ids, finish_reason, prompt_token_ids)
¶
Parse one chunk and resolve its chat finish_reason.
Parameters:
-
(delta_text¶str) –Text decoded from this chunk's tokens.
-
(delta_token_ids¶list[int]) –This chunk's token IDs.
-
(finish_reason¶str | None) –The engine finish reason. None if not finished.
-
(prompt_token_ids¶list[int] | None) –Prompt token IDs if known.
Returns:
-
ChatStreamStep–The delta to stream, filtered for
tool_choiceand -
ChatStreamStep–parallel_tool_calls, and the chatfinish_reason.
ChatStreamStep
¶
Bases: NamedTuple
Attributes:
-
delta(DeltaMessage | None) –None when the parser has nothing to emit for this chunk yet.
-
finish_reason(str | None) –The chat
finish_reasonor None while the choice is still running.