pub struct Message {
pub role: Role,
pub content: Vec<Content>,
pub tool_call_id: Option<String>,
}Expand description
A message in a conversation.
Fields§
§role: RoleRole of the message sender.
content: Vec<Content>Content blocks in this message.
tool_call_id: Option<String>ID of the tool call this message responds to (for Tool role).
Implementations§
Source§impl Message
impl Message
Sourcepub fn assistant(text: impl Into<String>) -> Self
pub fn assistant(text: impl Into<String>) -> Self
Creates an assistant message with text content.
Sourcepub fn tool_result(
call_id: impl Into<String>,
result: impl Into<String>,
) -> Self
pub fn tool_result( call_id: impl Into<String>, result: impl Into<String>, ) -> Self
Creates a tool result message.
Sourcepub fn tool_call_id(&self) -> Option<&str>
pub fn tool_call_id(&self) -> Option<&str>
Returns the tool call ID if this is a tool result message.
Sourcepub fn tool_calls(&self) -> impl Iterator<Item = &ToolCall>
pub fn tool_calls(&self) -> impl Iterator<Item = &ToolCall>
Returns an iterator over tool calls in this message.
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 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