Skip to main content

Python class

TextGenerationRequestMessage

TextGenerationRequestMessage

class max.interfaces.TextGenerationRequestMessage(*, role, content)

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 single role/content dict for text-only messages.

Return type:

dict[str, str]

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.

role

role: MessageRole

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]