pub struct Message { /* private fields */ }Expand description
A single message in a conversation.
Implementations§
Source§impl Message
impl Message
Sourcepub fn new(role: Role, content: impl Into<String>) -> Self
pub fn new(role: Role, content: impl Into<String>) -> Self
Creates a new Message with the specified role and content.
Sourcepub fn with_tool_calls(self, tool_calls: Vec<ToolCall>) -> Self
pub fn with_tool_calls(self, tool_calls: Vec<ToolCall>) -> Self
Adds tool calls to this message.
Sourcepub fn with_tool_call_id(self, tool_call_id: impl Into<String>) -> Self
pub fn with_tool_call_id(self, tool_call_id: impl Into<String>) -> Self
Sets the tool call ID for this message.
Sourcepub fn tool_calls(&self) -> Option<&[ToolCall]>
pub fn tool_calls(&self) -> Option<&[ToolCall]>
Returns the tool calls associated with this message, if any.
Sourcepub fn tool_call_id(&self) -> Option<&str>
pub fn tool_call_id(&self) -> Option<&str>
Returns the tool call ID associated with this message, if any.
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