pub trait TextGeneratorTrait {
    // Required methods
    fn init(&mut self, prompt: String) -> Result<()>;
    fn next(&mut self) -> Result<TextGeneratorResult>;
}
Expand description

A trait defining the core functionality for text generation.

This trait encapsulates the necessary methods for initializing the generation process with a prompt and then producing text iteratively.

Required Methods§

source

fn init(&mut self, prompt: String) -> Result<()>

Initializes the text generation process with a given prompt.

This method sets up the necessary state for text generation based on the provided prompt.

Arguments
  • prompt - A String that serves as the starting point for text generation.
Returns

A Result indicating success or failure of the initialization process.

source

fn next(&mut self) -> Result<TextGeneratorResult>

Generates the next piece of text in the sequence.

This method should be called iteratively to generate text progressively. It provides the next piece of text based on the current state of the generator.

Returns

A Result wrapping a TextGeneratorResult, which can be either a generated token or an indication that the generation process has finished.

Implementors§