Trait kalosm_language_model::SyncModelExt
source · pub trait SyncModelExt: SyncModel {
// Provided methods
fn generate_structured<P: Parser>(
&self,
session: &mut Self::Session,
prompt: impl Display,
parser: P,
parser_state: P::PartialState,
sampler: Arc<Mutex<dyn Sampler>>,
on_token: impl FnMut(String) -> Result<()>
) -> Result<P::Output>
where P::Output: Clone { ... }
fn stream_text_with_sampler(
&self,
session: &mut Self::Session,
prompt: &str,
max_tokens: Option<u32>,
stop_on: Option<&str>,
sampler: Arc<Mutex<dyn Sampler>>,
on_token: impl FnMut(String) -> Result<ModelFeedback>
) -> Result<()> { ... }
}
Expand description
An extension trait for sync models.
Provided Methods§
sourcefn generate_structured<P: Parser>(
&self,
session: &mut Self::Session,
prompt: impl Display,
parser: P,
parser_state: P::PartialState,
sampler: Arc<Mutex<dyn Sampler>>,
on_token: impl FnMut(String) -> Result<()>
) -> Result<P::Output>
fn generate_structured<P: Parser>( &self, session: &mut Self::Session, prompt: impl Display, parser: P, parser_state: P::PartialState, sampler: Arc<Mutex<dyn Sampler>>, on_token: impl FnMut(String) -> Result<()> ) -> Result<P::Output>
Generate new text with the given prompt that conforms to the given parser.
sourcefn stream_text_with_sampler(
&self,
session: &mut Self::Session,
prompt: &str,
max_tokens: Option<u32>,
stop_on: Option<&str>,
sampler: Arc<Mutex<dyn Sampler>>,
on_token: impl FnMut(String) -> Result<ModelFeedback>
) -> Result<()>
fn stream_text_with_sampler( &self, session: &mut Self::Session, prompt: &str, max_tokens: Option<u32>, stop_on: Option<&str>, sampler: Arc<Mutex<dyn Sampler>>, on_token: impl FnMut(String) -> Result<ModelFeedback> ) -> Result<()>
Stream text, calling the on_token callback every time a new token is generated. For some models, this could be used to implement Model::stream_text_with_sampler
.
Object Safety§
This trait is not object safe.