pub struct SystemPrompt { /* private fields */ }Expand description
Ordered sequence of SystemBlocks. An empty SystemPrompt
represents “no system prompt” — codecs treat it as if the field
were absent.
Storage is Arc<[SystemBlock]> so cloning a SystemPrompt
(and the crate::ir::ModelRequest that holds it) is an atomic
refcount bump. The hot-path cost of stamping the same prompt on
every model call is O(1) regardless of block count or block
length.
Implementations§
Source§impl SystemPrompt
impl SystemPrompt
Sourcepub fn empty() -> Self
pub fn empty() -> Self
Empty prompt — semantically equivalent to “no system prompt configured.”
Sourcepub fn cached(text: impl Into<String>, cache: CacheControl) -> Self
pub fn cached(text: impl Into<String>, cache: CacheControl) -> Self
Single-block prompt with the supplied cache directive.
Sourcepub fn blocks(&self) -> &[SystemBlock]
pub fn blocks(&self) -> &[SystemBlock]
Borrow the blocks in order.
Sourcepub fn any_cached(&self) -> bool
pub fn any_cached(&self) -> bool
Whether any block carries a cache directive — used by codecs
without native cache support to decide whether to emit a
LossyEncode warning.
Sourcepub fn map_blocks<F>(&self, f: F) -> Selfwhere
F: FnMut(&mut SystemBlock),
pub fn map_blocks<F>(&self, f: F) -> Selfwhere
F: FnMut(&mut SystemBlock),
Map every block through f, returning a fresh prompt whose
shared storage is rebuilt from the transformed sequence. The
canonical PII-redaction surface — redactors clone each
block, scrub the text in place, and assemble a fresh
Arc<[SystemBlock]> once. The original Arc is never
mutated; callers retaining a clone of the source prompt see
it untouched.
(Arc::try_unwrap fast-pathing the sole-owner case isn’t
available because Rust’s stdlib does not implement
try_unwrap for Arc<[T]> — slice DSTs aren’t Sized.)
Sourcepub fn concat_text(&self) -> String
pub fn concat_text(&self) -> String
Concatenate every block’s text with \n\n separators —
the canonical “flatten to single string” rendering codecs
without per-block channels rely on.
Trait Implementations§
Source§impl Clone for SystemPrompt
impl Clone for SystemPrompt
Source§fn clone(&self) -> SystemPrompt
fn clone(&self) -> SystemPrompt
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SystemPrompt
impl Debug for SystemPrompt
Source§impl Default for SystemPrompt
impl Default for SystemPrompt
Source§impl<'de> Deserialize<'de> for SystemPrompt
impl<'de> Deserialize<'de> for SystemPrompt
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<&str> for SystemPrompt
impl From<&str> for SystemPrompt
Source§impl From<String> for SystemPrompt
impl From<String> for SystemPrompt
Source§impl From<SystemBlock> for SystemPrompt
impl From<SystemBlock> for SystemPrompt
Source§fn from(block: SystemBlock) -> Self
fn from(block: SystemBlock) -> Self
Source§impl From<Vec<SystemBlock>> for SystemPrompt
impl From<Vec<SystemBlock>> for SystemPrompt
Source§fn from(blocks: Vec<SystemBlock>) -> Self
fn from(blocks: Vec<SystemBlock>) -> Self
Source§impl PartialEq for SystemPrompt
impl PartialEq for SystemPrompt
Source§fn eq(&self, other: &SystemPrompt) -> bool
fn eq(&self, other: &SystemPrompt) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for SystemPrompt
impl Serialize for SystemPrompt
impl Eq for SystemPrompt
impl StructuralPartialEq for SystemPrompt
Auto 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
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.