pub struct Message {
pub role: MessageRole,
pub content: Vec<Item>,
pub name: Option<String>,
}Expand description
A chat message: an author role plus ordered content parts.
Content parts are themselves Items, allowing multimodal messages (e.g. a
Item::Text alongside a Item::Image).
Fields§
§role: MessageRoleThe author role.
content: Vec<Item>The ordered content parts of the message.
name: Option<String>Optional participant name.
Implementations§
Source§impl Message
impl Message
Sourcepub fn new(role: MessageRole, content: impl Into<Vec<Item>>) -> Self
pub fn new(role: MessageRole, content: impl Into<Vec<Item>>) -> Self
Create a message with the given role and content parts.
Sourcepub fn with_name(self, name: impl Into<String>) -> Self
pub fn with_name(self, name: impl Into<String>) -> Self
Set the participant name (builder-style).
Sourcepub fn is_simple_text(&self) -> bool
pub fn is_simple_text(&self) -> bool
Whether the message consists of a single Item::Text content part.
Sourcepub fn text(&self) -> String
pub fn text(&self) -> String
The concatenated text of all Item::Text content parts.
Non-text parts are ignored. Returns an empty string if there are none.
Trait Implementations§
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
Mutably borrows from an owned value. Read more