pub struct ContextManager { /* private fields */ }Expand description
Context Management Infrastructure
Provides APIs for external orchestration layers to manage context windows.
Implementations§
Source§impl ContextManager
impl ContextManager
Sourcepub fn new(id: impl Into<String>) -> Self
pub fn new(id: impl Into<String>) -> Self
Create a new context manager with default constraints
Sourcepub fn with_constraints(
id: impl Into<String>,
constraints: ContextConstraints,
) -> Self
pub fn with_constraints( id: impl Into<String>, constraints: ContextConstraints, ) -> Self
Create a context manager with custom constraints
Sourcepub fn with_expansion_policy(self, policy: ExpansionPolicy) -> Self
pub fn with_expansion_policy(self, policy: ExpansionPolicy) -> Self
Set the expansion policy
Sourcepub fn with_pruning_policy(self, policy: PruningPolicy) -> Self
pub fn with_pruning_policy(self, policy: PruningPolicy) -> Self
Set the pruning policy
Sourcepub fn window(&self) -> &ContextWindow
pub fn window(&self) -> &ContextWindow
Get a reference to the context window
Sourcepub fn initialize_focus(
&mut self,
doc: &Document,
focus_id: BlockId,
task_description: &str,
) -> ContextUpdateResult
pub fn initialize_focus( &mut self, doc: &Document, focus_id: BlockId, task_description: &str, ) -> ContextUpdateResult
Initialize context with a focus block
Navigate to a new focus area
Sourcepub fn add_block(
&mut self,
doc: &Document,
block_id: BlockId,
reason: InclusionReason,
) -> ContextUpdateResult
pub fn add_block( &mut self, doc: &Document, block_id: BlockId, reason: InclusionReason, ) -> ContextUpdateResult
Add a block to the context
Sourcepub fn remove_block(&mut self, block_id: BlockId) -> ContextUpdateResult
pub fn remove_block(&mut self, block_id: BlockId) -> ContextUpdateResult
Remove a block from the context
Sourcepub fn expand_context(
&mut self,
doc: &Document,
direction: ExpandDirection,
depth: usize,
) -> ContextUpdateResult
pub fn expand_context( &mut self, doc: &Document, direction: ExpandDirection, depth: usize, ) -> ContextUpdateResult
Expand context in a direction
Sourcepub fn compress(
&mut self,
doc: &Document,
method: CompressionMethod,
) -> ContextUpdateResult
pub fn compress( &mut self, doc: &Document, method: CompressionMethod, ) -> ContextUpdateResult
Compress blocks to fit within constraints
Sourcepub fn get_statistics(&self) -> ContextStatistics
pub fn get_statistics(&self) -> ContextStatistics
Get statistics about the context
Sourcepub fn render_for_prompt(&self, doc: &Document) -> String
pub fn render_for_prompt(&self, doc: &Document) -> String
Render context to a format suitable for LLM prompts
Auto Trait Implementations§
impl Freeze for ContextManager
impl RefUnwindSafe for ContextManager
impl Send for ContextManager
impl Sync for ContextManager
impl Unpin for ContextManager
impl UnsafeUnpin for ContextManager
impl UnwindSafe for ContextManager
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