pub enum Message {
System {
content: String,
id: Option<String>,
name: Option<String>,
additional_kwargs: HashMap<String, Value>,
response_metadata: HashMap<String, Value>,
content_blocks: Vec<ContentBlock>,
},
Human {
content: String,
id: Option<String>,
name: Option<String>,
additional_kwargs: HashMap<String, Value>,
response_metadata: HashMap<String, Value>,
content_blocks: Vec<ContentBlock>,
},
AI {
content: String,
tool_calls: Vec<ToolCall>,
id: Option<String>,
name: Option<String>,
additional_kwargs: HashMap<String, Value>,
response_metadata: HashMap<String, Value>,
content_blocks: Vec<ContentBlock>,
usage_metadata: Option<TokenUsage>,
invalid_tool_calls: Vec<InvalidToolCall>,
},
Tool {
content: String,
tool_call_id: String,
id: Option<String>,
name: Option<String>,
additional_kwargs: HashMap<String, Value>,
response_metadata: HashMap<String, Value>,
content_blocks: Vec<ContentBlock>,
},
Chat {
custom_role: String,
content: String,
id: Option<String>,
name: Option<String>,
additional_kwargs: HashMap<String, Value>,
response_metadata: HashMap<String, Value>,
content_blocks: Vec<ContentBlock>,
},
Remove {
id: String,
},
}Expand description
Represents a chat message. Tagged enum with System, Human, AI, and Tool variants.
Variants§
System
Fields
§
content_blocks: Vec<ContentBlock>Human
Fields
§
content_blocks: Vec<ContentBlock>AI
Fields
§
content_blocks: Vec<ContentBlock>§
usage_metadata: Option<TokenUsage>§
invalid_tool_calls: Vec<InvalidToolCall>Tool
Fields
§
content_blocks: Vec<ContentBlock>Chat
Fields
§
content_blocks: Vec<ContentBlock>Remove
A special message that signals removal of a message by its ID. Used in message history management.
Implementations§
Source§impl Message
impl Message
pub fn system(content: impl Into<String>) -> Self
pub fn human(content: impl Into<String>) -> Self
pub fn ai(content: impl Into<String>) -> Self
pub fn ai_with_tool_calls( content: impl Into<String>, tool_calls: Vec<ToolCall>, ) -> Self
pub fn tool(content: impl Into<String>, tool_call_id: impl Into<String>) -> Self
pub fn chat(role: impl Into<String>, content: impl Into<String>) -> Self
Sourcepub fn remove(id: impl Into<String>) -> Self
pub fn remove(id: impl Into<String>) -> Self
Create a Remove message that signals removal of a message by its ID.
pub fn with_id(self, value: impl Into<String>) -> Self
pub fn with_name(self, value: impl Into<String>) -> Self
pub fn with_additional_kwarg(self, key: impl Into<String>, value: Value) -> Self
pub fn with_response_metadata_entry( self, key: impl Into<String>, value: Value, ) -> Self
pub fn with_content_blocks(self, blocks: Vec<ContentBlock>) -> Self
pub fn with_usage_metadata(self, usage: TokenUsage) -> Self
pub fn content(&self) -> &str
pub fn role(&self) -> &str
pub fn is_system(&self) -> bool
pub fn is_human(&self) -> bool
pub fn is_ai(&self) -> bool
pub fn is_tool(&self) -> bool
pub fn is_chat(&self) -> bool
pub fn is_remove(&self) -> bool
pub fn tool_calls(&self) -> &[ToolCall]
pub fn tool_call_id(&self) -> Option<&str>
pub fn id(&self) -> Option<&str>
pub fn name(&self) -> Option<&str>
pub fn additional_kwargs(&self) -> &HashMap<String, Value>
pub fn response_metadata(&self) -> &HashMap<String, Value>
pub fn content_blocks(&self) -> &[ContentBlock]
pub fn usage_metadata(&self) -> Option<&TokenUsage>
pub fn invalid_tool_calls(&self) -> &[InvalidToolCall]
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 Eq for Message
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 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