pub struct Agent { /* private fields */ }Expand description
A loaded Laya checkpoint.
Implementations§
Source§impl Agent
impl Agent
Sourcepub fn builder() -> AgentBuilder
pub fn builder() -> AgentBuilder
Configure a load.
Sourcepub fn from_dir(model_dir: impl AsRef<Path>) -> Result<Self>
pub fn from_dir(model_dir: impl AsRef<Path>) -> Result<Self>
Load a checkpoint from a local directory with default settings.
pub fn model_dir(&self) -> &Path
pub fn config(&self) -> &AgentConfig
pub fn encoder_config(&self) -> &EncoderConfig
pub fn tokenizer(&self) -> &Tokenizer
pub fn device(&self) -> &Device
pub fn dtype(&self) -> DType
Sourcepub fn predict(&self, state: &Value, questions: &Value) -> Result<Prediction>
pub fn predict(&self, state: &Value, questions: &Value) -> Result<Prediction>
Answer every question about a state.
Sourcepub fn system_one(&self, state: &Value, questions: &Value) -> Result<Prediction>
pub fn system_one(&self, state: &Value, questions: &Value) -> Result<Prediction>
Alias for Agent::predict, matching upstream’s system_one.
Sourcepub fn predict_map(
&self,
state: &Value,
questions: &Map<String, Value>,
) -> Result<Prediction>
pub fn predict_map( &self, state: &Value, questions: &Map<String, Value>, ) -> Result<Prediction>
Answer every question, taking the question map directly.
Source§impl Agent
impl Agent
Sourcepub fn from_pretrained(model_id_or_path: &str) -> Result<Self>
pub fn from_pretrained(model_id_or_path: &str) -> Result<Self>
Load a checkpoint by Hub id or local path, with default settings.
Sourcepub fn from_pretrained_with(
model_id_or_path: &str,
subfolder: Option<&str>,
revision: Option<&str>,
options: AgentBuilder,
) -> Result<Self>
pub fn from_pretrained_with( model_id_or_path: &str, subfolder: Option<&str>, revision: Option<&str>, options: AgentBuilder, ) -> Result<Self>
Load a checkpoint, choosing a subfolder, revision and options.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Agent
impl !RefUnwindSafe for Agent
impl !UnwindSafe for Agent
impl Send for Agent
impl Sync for Agent
impl Unpin for Agent
impl UnsafeUnpin for Agent
Blanket Implementations§
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
Source§impl<T> DropFlavorWrapper<T> for T
impl<T> DropFlavorWrapper<T> for T
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> 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