pub struct ChatMessage {
pub role: String,
pub content: String,
pub timestamp: DateTime<Utc>,
pub tool_call_id: Option<String>,
pub tool_calls: Option<Vec<Value>>,
pub name: Option<String>,
pub reasoning_content: Option<String>,
pub thinking_blocks: Option<Vec<Value>>,
}Expand description
A chat message
Fields§
§role: StringMessage role (user, assistant, system, tool)
content: StringMessage content
timestamp: DateTime<Utc>Message timestamp
tool_call_id: Option<String>Tool call ID (for tool-result messages)
tool_calls: Option<Vec<Value>>Tool calls made by the assistant
name: Option<String>Tool name (for tool-result messages)
reasoning_content: Option<String>Optional reasoning content captured from thinking-capable models
thinking_blocks: Option<Vec<Value>>Optional structured thinking blocks (provider-specific)
Implementations§
Source§impl ChatMessage
impl ChatMessage
Sourcepub fn new(role: impl Into<String>, content: impl Into<String>) -> Self
pub fn new(role: impl Into<String>, content: impl Into<String>) -> Self
Create a new chat message
Sourcepub fn with_tool_metadata(
role: impl Into<String>,
content: impl Into<String>,
tool_call_id: Option<String>,
tool_calls: Option<Vec<Value>>,
name: Option<String>,
) -> Self
pub fn with_tool_metadata( role: impl Into<String>, content: impl Into<String>, tool_call_id: Option<String>, tool_calls: Option<Vec<Value>>, name: Option<String>, ) -> Self
Create a chat message with full tool metadata
Sourcepub fn to_llm_format(&self) -> Value
pub fn to_llm_format(&self) -> Value
Convert to LLM format (role and content only)
Trait Implementations§
Source§impl Clone for ChatMessage
impl Clone for ChatMessage
Source§fn clone(&self) -> ChatMessage
fn clone(&self) -> ChatMessage
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 ChatMessage
impl Debug for ChatMessage
Source§impl<'de> Deserialize<'de> for ChatMessage
impl<'de> Deserialize<'de> for ChatMessage
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 ChatMessage
impl RefUnwindSafe for ChatMessage
impl Send for ChatMessage
impl Sync for ChatMessage
impl Unpin for ChatMessage
impl UnsafeUnpin for ChatMessage
impl UnwindSafe for ChatMessage
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