#[non_exhaustive]pub enum Message {
User {
blocks: Vec<UserBlock>,
},
Assistant {
blocks: Vec<AssistantBlock>,
},
}Expand description
One turn in the conversation history exchanged with a provider.
Message is the wire shape: every provider adapter maps this enum
to its own block model (Anthropic Messages, OpenAI Chat
Completions, etc.). Only the user and assistant roles live here —
system instructions are passed separately through
crate::ChatRequest::system_prompt because most providers
represent them out-of-band.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
User
A user-authored turn: free text, tool results from the previous step, or a mix.
Fields
Assistant
A turn produced by the model: visible text, tool calls,
reasoning. Tool results are in the next User turn.
Fields
blocks: Vec<AssistantBlock>Blocks rendered in order. Ordering is provider-significant for reasoning + tool-use chains (Anthropic extended thinking).
Implementations§
Source§impl Message
impl Message
Sourcepub fn user(text: impl Into<String>) -> Message
pub fn user(text: impl Into<String>) -> Message
Shorthand for a user turn containing a single text block.
Sourcepub fn assistant_text(text: impl Into<String>) -> Message
pub fn assistant_text(text: impl Into<String>) -> Message
Shorthand for an assistant turn containing a single text block.
Use the Message::Assistant variant directly when seeding
history with tool calls or reasoning.