pub struct Message {
pub role: Role,
pub content: Option<Value>,
pub tool_calls: Option<Vec<ToolCall>>,
pub tool_call_id: Option<String>,
pub name: Option<String>,
pub reasoning_content: Option<String>,
pub extra: Map<String, Value>,
}Fields§
§role: Role§content: Option<Value>§tool_calls: Option<Vec<ToolCall>>§tool_call_id: Option<String>§name: Option<String>§reasoning_content: Option<String>§extra: Map<String, Value>Implementations§
Source§impl Message
impl Message
Sourcepub fn user(content: impl Into<String>) -> Message
pub fn user(content: impl Into<String>) -> Message
Build a Message with role User and the given text content.
Sourcepub fn assistant(content: impl Into<String>) -> Message
pub fn assistant(content: impl Into<String>) -> Message
Build a Message with role Assistant and the given text content.
Sourcepub fn system(content: impl Into<String>) -> Message
pub fn system(content: impl Into<String>) -> Message
Build a Message with role System and the given text content.
Sourcepub fn tool(
tool_call_id: impl Into<String>,
name: impl Into<String>,
content: impl Into<String>,
) -> Message
pub fn tool( tool_call_id: impl Into<String>, name: impl Into<String>, content: impl Into<String>, ) -> Message
Build a Message with role Tool, setting tool_call_id and name.
Sourcepub fn content_str(&self) -> Option<&str>
pub fn content_str(&self) -> Option<&str>
Return the text view of content when it is a non-empty JSON string.
Returns None for null, empty strings, and non-string variants
(e.g. multimodal arrays).
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 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