Python class
TextGenerationRequestMessage
TextGenerationRequestMessage
class max.interfaces.TextGenerationRequestMessage(*, role, content)
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])
content
content: str | list[MessageContent]
flatten_content()
flatten_content()
Flattens message content to a single role/content dict for text-only messages.
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.
role
role: MessageRole
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!