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 Freeze for TokenCount
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