Python class
TextGenerationRequestMessage
TextGenerationRequestMessageβ
class max.pipelines.modeling.types.TextGenerationRequestMessage(*, role, content='', tool_calls=None, tool_call_id=None, reasoning_content=None)
Bases: BaseModel
A single message in a text generation request conversation.
-
Parameters:
-
- role (Literal['system', 'user', 'assistant', 'tool', 'function'])
- content (str | list[TextContentPart | ImageContentPart | VideoContentPart])
- tool_calls (list[dict[str, Any]] | None)
- tool_call_id (str | None)
- reasoning_content (str | None)
contentβ
content: str | list[MessageContent]
flatten_content()β
flatten_content()
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.
model_configβ
model_config: ClassVar[ConfigDict] = {'from_attributes': True, 'frozen': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
number_of_imagesβ
property number_of_images: int
Returns the number of ImageContentPart instances in the message content.
number_of_videosβ
property number_of_videos: int
Returns the number of VideoContentPart instances in the message content.
reasoning_contentβ
roleβ
role: _MessageRole
tool_call_idβ
tool_callsβ
validate_content_format()β
classmethod validate_content_format(v)
Normalizes message content to a string or list of content parts.
-
Parameters:
-
v (Any)
-
Return type:
-
str | list[TextContentPart | ImageContentPart | VideoContentPart]
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!