pub struct ChatMessage {
pub role: String,
pub content: String,
pub reasoning_content: Option<String>,
pub tool_call_id: Option<String>,
pub tool_calls: Option<Vec<ToolCallRequest>>,
}Expand description
Data structure of a chat message, could be from the user, the assistant or the tool.
Fields:
role: The role of the message.content: Text string content of the message.reasoning_content: Reasoning content in string.tool_call_id: Only valid for messages withroleof"tool". It indicates which tool call this message is responding to.tool_calls: Only valid for messages withroleof"assistant". It is the tool calls requested by the model.
Fields§
§role: String§content: String§reasoning_content: Option<String>§tool_call_id: Option<String>§tool_calls: Option<Vec<ToolCallRequest>>Implementations§
Source§impl ChatMessage
impl ChatMessage
Sourcepub fn apply_model_response_chunk(&mut self, chunk: ChatResponseChunkDelta)
pub fn apply_model_response_chunk(&mut self, chunk: ChatResponseChunkDelta)
Consume the chunk delta return from the chat completion stream API and apply it on to the message.
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 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