pub struct Message {
pub role: Role,
pub content: MessageContent,
}
Expand description
A message in a conversation.
Fields§
§role: Role
The role of the message sender
content: MessageContent
The content of the message
Implementations§
Source§impl Message
impl Message
Sourcepub fn assistant(content: impl Into<String>) -> Message
pub fn assistant(content: impl Into<String>) -> Message
Create an assistant message with text content
Sourcepub fn tool_response(
content: impl Into<String>,
tool_call_id: impl Into<String>,
) -> Message
pub fn tool_response( content: impl Into<String>, tool_call_id: impl Into<String>, ) -> Message
Create a tool response message
Sourcepub fn assistant_with_tools(
content: impl Into<String>,
tool_calls: Vec<ToolCall>,
) -> Message
pub fn assistant_with_tools( content: impl Into<String>, tool_calls: Vec<ToolCall>, ) -> Message
Create an assistant message with tool calls
Sourcepub fn user_multimodal(content: Vec<ContentPart>) -> Message
pub fn user_multimodal(content: Vec<ContentPart>) -> Message
Create a user message with multimodal content
Sourcepub fn assistant_multimodal(content: Vec<ContentPart>) -> Message
pub fn assistant_multimodal(content: Vec<ContentPart>) -> Message
Create an assistant message with multimodal content
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Message
impl<'de> Deserialize<'de> for Message
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Message, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Message, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Serialize for Message
impl Serialize for Message
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. 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 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