pub struct Message {
pub role: Role,
pub content: Vec<ContentPart>,
pub tool_calls: Vec<ToolCall>,
pub tool_call_id: Option<String>,
pub provider_state: Option<Value>,
}Expand description
A chat message.
Fields§
§role: Role§content: Vec<ContentPart>§tool_calls: Vec<ToolCall>Tool calls made by an assistant message.
tool_call_id: Option<String>For tool messages: the call this message answers.
provider_state: Option<Value>Opaque provider state attached to an assistant message (e.g. signed reasoning blocks) that must be sent back verbatim on the next turn.
Implementations§
Source§impl Message
impl Message
pub fn system(text: impl Into<String>) -> Self
pub fn user(text: impl Into<String>) -> Self
pub fn assistant(text: impl Into<String>) -> Self
Sourcepub fn tool(call_id: impl Into<String>, text: impl Into<String>) -> Self
pub fn tool(call_id: impl Into<String>, text: impl Into<String>) -> Self
A tool result answering call_id.
Sourcepub fn tool_with_images(
call_id: impl Into<String>,
text: impl Into<String>,
image_urls: impl IntoIterator<Item = String>,
) -> Self
pub fn tool_with_images( call_id: impl Into<String>, text: impl Into<String>, image_urls: impl IntoIterator<Item = String>, ) -> Self
A tool result answering call_id with images (https:// or data:
URLs) after the text. Providers that cannot put images in a tool
result send them in a user turn right after the tool results.
Sourcepub fn images(&self) -> impl Iterator<Item = &ContentPart>
pub fn images(&self) -> impl Iterator<Item = &ContentPart>
Image parts, in order.
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 Messagewhere
*const u8 is !null: Freeze,
PhantomData<ContentPart>: Freeze,
PhantomData<ToolCall>: Freeze,
PhantomData<u8>: Freeze,
PhantomData<Value>: Freeze,
PhantomData<usize>: Freeze,
PhantomData<Bucket<String, Value>>: Freeze,
impl Move for Message
impl RefUnwindSafe for Message
impl Send for Message
impl Sync for Message
impl Unpin for Message
impl UnsafeUnpin for Messagewhere
*const u8 is !null: UnsafeUnpin,
PhantomData<ContentPart>: UnsafeUnpin,
PhantomData<ToolCall>: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<Value>: UnsafeUnpin,
PhantomData<usize>: UnsafeUnpin,
PhantomData<Bucket<String, Value>>: UnsafeUnpin,
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