Trait Estimatable

Source
pub trait Estimatable: Send + Sync {
    // Required method
    fn for_estimate<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Cow<'_, str>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided method
    fn additional_tokens(&self) -> usize { ... }
}
Expand description

A value that can be estimated for the number of tokens it contains.

Required Methods§

Source

fn for_estimate<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Cow<'_, str>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Provided Methods§

Source

fn additional_tokens(&self) -> usize

Optionally return extra tokens that should be added to the estimate.

Implementations on Foreign Types§

Source§

impl Estimatable for &str

Source§

fn for_estimate<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Cow<'_, str>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

impl Estimatable for &[ChatMessage]

Source§

fn for_estimate<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Cow<'_, str>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn additional_tokens(&self) -> usize

Source§

impl Estimatable for String

Source§

fn for_estimate<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Cow<'_, str>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Implementors§