Skip to content

Attachment placeholders

Pure helpers for parsing row-level attachment placeholders.

AttachmentSegment(target) dataclass

Attachment segment parsed from a field containing attachment placeholders.

AttachmentTarget(raw, kind, scheme=None) dataclass

Validated attachment placeholder target.

AttachmentTargetKind

Bases: StrEnum

Attachment placeholder target classification.

TextSegment(text) dataclass

Text segment parsed from a field containing attachment placeholders.

classify_attachment_target(target)

Classify and validate an attachment placeholder target.

Parameters:

Name Type Description Default
target str

Raw placeholder target between [ATTACHMENT: and ].

required

Returns:

Name Type Description
AttachmentTarget AttachmentTarget

Validated target classification.

Raises:

Type Description
ValueError

If the target is empty, malformed, or uses an unsupported URI scheme.

field_contains_attachment_placeholder(value)

Return whether a supported field value contains an attachment placeholder.

Parameters:

Name Type Description Default
value Any

Scalar or list-valued evaluation field value.

required

Returns:

Name Type Description
bool bool

True when the value contains at least one attachment placeholder.

parse_attachment_placeholders(value)

Parse text into ordered text and attachment placeholder segments.

Empty text segments are omitted so callers can directly preserve only meaningful text/media ordering.

Parameters:

Name Type Description Default
value str

Field text that may contain attachment placeholders.

required

Returns:

Type Description
list[PlaceholderSegment]

list[PlaceholderSegment]: Ordered text and attachment segments.

Raises:

Type Description
ValueError

If a placeholder is not closed or has an invalid target.

row_contains_multimodal_content(row)

Return whether a row references attachments in supported fields.

Parameters:

Name Type Description Default
row dict[str, Any]

Normalized evaluation row.

required

Returns:

Name Type Description
bool bool

True when a supported string-bearing evaluation field contains attachment placeholders.