#[non_exhaustive]pub enum Message {
System(SystemMessage),
User(UserMessage),
Assistant(AssistantMessage),
Tool(ToolMessage),
}Expand description
A message in an application conversation, tagged by role.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
System(SystemMessage)
Instructions for the model.
User(UserMessage)
Input from the user.
Assistant(AssistantMessage)
Output from the model.
Tool(ToolMessage)
Tool results and approval responses.
Implementations§
Source§impl Message
impl Message
Sourcepub fn user_parts(parts: impl IntoIterator<Item = impl Into<UserPart>>) -> Self
pub fn user_parts(parts: impl IntoIterator<Item = impl Into<UserPart>>) -> Self
A user message with parts.
Sourcepub fn assistant_parts(
parts: impl IntoIterator<Item = impl Into<AssistantPart>>,
) -> Self
pub fn assistant_parts( parts: impl IntoIterator<Item = impl Into<AssistantPart>>, ) -> Self
An assistant message with parts.
Sourcepub fn tool(parts: impl IntoIterator<Item = impl Into<ToolPart>>) -> Self
pub fn tool(parts: impl IntoIterator<Item = impl Into<ToolPart>>) -> Self
A tool message.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true when the message carries no content (empty string or
no parts).
Sourcepub fn provider_options(&self) -> Option<&ProviderOptions>
pub fn provider_options(&self) -> Option<&ProviderOptions>
Provider-specific options.
Sourcepub fn with_provider_options(self, options: ProviderOptions) -> Self
pub fn with_provider_options(self, options: ProviderOptions) -> Self
Sets provider-specific options.
Sourcepub fn as_system(&self) -> Option<&SystemMessage>
pub fn as_system(&self) -> Option<&SystemMessage>
Returns the system message when this is one.
Sourcepub fn as_user(&self) -> Option<&UserMessage>
pub fn as_user(&self) -> Option<&UserMessage>
Returns the user message when this is one.
Sourcepub fn as_assistant(&self) -> Option<&AssistantMessage>
pub fn as_assistant(&self) -> Option<&AssistantMessage>
Returns the assistant message when this is one.
Sourcepub fn as_tool(&self) -> Option<&ToolMessage>
pub fn as_tool(&self) -> Option<&ToolMessage>
Returns the tool message when this is one.
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 From<AssistantMessage> for Message
impl From<AssistantMessage> for Message
Source§fn from(message: AssistantMessage) -> Self
fn from(message: AssistantMessage) -> Self
Converts to this type from the input type.
Source§impl From<SystemMessage> for Message
impl From<SystemMessage> for Message
Source§fn from(message: SystemMessage) -> Self
fn from(message: SystemMessage) -> Self
Converts to this type from the input type.
Source§impl From<ToolMessage> for Message
impl From<ToolMessage> for Message
Source§fn from(message: ToolMessage) -> Self
fn from(message: ToolMessage) -> Self
Converts to this type from the input type.
Source§impl From<UserMessage> for Message
impl From<UserMessage> for Message
Source§fn from(message: UserMessage) -> Self
fn from(message: UserMessage) -> Self
Converts to this type from the input type.
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