pub enum Message {
Human {
content: MessageContent,
id: Option<String>,
},
Ai {
content: MessageContent,
tool_calls: Vec<ToolCall>,
id: Option<String>,
usage: Option<LlmUsage>,
thinking: Option<String>,
},
System {
content: MessageContent,
id: Option<String>,
},
Tool {
content: MessageContent,
tool_call_id: String,
name: Option<String>,
id: Option<String>,
status: String,
},
Remove {
id: String,
},
}Expand description
Message types for the agent system.
Mirrors the LangChain message types: HumanMessage, AIMessage, SystemMessage, ToolMessage, and RemoveMessage.
Variants§
Human
A message from the human user.
Ai
A message from the AI assistant.
Fields
§
content: MessageContentSystem
A system message providing instructions.
Tool
A message containing the result of a tool call.
Fields
§
content: MessageContentRemove
A message that removes a previous message by ID.
Implementations§
Source§impl Message
impl Message
Sourcepub fn has_tool_calls(&self) -> bool
pub fn has_tool_calls(&self) -> bool
Check if this message has tool calls.
Sourcepub fn tool_calls(&self) -> &[ToolCall]
pub fn tool_calls(&self) -> &[ToolCall]
Get tool calls from the message.
Sourcepub fn ai_with_tool_calls(
content: impl Into<String>,
tool_calls: Vec<ToolCall>,
) -> Self
pub fn ai_with_tool_calls( content: impl Into<String>, tool_calls: Vec<ToolCall>, ) -> Self
Create an AI message with tool calls.
Sourcepub fn ai_with_usage(content: impl Into<String>, usage: LlmUsage) -> Self
pub fn ai_with_usage(content: impl Into<String>, usage: LlmUsage) -> Self
Create an AI message with token usage information.
Sourcepub fn ai_with_tool_calls_and_usage(
content: impl Into<String>,
tool_calls: Vec<ToolCall>,
usage: LlmUsage,
) -> Self
pub fn ai_with_tool_calls_and_usage( content: impl Into<String>, tool_calls: Vec<ToolCall>, usage: LlmUsage, ) -> Self
Create an AI message with tool calls and token usage.
Sourcepub fn ai_with_thinking(
content: impl Into<String>,
thinking: impl Into<String>,
) -> Self
pub fn ai_with_thinking( content: impl Into<String>, thinking: impl Into<String>, ) -> Self
Create an AI message with thinking/reasoning content.
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