pub struct AssistantMessage {
pub id: String,
pub message_type: String,
pub role: MessageRole,
pub content: Vec<ContentBlock>,
pub model: String,
pub stop_reason: StopReason,
pub created_at: String,
pub usage: Usage,
pub cache_usage: CacheUsage,
pub parent_tool_use_id: Option<String>,
pub error: Option<AssistantMessageError>,
}Expand description
An assistant message in a conversation
Fields§
§id: StringUnique identifier for the message
message_type: StringType of message (always “message”)
role: MessageRoleThe role (always “assistant”)
content: Vec<ContentBlock>The content blocks in the message
model: StringThe model used to generate this message
stop_reason: StopReasonWhy the model stopped generating
created_at: StringWhen the message was created
usage: UsageToken usage information
cache_usage: CacheUsageCache usage information
parent_tool_use_id: Option<String>Parent tool use ID for messages in tool execution context
error: Option<AssistantMessageError>Error type if the message generation failed.
When this is set, the message may be incomplete or contain error information.
Implementations§
Source§impl AssistantMessage
impl AssistantMessage
Sourcepub fn new(
model: impl Into<String>,
content: Vec<ContentBlock>,
usage: Usage,
) -> Self
pub fn new( model: impl Into<String>, content: Vec<ContentBlock>, usage: Usage, ) -> Self
Create a new assistant message
Sourcepub fn with_error(
model: impl Into<String>,
content: Vec<ContentBlock>,
usage: Usage,
error: AssistantMessageError,
) -> Self
pub fn with_error( model: impl Into<String>, content: Vec<ContentBlock>, usage: Usage, error: AssistantMessageError, ) -> Self
Create an error message with the specified error type.
Sourcepub fn set_parent_tool_use_id(self, id: impl Into<String>) -> Self
pub fn set_parent_tool_use_id(self, id: impl Into<String>) -> Self
Set the parent tool use ID.
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Check if this message’s error is retryable.
Trait Implementations§
Source§impl Clone for AssistantMessage
impl Clone for AssistantMessage
Source§fn clone(&self) -> AssistantMessage
fn clone(&self) -> AssistantMessage
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 AssistantMessage
impl Debug for AssistantMessage
Source§impl<'de> Deserialize<'de> for AssistantMessage
impl<'de> Deserialize<'de> for AssistantMessage
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 AssistantMessage
impl PartialEq for AssistantMessage
Source§impl Serialize for AssistantMessage
impl Serialize for AssistantMessage
impl StructuralPartialEq for AssistantMessage
Auto Trait Implementations§
impl Freeze for AssistantMessage
impl RefUnwindSafe for AssistantMessage
impl Send for AssistantMessage
impl Sync for AssistantMessage
impl Unpin for AssistantMessage
impl UnwindSafe for AssistantMessage
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