pub struct Message {
pub id: String,
pub role: MessageRole,
pub parts: Vec<MessagePart>,
pub metadata: Option<Value>,
}Expand description
A message exchanged between agents during a task.
Fields§
§id: StringUnique identifier for this message.
role: MessageRoleRole of the sender.
parts: Vec<MessagePart>Content parts of the message.
metadata: Option<Value>Optional metadata.
Implementations§
Source§impl Message
impl Message
Sourcepub fn user(parts: Vec<MessagePart>) -> Self
pub fn user(parts: Vec<MessagePart>) -> Self
Create a message from the user (client agent).
Sourcepub fn agent(parts: Vec<MessagePart>) -> Self
pub fn agent(parts: Vec<MessagePart>) -> Self
Create a message from the remote agent.
Sourcepub fn user_text(text: impl Into<String>) -> Self
pub fn user_text(text: impl Into<String>) -> Self
Convenience: create a user message with a single text part.
Sourcepub fn agent_text(text: impl Into<String>) -> Self
pub fn agent_text(text: impl Into<String>) -> Self
Convenience: create an agent message with a single text part.
Sourcepub fn text_content(&self) -> String
pub fn text_content(&self) -> String
Extract all text content from this message.
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 JsonSchema for Message
impl JsonSchema for Message
Source§fn schema_name() -> String
fn schema_name() -> String
The name of the generated JSON Schema. Read more
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 is_referenceable() -> bool
fn is_referenceable() -> bool
Whether JSON Schemas generated for this type should be re-used where possible using the
$ref keyword. Read moreAuto 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