Skip to main content

TextGenerator

Trait TextGenerator 

Source
pub trait TextGenerator: Generator {
    // Required methods
    fn add_message(&mut self, message: Message) -> Result<()>;
    fn reset(&mut self) -> Result<()>;
    fn goodbye<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn next_token<'life0, 'async_trait>(
        &'life0 mut self,
        index: usize,
    ) -> Pin<Box<dyn Future<Output = Result<Token>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn generated_tokens(&self) -> usize;
}

Required Methods§

Source

fn add_message(&mut self, message: Message) -> Result<()>

Add a message to the chat.

Source

fn reset(&mut self) -> Result<()>

Clear chat history.

Source

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

clear worker kv cache

Source

fn next_token<'life0, 'async_trait>( &'life0 mut self, index: usize, ) -> Pin<Box<dyn Future<Output = Result<Token>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Return the next token.

Source

fn generated_tokens(&self) -> usize

Return the number of generated tokens so far.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§