Skip to content

Schema

Schema utilities for gllm-retrieval.

get_image_metadata(chunk)

Retrieve validated image media metadata entries from a chunk.

Convenience wrapper around get_media_metadata filtered to MediaType.IMAGE.

Parameters:

Name Type Description Default
chunk Chunk

The chunk to read image metadata from.

required

Returns:

Type Description
list[Media]

list[Media]: Validated image Media objects; empty list for non-image chunks or chunks with no valid image media entries.

get_media_metadata(chunk, media_type=None)

Retrieve validated media metadata entries from a chunk.

Reads chunk.metadata["media"], validates each entry via the Media model, and optionally filters by media_type. Malformed entries are skipped with a warning log. The function never raises.

Parameters:

Name Type Description Default
chunk Chunk

The chunk to read media metadata from.

required
media_type MediaType | None

If provided, only entries matching this type are returned. Defaults to None (all types).

None

Returns:

Type Description
list[Media]

list[Media]: Validated Media objects; empty list for text chunks, missing "media" key, wrong shape, or all-malformed entries.