pub enum ChatMessage {
System(SystemMessage),
User(UserMessage),
Assistant(AssistantMessage),
Tool(ToolMessage),
}Variants§
System(SystemMessage)
A message from a system.
User(UserMessage)
A message from a human.
Assistant(AssistantMessage)
A message from the assistant.
Tool(ToolMessage)
A message from a tool.
Implementations§
Source§impl ChatMessage
impl ChatMessage
pub fn role(&self) -> Role
pub fn content(&self) -> &str
pub fn system(content: impl Into<String>) -> Self
pub fn user(content: impl Into<String>) -> Self
pub fn assistant( content: impl Into<String>, tool_calls: impl Into<Vec<ToolCall>>, ) -> Self
pub fn tool(content: impl Into<String>, tool_call_id: impl Into<String>) -> Self
pub fn is_system(&self) -> bool
pub fn is_user(&self) -> bool
pub fn is_assistant(&self) -> bool
pub fn is_tool(&self) -> bool
pub fn as_system(&self) -> Option<&SystemMessage>
pub fn as_user(&self) -> Option<&UserMessage>
pub fn as_assistant(&self) -> Option<&AssistantMessage>
pub fn as_tool(&self) -> Option<&ToolMessage>
Trait Implementations§
Source§impl Clone for ChatMessage
impl Clone for ChatMessage
Source§fn clone(&self) -> ChatMessage
fn clone(&self) -> ChatMessage
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ChatMessage
impl Debug for ChatMessage
Source§impl EnumMessage for ChatMessage
impl EnumMessage for ChatMessage
fn get_message(&self) -> Option<&'static str>
fn get_detailed_message(&self) -> Option<&'static str>
Source§fn get_documentation(&self) -> Option<&'static str>
fn get_documentation(&self) -> Option<&'static str>
Get the doc comment associated with a variant if it exists.
fn get_serializations(&self) -> &'static [&'static str]
Source§impl Into<ChatMessage> for SystemMessage
impl Into<ChatMessage> for SystemMessage
Source§fn into(self) -> ChatMessage
fn into(self) -> ChatMessage
Converts this type into the (usually inferred) input type.
Source§impl Into<ChatMessage> for UserMessage
impl Into<ChatMessage> for UserMessage
Source§fn into(self) -> ChatMessage
fn into(self) -> ChatMessage
Converts this type into the (usually inferred) input type.
Source§impl Into<ChatMessage> for AssistantMessage
impl Into<ChatMessage> for AssistantMessage
Source§fn into(self) -> ChatMessage
fn into(self) -> ChatMessage
Converts this type into the (usually inferred) input type.
Source§impl Into<ChatMessage> for ToolMessage
impl Into<ChatMessage> for ToolMessage
Source§fn into(self) -> ChatMessage
fn into(self) -> ChatMessage
Converts this type into the (usually inferred) input type.
Source§impl Serialize for ChatMessage
impl Serialize for ChatMessage
Source§impl VariantNames for ChatMessage
impl VariantNames for ChatMessage
Auto Trait Implementations§
impl Freeze for ChatMessage
impl RefUnwindSafe for ChatMessage
impl Send for ChatMessage
impl Sync for ChatMessage
impl Unpin for ChatMessage
impl UnsafeUnpin for ChatMessage
impl UnwindSafe for ChatMessage
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