#[non_exhaustive]pub enum MessageCategory {
SystemInstruction,
ToolDefinition,
Context,
History,
Current,
ToolResult,
}Expand description
Semantic category of a message for provider-specific handling.
Categories help providers optimize message processing, especially for caching. Messages with different categories may be grouped, cached, or prioritized differently.
§Priority Defaults
When using semantic constructors like UnifiedMessage::system_instruction(),
categories automatically set appropriate priority values:
| Category | Default Priority | Cacheable |
|---|---|---|
| SystemInstruction | 0 (highest) | Yes |
| ToolDefinition | 1 | Yes |
| Context | 5 | Yes |
| History | 20 | Yes |
| ToolResult | 26 | No |
| Current | 30 (lowest) | No |
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
SystemInstruction
Core system prompts and instructions.
These are the foundational instructions that define the model’s behavior. They’re almost always cached since they rarely change within a session.
ToolDefinition
Tool/function definitions.
Contains the schema definitions for available tools. Typically cached since tool definitions are static for a given application.
Context
Contextual information (user preferences, session state, etc.).
Background context that informs responses but isn’t part of the direct conversation. Often cached for the session duration.
History
Conversation history (previous turns).
Past messages in the conversation. May be partially cached for long conversations to save on repeated processing.
Current
Current user input (the active turn).
The message being responded to right now. Never cached since it changes with each request.
ToolResult
Results from tool executions.
Output from function calls. Not cached since tool results are dynamic and request-specific.
Trait Implementations§
Source§impl Clone for MessageCategory
impl Clone for MessageCategory
Source§fn clone(&self) -> MessageCategory
fn clone(&self) -> MessageCategory
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MessageCategory
impl Debug for MessageCategory
Source§impl<'de> Deserialize<'de> for MessageCategory
impl<'de> Deserialize<'de> for MessageCategory
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 Hash for MessageCategory
impl Hash for MessageCategory
Source§impl PartialEq for MessageCategory
impl PartialEq for MessageCategory
Source§impl Serialize for MessageCategory
impl Serialize for MessageCategory
impl Eq for MessageCategory
impl StructuralPartialEq for MessageCategory
Auto Trait Implementations§
impl Freeze for MessageCategory
impl RefUnwindSafe for MessageCategory
impl Send for MessageCategory
impl Sync for MessageCategory
impl Unpin for MessageCategory
impl UnwindSafe for MessageCategory
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§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.