pub enum ContentBlock {
Text(String),
Image(ImageContent),
Wire(Value),
}Expand description
A content block within a message.
The structured entry point of the content model: text and image blocks,
plus vendor-shaped pass-through blocks (Wire).
§Example
use molo::{ContentBlock, ImageContent, Message};
let msg = Message::user_blocks(vec![
ContentBlock::Text("What is in this picture?".into()),
ContentBlock::Image(ImageContent::new("image/png", vec![0x89, b'P', b'N', b'G'])),
]);
assert_eq!(msg, Message::user_blocks(vec![
ContentBlock::Text("What is in this picture?".into()),
ContentBlock::Image(ImageContent::new("image/png", vec![0x89, b'P', b'N', b'G'])),
]));Variants§
Text(String)
A text block.
Image(ImageContent)
An image block (raw bytes + MIME type). Provider implementations
encode it for the wire format (e.g. the OpenAI-compatible
image_url content block with a base64 data URL); Memory counts it
as no tokens and summarizers render it as a placeholder.
Wire(Value)
A vendor-shaped content block passed through verbatim (e.g. the
input_audio / file parts of OpenAI-compatible endpoints, whose
shapes vary per vendor and keep evolving).
For any modality without a typed variant, build the wire block yourself and wrap it here; the provider inserts it into the content array as-is. Whatever your endpoint accepts, this block can carry it.
Trait Implementations§
Source§impl Clone for ContentBlock
impl Clone for ContentBlock
Source§fn clone(&self) -> ContentBlock
fn clone(&self) -> ContentBlock
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ContentBlock
impl Debug for ContentBlock
Source§impl<'de> Deserialize<'de> for ContentBlock
impl<'de> Deserialize<'de> for ContentBlock
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<ContentBlock, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ContentBlock, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
impl Eq for ContentBlock
Source§impl Hash for ContentBlock
impl Hash for ContentBlock
Source§impl PartialEq for ContentBlock
impl PartialEq for ContentBlock
Source§impl Serialize for ContentBlock
impl Serialize for ContentBlock
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for ContentBlock
Auto Trait Implementations§
impl Freeze for ContentBlock
impl RefUnwindSafe for ContentBlock
impl Send for ContentBlock
impl Sync for ContentBlock
impl Unpin for ContentBlock
impl UnsafeUnpin for ContentBlock
impl UnwindSafe for ContentBlock
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.