pub struct Message {
pub role: Role,
pub content: String,
pub tool_calls: Vec<ToolCall>,
pub tool_results: Vec<ToolCallResult>,
pub timestamp: DateTime<Utc>,
pub content_parts: Vec<ContentPart>,
}Expand description
A message in a bout (conversation).
Fields§
§role: RoleThe role of the message sender.
content: StringText content of the message (may be empty for tool-only messages).
tool_calls: Vec<ToolCall>Tool calls requested by the assistant.
tool_results: Vec<ToolCallResult>Results from tool executions (for role = Tool).
timestamp: DateTime<Utc>When the message was created.
content_parts: Vec<ContentPart>Multimodal content parts (images, etc.). When non-empty, drivers should
use these instead of content for multimodal-capable providers.
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
Create a simple text message with the current timestamp.
Sourcepub fn with_parts(
role: Role,
content: impl Into<String>,
parts: Vec<ContentPart>,
) -> Self
pub fn with_parts( role: Role, content: impl Into<String>, parts: Vec<ContentPart>, ) -> Self
Create a message with multimodal content parts.
Sourcepub fn has_images(&self) -> bool
pub fn has_images(&self) -> bool
Returns true if this message contains any image content parts.
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
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