pub enum AgUiMessage {
Developer {
id: MessageId,
content: String,
name: Option<String>,
},
System {
id: MessageId,
content: String,
name: Option<String>,
},
Assistant {
id: MessageId,
content: Option<String>,
name: Option<String>,
tool_calls: Option<Vec<ToolCall>>,
},
User {
id: MessageId,
content: String,
name: Option<String>,
},
Tool {
id: MessageId,
content: String,
tool_call_id: ToolCallId,
error: Option<String>,
},
Activity {
id: MessageId,
activity_type: String,
content: Value,
},
}Expand description
Represents the different types of messages in a conversation.
This enum provides a unified type for all message variants, using the role field as the discriminant for JSON serialization.
Variants§
Developer
A developer message for debugging.
System
A system message (usually the system prompt).
Assistant
An assistant message from the AI model.
User
A user message from the human user.
Tool
A tool message containing tool call results.
Activity
An activity message for tracking agent activities.
Implementations§
Source§impl Message
impl Message
Sourcepub fn new<S>(role: Role, id: impl Into<MessageId>, content: S) -> Message
pub fn new<S>(role: Role, id: impl Into<MessageId>, content: S) -> Message
Creates a new message with the given role, ID, and content.
Sourcepub fn new_system<S>(content: S) -> Message
pub fn new_system<S>(content: S) -> Message
Creates a new system message with a random ID.
Sourcepub fn new_assistant<S>(content: S) -> Message
pub fn new_assistant<S>(content: S) -> Message
Creates a new assistant message with a random ID.
Sourcepub fn new_developer<S>(content: S) -> Message
pub fn new_developer<S>(content: S) -> Message
Creates a new developer message with a random ID.
Sourcepub fn new_activity(activity_type: impl Into<String>, content: Value) -> Message
pub fn new_activity(activity_type: impl Into<String>, content: Value) -> Message
Creates a new activity message with a random ID.
Sourcepub fn content(&self) -> Option<&str>
pub fn content(&self) -> Option<&str>
Returns the content of this message, if any.
Note: Activity messages have JSON content, not string content.
Use activity_content() to access their content.
Sourcepub fn content_mut(&mut self) -> Option<&mut String>
pub fn content_mut(&mut self) -> Option<&mut String>
Returns a mutable reference to the content of this message.
Note: Activity messages have JSON content, not string content.
Use activity_content_mut() to modify their content.
Sourcepub fn activity_content(&self) -> Option<&Value>
pub fn activity_content(&self) -> Option<&Value>
Returns the activity content of this message, if it’s an activity message.
Sourcepub fn activity_content_mut(&mut self) -> Option<&mut Value>
pub fn activity_content_mut(&mut self) -> Option<&mut Value>
Returns a mutable reference to the activity content, if it’s an activity message.
Sourcepub fn activity_type(&self) -> Option<&str>
pub fn activity_type(&self) -> Option<&str>
Returns the activity type, if this is an activity message.
Sourcepub fn tool_calls(&self) -> Option<&[ToolCall]>
pub fn tool_calls(&self) -> Option<&[ToolCall]>
Returns the tool calls for this message, if any.
Sourcepub fn tool_calls_mut(&mut self) -> Option<&mut Vec<ToolCall>>
pub fn tool_calls_mut(&mut self) -> Option<&mut Vec<ToolCall>>
Returns a mutable reference to the tool calls for this message.
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>,
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,
impl 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
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> 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>
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>
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 more