pub enum ContentBlock {
Text {
text: String,
},
Image {
source: Option<ImageSource>,
},
ToolUse {
id: String,
name: String,
input: Value,
},
ToolResult {
tool_use_id: String,
content: Option<String>,
is_error: Option<bool>,
},
Thinking {
thinking: String,
},
Document {
source: DocumentSource,
title: Option<String>,
},
}Expand description
A content block in a message
Variants§
Text
Plain text content.
Image
Image content.
Fields
§
source: Option<ImageSource>The source of the image data.
ToolUse
A request from the model to use a tool.
Fields
ToolResult
The result of a tool execution.
Fields
Thinking
A block indicating that the model is performing an extended computation.
Document
Content from a document.
Fields
§
source: DocumentSourceThe source of the document.
Implementations§
Source§impl ContentBlock
impl ContentBlock
Sourcepub fn tool_use(
id: impl Into<String>,
name: impl Into<String>,
input: Value,
) -> Self
pub fn tool_use( id: impl Into<String>, name: impl Into<String>, input: Value, ) -> Self
Create a tool use content block
Sourcepub fn tool_result(
tool_use_id: impl Into<String>,
content: impl Into<String>,
) -> Self
pub fn tool_result( tool_use_id: impl Into<String>, content: impl Into<String>, ) -> Self
Create a tool result content block
Sourcepub fn tool_error(
tool_use_id: impl Into<String>,
error: impl Into<String>,
) -> Self
pub fn tool_error( tool_use_id: impl Into<String>, error: impl Into<String>, ) -> Self
Create an error tool result
Sourcepub fn is_tool_use(&self) -> bool
pub fn is_tool_use(&self) -> bool
Check if this is a tool use block
Sourcepub fn is_tool_result(&self) -> bool
pub fn is_tool_result(&self) -> bool
Check if this is a tool result block
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 · 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 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