nemo_gym.core.media
nemo_gym.core.media
Media carried in Responses messages, such as an input_image part holding a base64 data URI.
split_text_and_media decodes a message into its text and its media files,
and MediaFile converts between bytes and data URIs.
nemo_gym.sandbox.stage_media writes the decoded files into a sandbox for a harness CLI to read.
Images are the supported media today.
Supporting another kind means adding its media types to _MEDIA_TYPE_EXTENSIONS and _MEDIA_TYPE_SIGNATURES
and its Responses part type to _PART_URL_FIELDS, or a decoder for a part that does not hold a data URI.
Module Contents
Classes
Functions
Data
API
Decoded media content and its media type, such as image/png.
The content always starts with the bytes that identify its media type.
The file extension, without the dot, that files of this media type are written with.
Decode a data:<media type>[;<parameter>]...;base64,<payload> URI.
The URI must name a supported media type, and the payload must hold data of a supported media type.
When the two differ, as for a PNG labeled image/jpeg, the payload’s own type wins,
so the file gets the extension its content needs.
Encode as a data:<media type>;base64,<payload> URI.
Bases: ValueError
A message holds content that cannot be passed on as text or as a media file.
The caller should reject the request rather than drop the content.
Return a message’s text, joined across text parts, and its decoded media in order.
Each part may be a mapping or a Responses content part model.
Raises UnsupportedContentError for a part that is neither text nor supported media.