#[non_exhaustive]pub enum ContentBlock {
Text(Text),
Image(Image),
ToolCall(ToolCall),
Reasoning(Reasoning),
Refusal(Refusal),
ProviderToolCall(ProviderToolCall),
ProviderToolResult(ProviderToolResult),
Other(OtherContent),
}Expand description
A block of model output.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Text(Text)
Text output.
Image(Image)
Image output.
ToolCall(ToolCall)
A tool call.
Reasoning(Reasoning)
Reasoning output.
Refusal(Refusal)
Text in which the model declines to answer; not answer text.
ProviderToolCall(ProviderToolCall)
A tool call the provider executed itself.
ProviderToolResult(ProviderToolResult)
The outcome of a provider-executed tool call.
Other(OtherContent)
Content the portable model does not represent.
Implementations§
Source§impl ContentBlock
impl ContentBlock
Sourcepub fn refusal(text: impl Into<String>) -> Self
pub fn refusal(text: impl Into<String>) -> Self
A refusal block: text in which the model declined to answer.
Sourcepub fn tool_call(
id: impl Into<String>,
name: impl Into<String>,
arguments: impl Into<String>,
) -> Self
pub fn tool_call( id: impl Into<String>, name: impl Into<String>, arguments: impl Into<String>, ) -> Self
A tool-call block.
Sourcepub fn as_tool_call(&self) -> Option<&ToolCall>
pub fn as_tool_call(&self) -> Option<&ToolCall>
Borrow a tool-call block.
Sourcepub fn as_reasoning(&self) -> Option<&Reasoning>
pub fn as_reasoning(&self) -> Option<&Reasoning>
Borrow a reasoning block.
Sourcepub fn as_refusal(&self) -> Option<&Refusal>
pub fn as_refusal(&self) -> Option<&Refusal>
Borrow a refusal block.
Sourcepub fn as_provider_tool_call(&self) -> Option<&ProviderToolCall>
pub fn as_provider_tool_call(&self) -> Option<&ProviderToolCall>
Borrow a provider tool call block.
Sourcepub fn as_provider_tool_result(&self) -> Option<&ProviderToolResult>
pub fn as_provider_tool_result(&self) -> Option<&ProviderToolResult>
Borrow a provider tool result block.
Sourcepub fn provider_data(&self) -> &ProviderData
pub fn provider_data(&self) -> &ProviderData
Borrow the block’s provider data.
Sourcepub fn provider_data_mut(&mut self) -> &mut ProviderData
pub fn provider_data_mut(&mut self) -> &mut ProviderData
Mutably borrow the block’s provider data.
Sourcepub fn block_type(&self) -> StreamBlockType
pub fn block_type(&self) -> StreamBlockType
The portable type of the block, as a stream announces it in its
BlockStart (StreamBlockType).
Every kind of block has one, so
StreamBlockType::ALL lists
every kind of block.
Trait Implementations§
Source§impl Clone for ContentBlock
impl Clone for ContentBlock
Source§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<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for ContentBlock
impl Display for ContentBlock
impl Eq for ContentBlock
Source§impl From<Image> for ContentBlock
impl From<Image> for ContentBlock
Source§impl From<OtherContent> for ContentBlock
impl From<OtherContent> for ContentBlock
Source§fn from(value: OtherContent) -> Self
fn from(value: OtherContent) -> Self
Converts to this type from the input type.
Source§impl From<ProviderToolCall> for ContentBlock
impl From<ProviderToolCall> for ContentBlock
Source§fn from(value: ProviderToolCall) -> Self
fn from(value: ProviderToolCall) -> Self
Converts to this type from the input type.
Source§impl From<ProviderToolResult> for ContentBlock
impl From<ProviderToolResult> for ContentBlock
Source§fn from(value: ProviderToolResult) -> Self
fn from(value: ProviderToolResult) -> Self
Converts to this type from the input type.
Source§impl From<Reasoning> for ContentBlock
impl From<Reasoning> for ContentBlock
Source§impl From<Refusal> for ContentBlock
impl From<Refusal> for ContentBlock
Source§impl From<Text> for ContentBlock
impl From<Text> for ContentBlock
Source§impl From<ToolCall> for ContentBlock
impl From<ToolCall> for ContentBlock
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