pub struct ContextWindow {
pub id: String,
pub blocks: HashMap<BlockId, ContextBlock>,
pub relationships: Vec<ContextRelation>,
pub metadata: ContextMetadata,
pub constraints: ContextConstraints,
}Expand description
Context window with intelligent management
Fields§
§id: String§blocks: HashMap<BlockId, ContextBlock>§relationships: Vec<ContextRelation>§metadata: ContextMetadata§constraints: ContextConstraintsImplementations§
Source§impl ContextWindow
impl ContextWindow
Sourcepub fn new(id: impl Into<String>, constraints: ContextConstraints) -> Self
pub fn new(id: impl Into<String>, constraints: ContextConstraints) -> Self
Create a new empty context window
Sourcepub fn block_count(&self) -> usize
pub fn block_count(&self) -> usize
Get the number of blocks in the context
Sourcepub fn total_tokens(&self) -> usize
pub fn total_tokens(&self) -> usize
Get estimated total tokens
Sourcepub fn has_capacity(&self) -> bool
pub fn has_capacity(&self) -> bool
Check if context has room for more blocks
Sourcepub fn get(&self, block_id: &BlockId) -> Option<&ContextBlock>
pub fn get(&self, block_id: &BlockId) -> Option<&ContextBlock>
Get a block from the context
Trait Implementations§
Source§impl Clone for ContextWindow
impl Clone for ContextWindow
Source§fn clone(&self) -> ContextWindow
fn clone(&self) -> ContextWindow
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 Debug for ContextWindow
impl Debug for ContextWindow
Source§impl<'de> Deserialize<'de> for ContextWindow
impl<'de> Deserialize<'de> for ContextWindow
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>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for ContextWindow
impl RefUnwindSafe for ContextWindow
impl Send for ContextWindow
impl Sync for ContextWindow
impl Unpin for ContextWindow
impl UnsafeUnpin for ContextWindow
impl UnwindSafe for ContextWindow
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