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§
Sourcefn generate(&self, prompt: &str, config: &GenerationConfig) -> Result<String>
fn generate(&self, prompt: &str, config: &GenerationConfig) -> Result<String>
Generate text from a prompt
Sourcefn generate_batch(
&self,
prompts: &[&str],
config: &GenerationConfig,
) -> Result<Vec<String>>
fn generate_batch( &self, prompts: &[&str], config: &GenerationConfig, ) -> Result<Vec<String>>
Generate multiple completions
Sourcefn generate_stream(
&self,
prompt: &str,
config: &GenerationConfig,
) -> Result<Box<dyn Iterator<Item = Result<String>>>>
fn generate_stream( &self, prompt: &str, config: &GenerationConfig, ) -> Result<Box<dyn Iterator<Item = Result<String>>>>
Stream generation token by token
Sourcefn max_context_length(&self) -> usize
fn max_context_length(&self) -> usize
Get the maximum context length
Sourcefn supports_task(&self, task: &TaskType) -> bool
fn supports_task(&self, task: &TaskType) -> bool
Check if the model supports a specific task