IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /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. /get-started.md).

Python class

TextGenerationRequestMessage

TextGenerationRequestMessage

class max.pipelines.modeling.types.TextGenerationRequestMessage(*, role, content='', tool_calls=None, tool_call_id=None, reasoning_content=None)

source

Bases: BaseModel

A single message in a text generation request conversation.

Parameters:

content

content: str | list[MessageContent]

source

flatten_content()

flatten_content()

source

Flattens message content to a role/content dict for text-only messages.

Preserves OpenAI-style tool-calling metadata (tool_calls, tool_call_id, reasoning_content) when set so chat templates that consume conversation history with tool use receive a faithful representation of each turn.

Return type:

dict[str, Any]

model_config

model_config: ClassVar[ConfigDict] = {'from_attributes': True, 'frozen': True}

source

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

number_of_images

property number_of_images: int

source

Returns the number of ImageContentPart instances in the message content.

number_of_videos

property number_of_videos: int

source

Returns the number of VideoContentPart instances in the message content.

reasoning_content

reasoning_content: str | None

source

role

role: _MessageRole

source

tool_call_id

tool_call_id: str | None

source

tool_calls

tool_calls: list[dict[str, Any]] | None

source

validate_content_format()

classmethod validate_content_format(v)

source

Normalizes message content to a string or list of content parts.

Parameters:

v (Any)

Return type:

str | list[TextContentPart | ImageContentPart | VideoContentPart]