pub struct Message {
pub id: Uuid,
pub role: Role,
pub content: String,
pub session_id: Uuid,
pub timestamp: DateTime<Utc>,
pub metadata: HashMap<String, Value>,
}Expand description
A single message exchanged within a conversation session.
Fields§
§id: UuidUnique identifier for this message.
role: RoleThe role of the message author.
content: StringThe textual content of the message.
session_id: UuidThe session this message belongs to.
timestamp: DateTime<Utc>UTC timestamp of when the message was created.
metadata: HashMap<String, Value>Arbitrary key-value metadata attached to the message.
Implementations§
Source§impl Message
impl Message
Sourcepub fn new(role: Role, content: impl Into<String>, session_id: Uuid) -> Self
pub fn new(role: Role, content: impl Into<String>, session_id: Uuid) -> Self
Creates a new message with the given role, content, and session ID.
Sourcepub fn user(content: impl Into<String>, session_id: Uuid) -> Self
pub fn user(content: impl Into<String>, session_id: Uuid) -> Self
Creates a new message with Role::User.
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