pub struct Engine { /* private fields */ }Expand description
A compiled decision engine. WASM is single-threaded, so the core engine is
held directly (no Arc/lock); trainJson takes &mut self.
Implementations§
Source§impl Engine
impl Engine
Sourcepub fn new(options_json: &str) -> Result<Engine, JsValue>
pub fn new(options_json: &str) -> Result<Engine, JsValue>
optionsJson: {"embedder":"hash","dims":256}. The onnx arm
({"embedder":{"kind":"onnx",...}}) needs model bytes, so it is rejected
here — use Engine.fromBytes instead.
Sourcepub fn from_bytes(
options_json: &str,
model_bytes: &[u8],
tokenizer_bytes: &[u8],
) -> Result<Engine, JsValue>
pub fn from_bytes( options_json: &str, model_bytes: &[u8], tokenizer_bytes: &[u8], ) -> Result<Engine, JsValue>
Construct an onnx-backed engine (tract) from in-memory model + tokenizer
bytes. optionsJson carries the model manifest (a JSON string or an
inline object). Requires the wasm-onnx build feature; otherwise returns
the documented embedder error JSON as the thrown value. Throws on a hash
mismatch or a model tract cannot load (fail closed, ADR-005).
Sourcepub fn decide_json(&self, request_json: &str) -> String
pub fn decide_json(&self, request_json: &str) -> String
Returns a DecisionResponse JSON, or the documented error JSON.
Sourcepub fn train_json(&mut self, train_json: &str) -> String
pub fn train_json(&mut self, train_json: &str) -> String
Returns a TrainReport JSON, or the documented error JSON.
Sourcepub fn stats_json(&self) -> String
pub fn stats_json(&self) -> String
{"embedderId","dims","examples","promotable"} from the bank summary.
Sourcepub fn optimize_json(&self, campaign_json: &str) -> String
pub fn optimize_json(&self, campaign_json: &str) -> String
Run an optimize campaign (ADR-004). campaignJson is a CampaignSpec;
returns a CampaignReport JSON or the documented error JSON.
Sourcepub fn export_bank_json(&self) -> String
pub fn export_bank_json(&self) -> String
Full-fidelity bank JSON (the user’s own examples), or the error JSON.
Sourcepub fn import_bank_json(&mut self, bank_json: &str) -> String
pub fn import_bank_json(&mut self, bank_json: &str) -> String
Replace the bank from JSON (re-embeds every stored text). Returns
{"ok":true} or the documented error JSON.
Trait Implementations§
Source§impl FromWasmAbi for Engine
impl FromWasmAbi for Engine
Source§impl IntoWasmAbi for Engine
impl IntoWasmAbi for Engine
Source§impl LongRefFromWasmAbi for Engine
impl LongRefFromWasmAbi for Engine
Source§impl OptionFromWasmAbi for Engine
impl OptionFromWasmAbi for Engine
Source§impl OptionIntoWasmAbi for Engine
impl OptionIntoWasmAbi for Engine
Source§impl RefFromWasmAbi for Engine
impl RefFromWasmAbi for Engine
Source§type Abi = WasmPtr<WasmRefCell<Engine>>
type Abi = WasmPtr<WasmRefCell<Engine>>
Self are recovered from.Source§impl RefMutFromWasmAbi for Engine
impl RefMutFromWasmAbi for Engine
impl SupportsConstructor for Engine
impl SupportsInstanceProperty for Engine
impl SupportsStaticProperty for Engine
Source§impl TryFromJsValue for Engine
impl TryFromJsValue for Engine
Source§impl VectorFromWasmAbi for Engine
impl VectorFromWasmAbi for Engine
Source§impl VectorIntoWasmAbi for Engine
impl VectorIntoWasmAbi for Engine
Auto Trait Implementations§
impl !Freeze for Engine
impl !RefUnwindSafe for Engine
impl !UnwindSafe for Engine
impl Send for Engine
impl Sync for Engine
impl Unpin for Engine
impl UnsafeUnpin for Engine
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
Source§impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
Source§type Abi = <T as IntoWasmAbi>::Abi
type Abi = <T as IntoWasmAbi>::Abi
IntoWasmAbi::AbiSource§fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
IntoWasmAbi::into_abi, except that it may throw and never
return in the case of Err.