pub struct ChatMessage {Show 13 fields
pub role: Role,
pub content: Option<MessageContent>,
pub name: Option<String>,
pub tool_calls: Option<Vec<ToolCall>>,
pub tool_call_id: Option<String>,
pub usage: Option<LLMTokenUsage>,
pub id: Option<String>,
pub model: Option<ModelInfo>,
pub cost: Option<f64>,
pub finish_reason: Option<String>,
pub created_at: Option<i64>,
pub completed_at: Option<i64>,
pub metadata: Option<Value>,
}Expand description
Chat message
Fields§
§role: Role§content: Option<MessageContent>§name: Option<String>§tool_calls: Option<Vec<ToolCall>>§tool_call_id: Option<String>§usage: Option<LLMTokenUsage>§id: Option<String>Unique message identifier
model: Option<ModelInfo>Model that generated this message (for assistant messages)
cost: Option<f64>Cost in dollars for this message
finish_reason: Option<String>Why the model stopped: “stop”, “tool_calls”, “length”, “error”
created_at: Option<i64>Unix timestamp (ms) when message was created/sent
completed_at: Option<i64>Unix timestamp (ms) when assistant finished generating
metadata: Option<Value>Plugin extensibility - unstructured metadata
Implementations§
Source§impl ChatMessage
impl ChatMessage
pub fn last_server_message(messages: &[ChatMessage]) -> Option<&ChatMessage>
pub fn to_xml(&self) -> String
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 Default for ChatMessage
impl Default for ChatMessage
Source§fn default() -> ChatMessage
fn default() -> ChatMessage
Returns the “default value” for a type. Read more
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
Source§impl From<ChatMessage> for LLMMessage
impl From<ChatMessage> for LLMMessage
Source§fn from(chat_message: ChatMessage) -> Self
fn from(chat_message: ChatMessage) -> Self
Converts to this type from the input type.
Source§impl From<LLMMessage> for ChatMessage
impl From<LLMMessage> for ChatMessage
Source§fn from(llm_message: LLMMessage) -> Self
fn from(llm_message: LLMMessage) -> Self
Converts to this type from the input type.
Source§impl PartialEq for ChatMessage
impl PartialEq for ChatMessage
Source§impl Serialize for ChatMessage
impl Serialize for ChatMessage
impl StructuralPartialEq for ChatMessage
Auto Trait Implementations§
impl Freeze for ChatMessage
impl RefUnwindSafe for ChatMessage
impl Send for ChatMessage
impl Sync for ChatMessage
impl Unpin 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