pub struct Message {
pub role: Role,
pub content: String,
pub reasoning_content: String,
pub tool_call_id: CompactString,
pub tool_calls: SmallVec<[ToolCall; 4]>,
}Expand description
A message in the chat
Fields§
§role: RoleThe role of the message
content: StringThe content of the message
reasoning_content: StringThe reasoning content
tool_call_id: CompactStringThe tool call id
tool_calls: SmallVec<[ToolCall; 4]>The tool calls
Implementations§
Source§impl Message
impl Message
Sourcepub fn assistant(
content: impl Into<String>,
reasoning: Option<String>,
tool_calls: Option<&[ToolCall]>,
) -> Message
pub fn assistant( content: impl Into<String>, reasoning: Option<String>, tool_calls: Option<&[ToolCall]>, ) -> Message
Create a new assistant message
Sourcepub fn tool(
content: impl Into<String>,
call: impl Into<CompactString>,
) -> Message
pub fn tool( content: impl Into<String>, call: impl Into<CompactString>, ) -> Message
Create a new tool message
Sourcepub fn builder(role: Role) -> MessageBuilder
pub fn builder(role: Role) -> MessageBuilder
Create a new message builder
Sourcepub fn estimate_tokens(&self) -> usize
pub fn estimate_tokens(&self) -> usize
Estimate the number of tokens in this message.
Uses a simple heuristic: ~4 characters per token.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Message
impl<'de> Deserialize<'de> for Message
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Message, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Message, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Serialize for Message
impl Serialize for Message
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations§
impl Freeze for Message
impl RefUnwindSafe for Message
impl Send for Message
impl Sync for Message
impl Unpin for Message
impl UnsafeUnpin for Message
impl UnwindSafe for Message
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