pub enum Message {
User(UserMessage),
Assistant(AssistantMessage),
ToolResult(ToolResultMessage),
}Expand description
Message types for constructing conversations. Message union tagged by role.
Every conversation turn is one of: a UserMessage, an AssistantMessage,
or a ToolResultMessage.
Variants§
User(UserMessage)
A message from the user.
Assistant(AssistantMessage)
A response from the assistant.
ToolResult(ToolResultMessage)
The output of a tool invocation.
Implementations§
Source§impl Message
impl Message
Sourcepub fn user(content: impl Into<MessageContent>) -> Self
pub fn user(content: impl Into<MessageContent>) -> Self
Convenience constructor for a user text message.
Sourcepub fn assistant(content: Vec<ContentBlock>) -> Self
pub fn assistant(content: Vec<ContentBlock>) -> Self
Convenience constructor for an assistant message.
Sourcepub fn tool_result(
tool_call_id: impl Into<String>,
tool_name: impl Into<String>,
content: Vec<ContentBlock>,
) -> Self
pub fn tool_result( tool_call_id: impl Into<String>, tool_name: impl Into<String>, content: Vec<ContentBlock>, ) -> Self
Convenience constructor for a tool result message.
Sourcepub fn timestamp(&self) -> i64
pub fn timestamp(&self) -> i64
Return the timestamp (milliseconds since epoch) of this message.
Sourcepub fn text_content(&self) -> Result<String, ProviderError>
pub fn text_content(&self) -> Result<String, ProviderError>
Get the text content of this message
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
Auto Trait Implementations§
impl Freeze for Message
impl RefUnwindSafe for Message
impl Send for Message
impl Sync for Message
impl Unpin for Message
impl UnsafeUnpin 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