pub struct Message {
pub role: MessageRole,
pub content: String,
pub metadata: MessageMeta,
pub tool_name: Option<String>,
pub tool_call_id: Option<String>,
pub tool_calls: Option<Vec<ToolCallInfo>>,
}Expand description
A conversation message with dual serialization format support.
Fields§
§role: MessageRoleMessage role (system, user, assistant, tool).
content: StringMain text content of the message.
metadata: MessageMetaMetadata tagging for tracking and budget decisions.
tool_name: Option<String>Tool name associated with the message, if it is a tool response.
tool_call_id: Option<String>Tool call identifier paired with this message.
tool_calls: Option<Vec<ToolCallInfo>>List of tool call invocations, if this is an assistant message.
Implementations§
Source§impl Message
impl Message
Sourcepub fn new(
role: MessageRole,
content: impl Into<String>,
metadata: MessageMeta,
) -> Self
pub fn new( role: MessageRole, content: impl Into<String>, metadata: MessageMeta, ) -> Self
Creates a new Message.
Sourcepub fn with_tool_name(self, name: impl Into<String>) -> Self
pub fn with_tool_name(self, name: impl Into<String>) -> Self
Sets the tool name.
Sourcepub fn with_tool_call_id(self, id: impl Into<String>) -> Self
pub fn with_tool_call_id(self, id: impl Into<String>) -> Self
Sets the tool call ID.
Sourcepub fn with_tool_calls(self, calls: Vec<ToolCallInfo>) -> Self
pub fn with_tool_calls(self, calls: Vec<ToolCallInfo>) -> Self
Sets the list of tool calls.
Trait Implementations§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreCreates a shared type from an unshared type.