pub struct Message {
pub role: String,
pub content: Vec<ContentPart>,
pub name: Option<String>,
pub user: Option<Principal>,
pub timestamp: Option<u64>,
}Expand description
Chat message sent to or returned by an LLM provider.
Fields§
§role: StringMessage role: “system”, “user”, “assistant”, “tool”.
content: Vec<ContentPart>Message content parts.
name: Option<String>An optional name for the participant. Provides the model information to differentiate between participants of the same role. This field is not used by the model.
user: Option<Principal>The user ID of the message sender. This field is not used by the model.
timestamp: Option<u64>The timestamp of the message. This field is not used by the model.
Implementations§
Source§impl Message
impl Message
Sourcepub fn thoughts(&self) -> Option<String>
pub fn thoughts(&self) -> Option<String>
Returns all reasoning content parts joined with blank lines.
Sourcepub fn tool_calls(&self) -> Vec<ToolCall>
pub fn tool_calls(&self) -> Vec<ToolCall>
Extracts tool calls from this message.
Sourcepub fn prune_content(&mut self) -> usize
pub fn prune_content(&mut self) -> usize
Removes non-visible content parts and appends a short pruning notice.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Message
impl<'de> Deserialize<'de> for Message
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
impl Eq for Message
impl StructuralPartialEq for Message
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.