pub enum ContentBlock {
Text {
text: String,
},
Image {
source: ImageSource,
},
Audio {
source: FileSource,
},
Video {
source: FileSource,
},
File {
source: FileSource,
},
}Expand description
Content block for multimodal messages.
Only ContentBlock::Text and ContentBlock::Image are currently
translated by the bundled providers; audio, video, and file blocks are
modelled here but not yet sent on the wire.
§Examples
use rai_sdk::ContentBlock;
let caption = ContentBlock::text("Describe this diagram.");
let remote = ContentBlock::image_url("https://example.com/diagram.png");
let inline = ContentBlock::image_base64("image/png", "iVBORw0KGgo=");Variants§
Text
Plain text.
Image
An image, by URL or inline base64 data.
Fields
§
source: ImageSourceWhere the image data comes from.
Audio
An audio clip. Not yet supported by the bundled providers.
Fields
§
source: FileSourceWhere the audio data comes from.
Video
A video clip. Not yet supported by the bundled providers.
Fields
§
source: FileSourceWhere the video data comes from.
File
An arbitrary file. Not yet supported by the bundled providers.
Fields
§
source: FileSourceWhere the file data comes from.
Implementations§
Source§impl ContentBlock
impl ContentBlock
Sourcepub fn image_base64(
media_type: impl Into<String>,
data: impl Into<String>,
) -> Self
pub fn image_base64( media_type: impl Into<String>, data: impl Into<String>, ) -> Self
Create an image content block from base64 data.
Sourcepub fn audio_base64(
media_type: impl Into<String>,
data: impl Into<String>,
) -> Self
pub fn audio_base64( media_type: impl Into<String>, data: impl Into<String>, ) -> Self
Create an audio content block from base64 data.
Trait Implementations§
Source§impl Clone for ContentBlock
impl Clone for ContentBlock
Source§fn clone(&self) -> ContentBlock
fn clone(&self) -> ContentBlock
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
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<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for ContentBlock
impl PartialEq for ContentBlock
Source§impl Serialize for ContentBlock
impl Serialize for ContentBlock
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
Mutably borrows from an owned value. Read more