pub struct Message {
pub id: String,
pub message_type: String,
pub role: MessageRole,
pub content: Vec<ContentBlock>,
pub model: String,
pub stop_reason: StopReason,
pub stop_sequence: Option<String>,
pub created_at: String,
pub usage: Usage,
pub cache_usage: CacheUsage,
}Expand description
A message in a conversation
Fields§
§id: StringUnique identifier for the message
message_type: StringType of message (always “message”)
role: MessageRoleThe role that produced the message
content: Vec<ContentBlock>The content blocks in the message
model: StringThe model used to generate this message
stop_reason: StopReasonWhy the model stopped generating
stop_sequence: Option<String>Additional stop sequences if any
created_at: StringWhen the message was created
usage: UsageToken usage information
cache_usage: CacheUsageCache usage information
Implementations§
Source§impl Message
impl Message
Sourcepub fn new(
model: impl Into<String>,
role: MessageRole,
content: Vec<ContentBlock>,
) -> Self
pub fn new( model: impl Into<String>, role: MessageRole, content: Vec<ContentBlock>, ) -> Self
Create a new message
Sourcepub fn get_text_content(&self) -> String
pub fn get_text_content(&self) -> String
Get all text content from the message
Sourcepub fn used_tools(&self) -> bool
pub fn used_tools(&self) -> bool
Check if message ended due to tool use
Sourcepub fn is_complete(&self) -> bool
pub fn is_complete(&self) -> bool
Check if message is complete
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Message
impl<'de> Deserialize<'de> for Message
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
impl StructuralPartialEq for Message
Auto Trait Implementations§
impl Freeze for Message
impl RefUnwindSafe for Message
impl Send for Message
impl Sync for Message
impl Unpin for Message
impl UnwindSafe for Message
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