Skip to content

Slot

Defined in: core/src/nlp/utterance/utterance.slot.ts:47

A fillable position in an Utterance — the thing {room} would have been in a string-templated NLP engine.

The design difference is that a slot is an object, not a name, and that settles two problems a shared namespace has. Nothing has to own the identifier room, because identity is the object reference and the id below is a guid with no meaning outside the engine; two providers can each hold a slot they both think of as “room” without colliding. And a slot knows how to fetch its own values and when they went stale, so adding a room is a markUpdated away from a retrain rather than an edit to a static entity list.

Extend this when a provider has a bespoke source; reach for slot when a function is enough.

Type Parameter Default type
T unknown
new Slot<T>(): Slot<T>;

Slot<T>

EventEmitter.constructor

abstract getValues: (context) => Promise<SlotValue<T>[]>;

Defined in: core/src/nlp/utterance/utterance.slot.ts:59

Every value this slot can currently take. Called when the engine (re)builds.

Parameter Type
context SlotGetContext

Promise<SlotValue<T>[]>

get id(): string;

Defined in: core/src/nlp/utterance/utterance.slot.ts:54

The guid an engine keys extractions on. Internal and never shown to anyone — the meaningful names live on the values a match resolves to.

string

emit<K>(event, ...args): void;

Defined in: core/src/utils/utils.eventemitter.ts:62

Invokes all listeners for event synchronously, without awaiting async listeners.

Type Parameter
K extends "updated"
Parameter Type
event K
args Parameters<SlotEvents[K]>

void

EventEmitter.emit


emitAsync<K>(event, ...args): Promise<void>;

Defined in: core/src/utils/utils.eventemitter.ts:73

Invokes all listeners for event and awaits them concurrently via Promise.all.

Type Parameter
K extends "updated"
Parameter Type
event K
args Parameters<SlotEvents[K]>

Promise<void>

EventEmitter.emitAsync


markUpdated(): void;

Defined in: core/src/nlp/utterance/utterance.slot.ts:65

Signals that getValues would now answer differently. An engine listens for this and rebuilds; nothing is cached here.

void


on<K>(
event,
callback,
options?): () => void;

Defined in: core/src/utils/utils.eventemitter.ts:21

Registers callback for event. Returns an unsubscribe function; passing options.abortSignal also removes the listener when that signal aborts.

Type Parameter
K extends "updated"
Parameter Type
event K
callback EventListener<Parameters<SlotEvents[K]>>
options OnOptions

() => void

EventEmitter.on


once<K>(
event,
callback,
options?): () => void;

Defined in: core/src/utils/utils.eventemitter.ts:45

Like on, but the listener is removed after firing once.

Type Parameter
K extends "updated"
Parameter Type
event K
callback EventListener<Parameters<SlotEvents[K]>>
options OnOptions

() => void

EventEmitter.once