pub struct SystemPrompt { /* private fields */ }Expand description
A structured system prompt with cache control breakpoints.
The system prompt is divided into a static prefix (stable across turns) and dynamic content. Cache control breakpoints mark positions where the provider should cache token computations.
Implementations§
Source§impl SystemPrompt
impl SystemPrompt
Sourcepub fn cache_control_breakpoints(&self) -> &[usize]
pub fn cache_control_breakpoints(&self) -> &[usize]
Returns the byte positions where cache control markers should be inserted.
Sourcepub fn to_anthropic_format(&self) -> Value
pub fn to_anthropic_format(&self) -> Value
Formats this system prompt for the Anthropic Messages API with
cache_control markers at the appropriate breakpoints.
The output follows the Anthropic format:
{
"system": [
{"type": "text", "text": "...", "cache_control": {"type": "ephemeral"}},
{"type": "text", "text": "..."}
]
}Each section between breakpoints becomes a separate content block.
The last block before each breakpoint gets a cache_control marker.
Trait Implementations§
Source§impl Clone for SystemPrompt
impl Clone for SystemPrompt
Source§fn clone(&self) -> SystemPrompt
fn clone(&self) -> SystemPrompt
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 moreAuto Trait Implementations§
impl Freeze for SystemPrompt
impl RefUnwindSafe for SystemPrompt
impl Send for SystemPrompt
impl Sync for SystemPrompt
impl Unpin for SystemPrompt
impl UnsafeUnpin for SystemPrompt
impl UnwindSafe for SystemPrompt
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