pub enum Message {
Developer(DeveloperMessage),
System(SystemMessage),
Assistant(AssistantMessage),
User(UserMessage),
Tool(ToolMessage),
Activity(ActivityMessage),
Reasoning(ReasoningMessage),
}Expand description
A message in a thread, discriminated by its role.
Variants§
Developer(DeveloperMessage)
See DeveloperMessage.
System(SystemMessage)
See SystemMessage.
Assistant(AssistantMessage)
See AssistantMessage.
User(UserMessage)
See UserMessage.
Tool(ToolMessage)
See ToolMessage.
Activity(ActivityMessage)
See ActivityMessage.
Reasoning(ReasoningMessage)
See ReasoningMessage.
Implementations§
Source§impl Message
impl Message
Sourcepub fn user(id: impl Into<MessageId>, content: impl Into<UserContent>) -> Self
pub fn user(id: impl Into<MessageId>, content: impl Into<UserContent>) -> Self
Builds a user message carrying plain text.
Sourcepub fn assistant(id: impl Into<MessageId>, content: impl Into<String>) -> Self
pub fn assistant(id: impl Into<MessageId>, content: impl Into<String>) -> Self
Builds an assistant message carrying plain text.
Sourcepub fn system(id: impl Into<MessageId>, content: impl Into<String>) -> Self
pub fn system(id: impl Into<MessageId>, content: impl Into<String>) -> Self
Builds a system message.
Sourcepub fn developer(id: impl Into<MessageId>, content: impl Into<String>) -> Self
pub fn developer(id: impl Into<MessageId>, content: impl Into<String>) -> Self
Builds a developer message.
Sourcepub fn tool(
id: impl Into<MessageId>,
tool_call_id: impl Into<ToolCallId>,
content: impl Into<String>,
) -> Self
pub fn tool( id: impl Into<MessageId>, tool_call_id: impl Into<ToolCallId>, content: impl Into<String>, ) -> Self
Builds a tool result message.
Sourcepub const fn subagent_run_id(&self) -> Option<&SubagentRunId>
pub const fn subagent_run_id(&self) -> Option<&SubagentRunId>
The subagent that produced the message, whatever the role. None
means the parent agent. See crate::event::subagent.
Sourcepub fn set_subagent_run_id(&mut self, subagent_run_id: Option<SubagentRunId>)
pub fn set_subagent_run_id(&mut self, subagent_run_id: Option<SubagentRunId>)
Sets or clears the subagent the message is attributed to.
Sourcepub const fn metadata(&self) -> Option<&JsonObject>
pub const fn metadata(&self) -> Option<&JsonObject>
The message’s metadata, whatever the role. See crate::metadata.
Sourcepub fn metadata_mut(&mut self) -> &mut Option<JsonObject>
pub fn metadata_mut(&mut self) -> &mut Option<JsonObject>
The metadata slot, for a consumer merging an event’s metadata into
the message it builds — see
merge_metadata_into.
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
Source§impl From<ActivityMessage> for Message
impl From<ActivityMessage> for Message
Source§fn from(value: ActivityMessage) -> Self
fn from(value: ActivityMessage) -> Self
Converts to this type from the input type.
Source§impl From<AssistantMessage> for Message
impl From<AssistantMessage> for Message
Source§fn from(value: AssistantMessage) -> Self
fn from(value: AssistantMessage) -> Self
Converts to this type from the input type.
Source§impl From<DeveloperMessage> for Message
impl From<DeveloperMessage> for Message
Source§fn from(value: DeveloperMessage) -> Self
fn from(value: DeveloperMessage) -> Self
Converts to this type from the input type.
Source§impl From<ReasoningMessage> for Message
impl From<ReasoningMessage> for Message
Source§fn from(value: ReasoningMessage) -> Self
fn from(value: ReasoningMessage) -> Self
Converts to this type from the input type.
Source§impl From<SystemMessage> for Message
impl From<SystemMessage> for Message
Source§fn from(value: SystemMessage) -> Self
fn from(value: SystemMessage) -> Self
Converts to this type from the input type.
Source§impl From<ToolMessage> for Message
impl From<ToolMessage> for Message
Source§fn from(value: ToolMessage) -> Self
fn from(value: ToolMessage) -> Self
Converts to this type from the input type.
Source§impl From<UserMessage> for Message
impl From<UserMessage> for Message
Source§fn from(value: UserMessage) -> Self
fn from(value: UserMessage) -> Self
Converts to this type from the input type.
Source§impl JsonSchema for Message
impl JsonSchema for Message
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. Read more
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
Whether JSON Schemas generated for this type should be included directly in parent schemas,
rather than being re-used where possible using the
$ref keyword. Read moreimpl StructuralPartialEq for Message
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