pub struct ContextBuilder { /* private fields */ }Expand description
Builds a system prompt from named, ordered sections.
Implementations§
Source§impl ContextBuilder
impl ContextBuilder
pub fn new() -> Self
Sourcepub fn separator(self, sep: impl Into<String>) -> Self
pub fn separator(self, sep: impl Into<String>) -> Self
Set the separator between sections (default: double newline).
Sourcepub fn section(
self,
name: impl Into<String>,
content: impl Into<String>,
) -> Self
pub fn section( self, name: impl Into<String>, content: impl Into<String>, ) -> Self
Add a named section. If a section with this name exists, replace it.
Sourcepub fn section_with_priority(
self,
name: impl Into<String>,
content: impl Into<String>,
priority: i32,
) -> Self
pub fn section_with_priority( self, name: impl Into<String>, content: impl Into<String>, priority: i32, ) -> Self
Add a section with explicit priority (higher = earlier in output).
Sourcepub fn disable(self, name: &str) -> Self
pub fn disable(self, name: &str) -> Self
Disable a section by name (it will be omitted from build output).
Sourcepub fn section_names(&self) -> Vec<&str>
pub fn section_names(&self) -> Vec<&str>
Names of all sections (in render order, enabled and disabled).
Sourcepub fn enabled_count(&self) -> usize
pub fn enabled_count(&self) -> usize
Count of enabled sections.
Sourcepub fn build(&self) -> String
pub fn build(&self) -> String
Render the prompt: enabled sections sorted by priority desc, then insertion order.
Sourcepub fn duplicate_names(&self) -> Vec<String>
pub fn duplicate_names(&self) -> Vec<String>
All duplicate section names (should be empty in normal use).
Trait Implementations§
Source§impl Debug for ContextBuilder
impl Debug for ContextBuilder
Source§impl Default for ContextBuilder
impl Default for ContextBuilder
Source§fn default() -> ContextBuilder
fn default() -> ContextBuilder
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ContextBuilder
impl RefUnwindSafe for ContextBuilder
impl Send for ContextBuilder
impl Sync for ContextBuilder
impl Unpin for ContextBuilder
impl UnsafeUnpin for ContextBuilder
impl UnwindSafe for ContextBuilder
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