Skip to content

Dm Media

Shared multimodal capability, media attachment, and rule helpers for decision-model judges.

add_multimodal_rules(request, *, enabled=True, rules=None)

Append the multimodal judge rules to each decision-model question in place.

Parameters:

Name Type Description Default
request DMInput

The decision-model request to update in place. Question instructions must be text.

required
enabled bool

When False, leaves the request unchanged. Defaults to True.

True
rules str | None

Custom multimodal rules. Defaults to None, which uses GLLM_MULTIMODAL_RULES.

None

attach_media(state, *, resolved_by_source=None) async

Replace the image placeholders in a row's state with Attachment items.

Recurses into nested dicts and lists (such as conversational turns and retrieved_context). A text field holding images becomes an ordered list of text and attachments; a field or list item that is only an image becomes the attachment. An image used more than once is resolved once and shared.

Parameters:

Name Type Description Default
state dict[str, Any]

The state built from a row; its text may hold image placeholders.

required
resolved_by_source dict[str, Attachment] | None

Per-row cache shared across attempts to avoid resolving the same image more than once. Defaults to None.

None

Returns:

Type Description
dict[str, Any]

dict[str, Any]: The state with every image placeholder replaced by its attachment.

contains_image_placeholders(text)

Return whether text contains at least one registered DeepEval MLLMImage placeholder.

Parameters:

Name Type Description Default
text str | None

Text that may carry rewritten DeepEval image placeholders.

required

Returns:

Name Type Description
bool bool

True if text resolves to at least one MLLMImage item.

dm_accepts_media(invoker, record_usage=None) async

Check whether a decisions-model judge reads image input via the blessed list or probe.

skip_multimodal_check does not apply here: it vouches for LM judges, and a decisions model that cannot see images would otherwise score image rows blind.

Parameters:

Name Type Description Default
invoker BaseDMInvoker

The decisions-model judge.

required
record_usage Callable[[DMOutput], None] | None

Called with each probe output to record its token usage. Defaults to None.

None

Returns:

Name Type Description
bool bool

True if the judge is blessed as image-capable or passes dm_reads_images.

dm_verdict_is_definite(model_id)

Check whether a decisions model's image verdict is definite rather than a transient probe failure.

Parameters:

Name Type Description Default
model_id str

The decisions model id.

required

Returns:

Name Type Description
bool bool

True if the model is on the blessed list or its probe reached a cached verdict.