pub struct LocalEngine { /* private fields */ }Expand description
A model loaded in memory. Loading takes a while and generating blocks, so keep it away from the UI thread.
Implementations§
Source§impl LocalEngine
impl LocalEngine
Sourcepub fn load(
folder: &ModelFolder,
model: &LocalModel,
) -> Result<Self, EngineError>
pub fn load( folder: &ModelFolder, model: &LocalModel, ) -> Result<Self, EngineError>
Sourcepub fn generate(
&mut self,
system: &str,
user: &str,
max_tokens: usize,
on_text: &mut dyn FnMut(&str) -> bool,
) -> Result<Generated, EngineError>
pub fn generate( &mut self, system: &str, user: &str, max_tokens: usize, on_text: &mut dyn FnMut(&str) -> bool, ) -> Result<Generated, EngineError>
Answers user, following system, in at most max_tokens. on_text gets the
text as it comes, and returning false stops it.
§Errors
When it stops in the middle.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for LocalEngine
impl !RefUnwindSafe for LocalEngine
impl !UnwindSafe for LocalEngine
impl Send for LocalEngine
impl Sync for LocalEngine
impl Unpin for LocalEngine
impl UnsafeUnpin for LocalEngine
Blanket Implementations§
impl<T> AutoreleaseSafe for Twhere
T: ?Sized,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more