Struct llm_chain::tokens::TokenCount
source · pub struct TokenCount { /* private fields */ }
Expand description
Struct representing token count information, including the maximum tokens allowed and the total number of tokens used.
Implementations§
source§impl TokenCount
impl TokenCount
sourcepub fn new(max_tokens: i32, tokens_used: i32) -> Self
pub fn new(max_tokens: i32, tokens_used: i32) -> Self
Creates a new TokenCount
instance with the given maximum tokens and tokens used.
Arguments
max_tokens
- The maximum number of tokens allowed.tokens_used
- The total number of tokens used.
sourcepub fn tokens_remaining(&self) -> i32
pub fn tokens_remaining(&self) -> i32
Returns the number of tokens that could be added to the context window.
sourcepub fn has_tokens_remaining(&self) -> bool
pub fn has_tokens_remaining(&self) -> bool
Returns true if there is still room in the context window.
sourcepub fn has_room_for(&self, tokens: i32) -> bool
pub fn has_room_for(&self, tokens: i32) -> bool
Auto Trait Implementations§
impl RefUnwindSafe for TokenCount
impl Send for TokenCount
impl Sync for TokenCount
impl Unpin for TokenCount
impl UnwindSafe for TokenCount
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