pub enum ContentPart {
Text {
text: String,
},
Image {
media_type: String,
data: String,
},
Audio {
media_type: String,
data: String,
name: Option<String>,
},
Video {
media_type: String,
data: String,
name: Option<String>,
},
Document {
media_type: String,
data: String,
name: Option<String>,
},
}Expand description
A single part of a multimodal message content.
Models like GPT-4o, Claude, and Gemini accept messages with mixed
text and attachment parts. When a ModelMessage contains non-empty
ModelMessage::content_parts, providers serialize each part
according to their native wire format instead of using the plain
ModelMessage::content string.
Variants§
Text
A plain text content block.
Image
An inline image (base64-encoded).
Fields
Audio
An inline audio attachment (base64-encoded).
Fields
Video
An inline video attachment (base64-encoded).
Fields
Document
An inline document attachment (base64-encoded).
Implementations§
Source§impl ContentPart
impl ContentPart
Sourcepub fn is_document(&self) -> bool
pub fn is_document(&self) -> bool
Returns true if this is a document part.
Sourcepub fn attachment_kind(&self) -> Option<AttachmentKind>
pub fn attachment_kind(&self) -> Option<AttachmentKind>
Returns the attachment kind, if this part is an attachment.
Sourcepub fn media_type(&self) -> Option<&str>
pub fn media_type(&self) -> Option<&str>
Returns the MIME type for attachment parts.
Sourcepub fn name(&self) -> Option<&str>
pub fn name(&self) -> Option<&str>
Optional filename/label for audio, video, or document attachments.
Sourcepub fn text_from_parts(parts: &[ContentPart]) -> String
pub fn text_from_parts(parts: &[ContentPart]) -> String
Returns all text content from a slice of parts, concatenated.
Trait Implementations§
Source§impl Clone for ContentPart
impl Clone for ContentPart
Source§fn clone(&self) -> ContentPart
fn clone(&self) -> ContentPart
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more