pub struct ToolMessage { /* private fields */ }Expand description
A tool message containing the result of a tool call.
ToolMessage objects contain the result of a tool invocation. Typically, the result
is encoded inside the content field.
This corresponds to ToolMessage in LangChain Python.
Implementations§
Source§impl ToolMessage
impl ToolMessage
Sourcepub fn new(content: impl Into<String>, tool_call_id: impl Into<String>) -> Self
pub fn new(content: impl Into<String>, tool_call_id: impl Into<String>) -> Self
Create a new tool message.
Sourcepub fn with_id(
id: impl Into<String>,
content: impl Into<String>,
tool_call_id: impl Into<String>,
) -> Self
pub fn with_id( id: impl Into<String>, content: impl Into<String>, tool_call_id: impl Into<String>, ) -> Self
Create a new tool message with an explicit ID.
Use this when deserializing or reconstructing messages where the ID must be preserved.
Sourcepub fn error(
content: impl Into<String>,
tool_call_id: impl Into<String>,
) -> Self
pub fn error( content: impl Into<String>, tool_call_id: impl Into<String>, ) -> Self
Create a new tool message with error status.
Sourcepub fn with_artifact(
content: impl Into<String>,
tool_call_id: impl Into<String>,
artifact: Value,
) -> Self
pub fn with_artifact( content: impl Into<String>, tool_call_id: impl Into<String>, artifact: Value, ) -> Self
Create a new tool message with an artifact.
Sourcepub fn tool_call_id(&self) -> &str
pub fn tool_call_id(&self) -> &str
Get the tool call ID this message responds to.
Sourcepub fn status(&self) -> &ToolStatus
pub fn status(&self) -> &ToolStatus
Get the status of the tool invocation.
Sourcepub fn additional_kwargs(&self) -> &HashMap<String, Value>
pub fn additional_kwargs(&self) -> &HashMap<String, Value>
Get additional kwargs.
Sourcepub fn response_metadata(&self) -> &HashMap<String, Value>
pub fn response_metadata(&self) -> &HashMap<String, Value>
Get response metadata.
Trait Implementations§
Source§impl Clone for ToolMessage
impl Clone for ToolMessage
Source§fn clone(&self) -> ToolMessage
fn clone(&self) -> ToolMessage
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ToolMessage
impl Debug for ToolMessage
Source§impl<'de> Deserialize<'de> for ToolMessage
impl<'de> Deserialize<'de> for ToolMessage
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
Source§impl From<ToolMessage> for BaseMessage
impl From<ToolMessage> for BaseMessage
Source§fn from(msg: ToolMessage) -> Self
fn from(msg: ToolMessage) -> Self
Converts to this type from the input type.
Source§impl From<ToolMessage> for ToolOutput
impl From<ToolMessage> for ToolOutput
Source§fn from(m: ToolMessage) -> Self
fn from(m: ToolMessage) -> Self
Converts to this type from the input type.
Source§impl PartialEq for ToolMessage
impl PartialEq for ToolMessage
Source§impl Serialize for ToolMessage
impl Serialize for ToolMessage
impl StructuralPartialEq for ToolMessage
impl ToolOutputMixin for ToolMessage
Auto Trait Implementations§
impl Freeze for ToolMessage
impl RefUnwindSafe for ToolMessage
impl Send for ToolMessage
impl Sync for ToolMessage
impl Unpin for ToolMessage
impl UnwindSafe for ToolMessage
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