NlpEngine
Defined in: engine/engine.instance.ts:30
The cheap first pass: matches a phrase against the intents providers declared, so a request that is plainly “turn off the kitchen light” never has to reach a model.
Takes plain arrays rather than a ProviderRegistry so it can be exercised
without standing up providers; the host does the flattening.
The corpus is trained from live slot values and rebuilt whenever a slot says they changed, which is the whole reason slots are objects: adding a room retrains the engine instead of requiring an edit to a static entity list.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new NlpEngine(options): NlpEngine;Defined in: engine/engine.instance.ts:45
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
options |
NlpEngineOptions |
Returns
Section titled “Returns”NlpEngine
Methods
Section titled “Methods”[destroy]()
Section titled “[destroy]()”destroy: void;Defined in: engine/engine.instance.ts:158
Returns
Section titled “Returns”void
classify()
Section titled “classify()”classify(text, options?): Promise<NlpMatch | undefined>;Defined in: engine/engine.instance.ts:73
Matches text against the trained intents, or answers undefined if
nothing did.
A rebuild in progress does not block: the previous model keeps answering until the new one finishes. Slot values going momentarily stale is a far smaller cost than the first pass stalling every request behind a retrain.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
text |
string |
options |
NlpClassifyOptions |
Returns
Section titled “Returns”Promise<NlpMatch | undefined>
execute()
Section titled “execute()”execute(__namedParameters): Promise<void>;Defined in: engine/engine.instance.ts:88
Runs a match’s intent, exactly as NlpEngine.classify handed it back.
Whether the match was strong enough is not asked again here: classify
answers with the score alongside the intent precisely so that judgement is
made once, by the caller, before it gets this far.
Throws NlpIntentNotFoundError if the id names nothing — expected when a match is held across a restart, since intent ids are minted per process.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
__namedParameters |
NlpExecuteOptions |
Returns
Section titled “Returns”Promise<void>
train()
Section titled “train()”train(): Promise<void>;Defined in: engine/engine.instance.ts:60
Trains the corpus and begins watching slots for changes.
Safe to skip — NlpEngine.classify trains on first use — but calling it at boot moves the cost off the first request.
Returns
Section titled “Returns”Promise<void>