pub enum ContentBlock {
Text {
text: String,
},
Image {
source: ImageSource,
},
ToolUse {
id: String,
name: String,
input: Value,
},
ToolResult {
tool_use_id: String,
content: ToolResultContent,
is_error: Option<bool>,
},
Thinking {
thinking: String,
signature: String,
},
RedactedThinking {
data: String,
},
Document {
source: DocumentSource,
title: Option<String>,
context: Option<String>,
citations: Option<CitationsConfig>,
},
Opaque,
}Variants§
Text
Image
Fields
source: ImageSourceToolUse
ToolResult
Thinking
RedactedThinking
Document
Opaque
Escape hatch for provider-specific block types not covered above.
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
Image block from already-base64-encoded data and an explicit MIME type.
Sourcepub fn image_bytes(media_type: impl Into<String>, bytes: &[u8]) -> Self
pub fn image_bytes(media_type: impl Into<String>, bytes: &[u8]) -> Self
Image block from raw bytes; the bytes are base64-encoded for you.
Sourcepub fn image_url(url: impl Into<String>) -> Self
pub fn image_url(url: impl Into<String>) -> Self
Image block referencing a remote URL (provider must support URL sources).
Sourcepub fn document_base64(
media_type: impl Into<String>,
data: impl Into<String>,
) -> Self
pub fn document_base64( media_type: impl Into<String>, data: impl Into<String>, ) -> Self
Document block (PDF, text, …) from already-base64-encoded data.
Sourcepub fn document_bytes(media_type: impl Into<String>, bytes: &[u8]) -> Self
pub fn document_bytes(media_type: impl Into<String>, bytes: &[u8]) -> Self
Document block from raw bytes; the bytes are base64-encoded for you.
Sourcepub fn document_url(url: impl Into<String>) -> Self
pub fn document_url(url: impl Into<String>) -> Self
Document block referencing a remote URL.
Sourcepub fn media_bytes(media_type: impl Into<String>, bytes: &[u8]) -> Self
pub fn media_bytes(media_type: impl Into<String>, bytes: &[u8]) -> Self
Build a block from raw bytes plus a known MIME type. Images, video, and
audio become ContentBlock::Image; everything else becomes a
ContentBlock::Document.
Sourcepub fn from_path(path: impl AsRef<Path>) -> Result<Self>
pub fn from_path(path: impl AsRef<Path>) -> Result<Self>
Build a block from a local file, auto-detecting the MIME type from the file’s contents (and extension as a fallback). Images/video/audio become image blocks; PDFs and other files become document blocks.
Returns CerseiError::Config if the media type can’t be determined,
or CerseiError::Io if the file can’t be read.
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 more