pub enum MessageRole {
System,
User,
Assistant,
Tool,
}Expand description
Identifies the sender/role of a message in the conversation.
This enum follows the standard chat completion role system used by most LLM APIs. The role determines how the message is interpreted and processed.
§Serialization
Serializes to lowercase strings via serde ("system", "user", etc.)
to match OpenAI API format.
§Role Semantics
Variants§
System
System message that establishes agent behavior and context.
Typically the first message in a conversation. Used for instructions, personality definition, and constraints that apply throughout the conversation.
User
User message representing human or application input.
The prompt or query that the agent should respond to. In multi-turn conversations, user messages alternate with assistant messages.
Assistant
Assistant message containing the AI model’s response.
Can include text, tool use requests, or both. When the model wants to call a tool, it includes ToolUseBlock content.
Tool
Tool result message containing function execution results.
Sent back to the model after executing a requested tool. Contains the tool’s output that the model can use in its next response.
Trait Implementations§
Source§impl Clone for MessageRole
impl Clone for MessageRole
Source§fn clone(&self) -> MessageRole
fn clone(&self) -> MessageRole
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MessageRole
impl Debug for MessageRole
Source§impl<'de> Deserialize<'de> for MessageRole
impl<'de> Deserialize<'de> for MessageRole
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 PartialEq for MessageRole
impl PartialEq for MessageRole
Source§impl Serialize for MessageRole
impl Serialize for MessageRole
impl Eq for MessageRole
impl StructuralPartialEq for MessageRole
Auto Trait Implementations§
impl Freeze for MessageRole
impl RefUnwindSafe for MessageRole
impl Send for MessageRole
impl Sync for MessageRole
impl Unpin for MessageRole
impl UnwindSafe for MessageRole
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.