Skip to content

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.

new NlpEngine(options): NlpEngine;

Defined in: engine/engine.instance.ts:45

Parameter Type
options NlpEngineOptions

NlpEngine

destroy: void;

Defined in: engine/engine.instance.ts:158

void


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.

Parameter Type
text string
options NlpClassifyOptions

Promise<NlpMatch | undefined>


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.

Parameter Type
__namedParameters NlpExecuteOptions

Promise<void>


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.

Promise<void>