Documentation Index
Fetch the complete documentation index at: https://docs.praison.ai/llms.txt
Use this file to discover all available pages before exploring further.
ContextLedger
Defined in the context module.
Rust AI Agent SDK
Tracks token usage across different context segments.
Fields
| Name | Type | Description |
|---|
segments | Vec<ContextSegment> | Segments in the ledger |
total_tokens | usize | Total tokens used |
max_tokens | usize | Maximum allowed tokens |
Methods
new
fn new(max_tokens: usize) -> Self
Create a new ledger with max tokens
Parameters:
add
fn add(&mut self, segment: ContextSegment) -> ()
Add a segment to the ledger
Parameters:
| Name | Type |
|---|
segment | ContextSegment |
remaining
fn remaining(&self) -> usize
Get remaining tokens
is_over_budget
fn is_over_budget(&self) -> bool
Check if over budget
utilization
fn utilization(&self) -> f64
Get utilization percentage
Source
View on GitHub
praisonai/src/context/mod.rs at line 95