IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /max/get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /max/get-started.md).

Python class

TextGenerationOutput

TextGenerationOutput​

class max.pipelines.context.TextGenerationOutput(*, request_id, tokens, final_status, log_probabilities=None, num_cached_tokens=None)

source

Bases: object

Represents the output of a text generation operation.

Combines token IDs, final generation status, request ID, and optional log probabilities for each token.

Parameters:

final_status​

final_status: GenerationStatus

source

The final status of the generation process.

is_done​

property is_done: bool

source

Indicates whether the text generation process is complete.

Returns:

True if the generation is done, False otherwise.

log_probabilities​

log_probabilities: list[LogProbabilities] | None = None

source

Optional list of log probabilities for each token.

merge()​

classmethod merge(outputs)

source

Combine many TextGenerationOutput chunks into a single TextGenerationOutput.

Parameters:

outputs (list[TextGenerationOutput])

Return type:

TextGenerationOutput

num_cached_tokens​

num_cached_tokens: int | None = None

source

Number of prompt tokens served from the KV prefix cache.

request_id​

request_id: RequestID

source

The unique identifier for the generation request.

tokens​

tokens: list[int]

source

List of generated token IDs.