pub struct ContextBuilder { /* private fields */ }Expand description
Declarative state-to-narrative renderer.
Renders session state into a natural-language summary for the model’s instruction. Sections group related keys; missing values are auto-skipped.
When the current phase has needs metadata (set via .needs() on the
phase builder), appends a “Gathering:” line for keys that are still missing,
so the model knows what to focus on in the current phase.
Use directly with with_context() on phase defaults or individual phases.
§Example
ⓘ
.phase_defaults(|d| d.with_context(
ContextBuilder::new()
.section("Caller")
.field("name", "Name")
.build()
))Implementations§
Source§impl ContextBuilder
impl ContextBuilder
Sourcepub fn new() -> SectionBuilder
pub fn new() -> SectionBuilder
Start building a new context with the first section.
Sourcepub fn render(&self, state: &State) -> String
pub fn render(&self, state: &State) -> String
Render the context from the given state.
Returns an empty string when no state has been gathered (no noise).
Sourcepub fn into_modifier(self) -> InstructionModifier
pub fn into_modifier(self) -> InstructionModifier
Convert into an super::InstructionModifier for use with phase modifiers.
Trait Implementations§
Source§impl Add for ContextBuilder
impl Add for ContextBuilder
Source§type Output = ContextBuilder
type Output = ContextBuilder
The resulting type after applying the
+ operator.Source§impl Clone for ContextBuilder
impl Clone for ContextBuilder
Source§fn clone(&self) -> ContextBuilder
fn clone(&self) -> ContextBuilder
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§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 !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