pub enum Message {
System {
content: String,
},
User {
content: OneOrMany<UserContent>,
},
Assistant {
id: Option<String>,
content: OneOrMany<AssistantContent>,
},
}Expand description
A provider-agnostic chat message.
Messages are role-tagged and may contain one or many content items, including text, images, audio, documents, tool calls, and tool results. Provider modules are responsible for translating these generic messages into provider-native request bodies. That conversion may be lossy when a provider does not support a particular content type.
Variants§
System
System message containing instruction text.
User
User message containing one or more content types defined by UserContent.
Fields
content: OneOrMany<UserContent>Assistant
Assistant message containing one or more content types defined by AssistantContent.
Implementations§
Source§impl Message
impl Message
Sourcepub fn system(text: impl Into<String>) -> Self
pub fn system(text: impl Into<String>) -> Self
Helper constructor to make creating system messages easier.
Sourcepub fn user(text: impl Into<String>) -> Self
pub fn user(text: impl Into<String>) -> Self
Helper constructor to make creating user messages easier.
Sourcepub fn assistant(text: impl Into<String>) -> Self
pub fn assistant(text: impl Into<String>) -> Self
Helper constructor to make creating assistant messages easier.
Sourcepub fn assistant_with_id(id: String, text: impl Into<String>) -> Self
pub fn assistant_with_id(id: String, text: impl Into<String>) -> Self
Helper constructor to make creating assistant messages easier.
Sourcepub fn tool_result(id: impl Into<String>, content: impl Into<String>) -> Self
pub fn tool_result(id: impl Into<String>, content: impl Into<String>) -> Self
Helper constructor to make creating tool result messages easier.
pub fn tool_result_with_call_id( id: impl Into<String>, call_id: Option<String>, content: impl Into<String>, ) -> Self
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>,
Source§impl From<AssistantContent> for Message
impl From<AssistantContent> for Message
Source§fn from(content: AssistantContent) -> Self
fn from(content: AssistantContent) -> Self
Source§impl From<Message> for Message
Conversion from provider Message to a completion message.
This is needed so that responses can be converted back into chat history.
impl From<Message> for Message
Conversion from provider Message to a completion message. This is needed so that responses can be converted back into chat history.
Source§impl From<OneOrMany<AssistantContent>> for Message
impl From<OneOrMany<AssistantContent>> for Message
Source§fn from(content: OneOrMany<AssistantContent>) -> Self
fn from(content: OneOrMany<AssistantContent>) -> Self
Source§impl From<OneOrMany<UserContent>> for Message
impl From<OneOrMany<UserContent>> for Message
Source§fn from(content: OneOrMany<UserContent>) -> Self
fn from(content: OneOrMany<UserContent>) -> Self
Source§impl From<ToolResult> for Message
impl From<ToolResult> for Message
Source§fn from(tool_result: ToolResult) -> Self
fn from(tool_result: ToolResult) -> Self
Source§impl From<ToolResultContent> for Message
impl From<ToolResultContent> for Message
Source§fn from(tool_result_content: ToolResultContent) -> Self
fn from(tool_result_content: ToolResultContent) -> Self
Source§impl From<UserContent> for Message
impl From<UserContent> for Message
Source§fn from(content: UserContent) -> Self
fn from(content: UserContent) -> Self
Source§impl TryFrom<Message> for Vec<Message>
§Provider Message Conversions
Conversion from an internal Rig message (crate::message::Message) to a provider Message.
(Only User and Assistant variants are supported.)
impl TryFrom<Message> for Vec<Message>
§Provider Message Conversions
Conversion from an internal Rig message (crate::message::Message) to a provider Message. (Only User and Assistant variants are supported.)
Source§impl TryFrom<Message> for Vec<Message>
impl TryFrom<Message> for Vec<Message>
Source§type Error = CompletionError
type Error = CompletionError
Source§impl TryFrom<RawMessage> for Message
impl TryFrom<RawMessage> for Message
Source§type Error = CompletionError
type Error = CompletionError
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
Source§impl<T> CloneDebuggableStorage for Twhere
T: DebuggableStorage + Clone,
impl<T> CloneDebuggableStorage for Twhere
T: DebuggableStorage + Clone,
fn clone_storage(&self) -> Box<dyn CloneDebuggableStorage>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> CloneableStorage for T
impl<T> CloneableStorage for T
fn clone_storage(&self) -> Box<dyn CloneableStorage>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more