agentix.content¶
content ¶
Multimodal content parts for :class:~agentix.types.Message.
A message's content is either a plain str (the common case, unchanged) or
a list of parts — text interleaved with media. Parts are framework-agnostic;
each provider adapter translates them into that vendor's block format and raises
a clear error for anything the provider can't accept.
Four part types::
TextPart("describe this")
ImagePart.from_path("cat.png") # base64-encoded, mime inferred
DocumentPart.from_url("https://…/x.pdf")
AudioPart.from_bytes(raw, "audio/wav")
A media part holds exactly one of inline data (base64) or a remote
url. Build them with the from_* constructors rather than the raw fields.
BinaryPart
dataclass
¶
BinaryPart(
data: str | None = None,
url: str | None = None,
media_type: str = "",
filename: str | None = None,
)
Base for media parts. Carries exactly one of data (base64) or url.
Prefer the constructors: :meth:from_path, :meth:from_bytes,
:meth:from_base64, :meth:from_url.
from_path
classmethod
¶
Read a local file, base64-encode it, and infer its MIME type.
ImagePart
dataclass
¶
DocumentPart
dataclass
¶
AudioPart
dataclass
¶
part_to_dict ¶
Serialize a content part to a JSON-able dict (used by the codec).
part_from_dict ¶
Reconstruct a content part from :func:part_to_dict output.