pub struct Message {
pub role: MessageRole,
pub parts: Vec<Part>,
pub message_id: Option<String>,
pub task_id: Option<String>,
pub context_id: Option<String>,
pub reference_task_ids: Vec<String>,
pub metadata: Option<HashMap<String, Value>>,
}Expand description
A single unit of communication
Fields§
§role: MessageRoleSender’s role
parts: Vec<Part>Content of the message
message_id: Option<String>Unique message identifier
task_id: Option<String>Associated task ID
context_id: Option<String>Conversation context ID
reference_task_ids: Vec<String>List of prior task IDs for context
metadata: Option<HashMap<String, Value>>Custom metadata
Implementations§
Source§impl Message
impl Message
Sourcepub fn new(role: MessageRole, parts: Vec<Part>) -> Self
pub fn new(role: MessageRole, parts: Vec<Part>) -> Self
Create a new message
Sourcepub fn agent_text(text: impl Into<String>) -> Self
pub fn agent_text(text: impl Into<String>) -> Self
Create a text message from the agent
Sourcepub fn with_task_id(self, task_id: impl Into<String>) -> Self
pub fn with_task_id(self, task_id: impl Into<String>) -> Self
Set the task ID
Sourcepub fn with_context_id(self, context_id: impl Into<String>) -> Self
pub fn with_context_id(self, context_id: impl Into<String>) -> Self
Set the context ID
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
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