Skip to content

vllm.entrypoints.openai.chat_completion.stream_processor

Classes:

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

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_reason or None while the choice is still running.

delta instance-attribute

None when the parser has nothing to emit for this chunk yet.

finish_reason instance-attribute

The chat finish_reason or None while the choice is still running.