Skip to main content

GenerativeModel

Trait GenerativeModel 

Source
pub trait GenerativeModel {
    // Required methods
    fn generate(
        &self,
        prompt: &str,
        config: &GenerationConfig,
    ) -> Result<String>;
    fn generate_batch(
        &self,
        prompts: &[&str],
        config: &GenerationConfig,
    ) -> Result<Vec<String>>;
    fn generate_stream(
        &self,
        prompt: &str,
        config: &GenerationConfig,
    ) -> Result<Box<dyn Iterator<Item = Result<String>>>>;
    fn max_context_length(&self) -> usize;
    fn config(&self) -> &dyn DynConfig;
    fn supports_task(&self, task: &TaskType) -> bool;
}
Expand description

Common generative model interface

Required Methods§

Source

fn generate(&self, prompt: &str, config: &GenerationConfig) -> Result<String>

Generate text from a prompt

Source

fn generate_batch( &self, prompts: &[&str], config: &GenerationConfig, ) -> Result<Vec<String>>

Generate multiple completions

Source

fn generate_stream( &self, prompt: &str, config: &GenerationConfig, ) -> Result<Box<dyn Iterator<Item = Result<String>>>>

Stream generation token by token

Source

fn max_context_length(&self) -> usize

Get the maximum context length

Source

fn config(&self) -> &dyn DynConfig

Get the model configuration

Source

fn supports_task(&self, task: &TaskType) -> bool

Check if the model supports a specific task

Implementors§