pub struct Message {
pub role: Role,
pub content: MessageContent,
pub name: Option<String>,
pub tool_calls: Option<Vec<ToolCall>>,
pub tool_call_id: Option<String>,
pub reasoning_content: Option<String>,
pub audio: Option<MessageAudio>,
}Expand description
A message in the conversation.
Fields§
§role: RoleThe role of the message author
content: MessageContentThe content of the message
name: Option<String>Optional name for the participant
tool_calls: Option<Vec<ToolCall>>Tool calls (for assistant messages)
tool_call_id: Option<String>Tool call ID (for tool messages)
reasoning_content: Option<String>Reasoning content (for thinking mode)
audio: Option<MessageAudio>Audio data (for assistant messages with audio output)
Implementations§
Source§impl Message
impl Message
Sourcepub fn new(role: Role, content: MessageContent) -> Self
pub fn new(role: Role, content: MessageContent) -> Self
Create a new message.
Sourcepub fn system(content: impl Into<MessageContent>) -> Self
pub fn system(content: impl Into<MessageContent>) -> Self
Create a system message.
Sourcepub fn developer(content: impl Into<MessageContent>) -> Self
pub fn developer(content: impl Into<MessageContent>) -> Self
Create a developer message.
Sourcepub fn user(content: impl Into<MessageContent>) -> Self
pub fn user(content: impl Into<MessageContent>) -> Self
Create a user message.
Sourcepub fn assistant(content: impl Into<MessageContent>) -> Self
pub fn assistant(content: impl Into<MessageContent>) -> Self
Create an assistant message.
Sourcepub fn tool(tool_call_id: impl Into<String>, content: impl Into<String>) -> Self
pub fn tool(tool_call_id: impl Into<String>, content: impl Into<String>) -> Self
Create a tool response message.
Sourcepub fn with_tool_calls(self, tool_calls: Vec<ToolCall>) -> Self
pub fn with_tool_calls(self, tool_calls: Vec<ToolCall>) -> Self
Set the tool calls.
Sourcepub fn with_reasoning_content(self, content: impl Into<String>) -> Self
pub fn with_reasoning_content(self, content: impl Into<String>) -> Self
Set the reasoning content.
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