#[non_exhaustive]pub struct Message {
pub role: Role,
pub parts: Vec<Part>,
}Expand description
One message of the conversation history.
The system prompt is not a message: the Agent of agentai sends its own with every
request.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.role: RoleWho wrote the message.
parts: Vec<Part>Content of the message, in order.
Implementations§
Source§impl Message
impl Message
Sourcepub fn tool_response(response: ToolResponse) -> Self
pub fn tool_response(response: ToolResponse) -> Self
Creates a message with the result of a tool call.
Sourcepub fn text(&self) -> Option<String>
pub fn text(&self) -> Option<String>
Returns the text parts joined together, or None when the message has no text.
Sourcepub fn tool_calls(&self) -> Vec<&ToolCall>
pub fn tool_calls(&self) -> Vec<&ToolCall>
Returns the tool calls in the 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 Forget for Message
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