pub struct Message {
pub role: Role,
pub content: Option<String>,
pub tool_calls: Vec<ToolCall>,
pub tool_call_id: Option<String>,
}Expand description
A single message in a conversation.
Fields§
§role: RoleWho produced this message.
content: Option<String>Text content of the message (may be None for tool-call-only messages).
tool_calls: Vec<ToolCall>Tool calls requested by the assistant.
tool_call_id: Option<String>The tool call ID this message is responding to (for Role::Tool).
Implementations§
Source§impl Message
impl Message
Sourcepub fn assistant(content: impl Into<String>) -> Self
pub fn assistant(content: impl Into<String>) -> Self
Create an assistant message with text content.
Sourcepub fn assistant_with_tool_calls(tool_calls: Vec<ToolCall>) -> Self
pub fn assistant_with_tool_calls(tool_calls: Vec<ToolCall>) -> Self
Create an assistant message that contains tool calls (no text).
Sourcepub fn assistant_with_text_and_tool_calls(
content: impl Into<String>,
tool_calls: Vec<ToolCall>,
) -> Self
pub fn assistant_with_text_and_tool_calls( content: impl Into<String>, tool_calls: Vec<ToolCall>, ) -> Self
Create an assistant message that carries both text and tool calls.
Models such as Anthropic and Gemini emit reasoning text alongside a tool call in the same turn; preserving both keeps replayed history faithful to what the model produced.
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