Struct ContextBuilder
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§
§impl ContextBuilder
impl ContextBuilder
pub fn new() -> SectionBuilder
pub fn new() -> SectionBuilder
Start building a new context with the first section.
pub 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).
pub fn into_modifier(self) -> InstructionModifier
pub fn into_modifier(self) -> InstructionModifier
Convert into an [super::InstructionModifier] for use with phase modifiers.
Trait Implementations§
§impl Add for ContextBuilder
impl Add for ContextBuilder
§type Output = ContextBuilder
type Output = ContextBuilder
The resulting type after applying the
+ operator.§fn add(self, rhs: ContextBuilder) -> <ContextBuilder as Add>::Output
fn add(self, rhs: ContextBuilder) -> <ContextBuilder as Add>::Output
Performs the
+ operation. Read more§impl Clone for ContextBuilder
impl Clone for ContextBuilder
§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 more§impl Default for ContextBuilder
impl Default for ContextBuilder
§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