pub struct ChatMessage {
pub role: Role,
pub content: String,
pub timestamp: DateTime<Utc>,
pub metadata: HashMap<String, Value>,
pub tool_calls: Vec<ToolCall>,
pub tokens: Option<u64>,
pub thinking_trace: Option<String>,
pub reasoning_content: Option<String>,
pub token_usage: Option<HashMap<String, Value>>,
pub provenance: Option<InputProvenance>,
}Expand description
Represents a single message in the conversation.
Fields§
§role: Role§content: String§timestamp: DateTime<Utc>§metadata: HashMap<String, Value>§tool_calls: Vec<ToolCall>§tokens: Option<u64>§thinking_trace: Option<String>Thinking/reasoning used for this response.
reasoning_content: Option<String>Native model reasoning (o1/o3).
token_usage: Option<HashMap<String, Value>>Token usage stats (may contain nested dicts).
provenance: Option<InputProvenance>Input provenance tracking (multi-channel architecture).
Implementations§
Source§impl ChatMessage
impl ChatMessage
Sourcepub fn token_estimate(&self) -> u64
pub fn token_estimate(&self) -> u64
Estimate token count (rough approximation).
Sourcepub fn cache_token_estimate(&mut self) -> u64
pub fn cache_token_estimate(&mut self) -> u64
Estimate token count and cache the result in self.tokens.
On first call (when tokens is None), computes the estimate and
stores it so subsequent calls skip recomputation. Returns the
(possibly newly cached) value.
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