pub enum BaseMessage {
Human(HumanMessage),
System(SystemMessage),
AI(AIMessage),
Tool(ToolMessage),
Chat(ChatMessage),
Function(FunctionMessage),
Remove(RemoveMessage),
}Expand description
A unified message type that can represent any message role.
This corresponds to BaseMessage in LangChain Python.
Variants§
Human(HumanMessage)
A human message
System(SystemMessage)
A system message
AI(AIMessage)
An AI message
Tool(ToolMessage)
A tool result message
Chat(ChatMessage)
A chat message with arbitrary role
Function(FunctionMessage)
A function message (deprecated, use Tool)
Remove(RemoveMessage)
A remove message (for message deletion)
Implementations§
Source§impl BaseMessage
impl BaseMessage
Sourcepub fn content(&self) -> &str
pub fn content(&self) -> &str
Get the message content as a string reference.
For messages with multimodal content, this returns the first text content or an empty string.
Sourcepub fn text(&self) -> String
pub fn text(&self) -> String
Get the text content of the message as a string.
This extracts text from both simple string content and list content
(filtering for text blocks). Corresponds to the text property in Python.
Sourcepub fn tool_calls(&self) -> &[ToolCall]
pub fn tool_calls(&self) -> &[ToolCall]
Get tool calls if this is an AI message.
Sourcepub fn message_type(&self) -> &'static str
pub fn message_type(&self) -> &'static str
Get the message type as a string.
Sourcepub fn additional_kwargs(&self) -> Option<&HashMap<String, Value>>
pub fn additional_kwargs(&self) -> Option<&HashMap<String, Value>>
Get additional kwargs if present.
Sourcepub fn response_metadata(&self) -> Option<&HashMap<String, Value>>
pub fn response_metadata(&self) -> Option<&HashMap<String, Value>>
Get response metadata if present.
Sourcepub fn pretty_print(&self)
pub fn pretty_print(&self)
Pretty print the message to stdout. This mimics LangChain’s pretty_print() method for messages.
Sourcepub fn pretty_repr(&self, html: bool) -> String
pub fn pretty_repr(&self, html: bool) -> String
Get a pretty representation of the message.
§Arguments
html- Whether to format the message with bold text (using ANSI codes). Namedhtmlfor Python compatibility but actually uses terminal codes.
Trait Implementations§
Source§impl Clone for BaseMessage
impl Clone for BaseMessage
Source§fn clone(&self) -> BaseMessage
fn clone(&self) -> BaseMessage
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more