Skip to content

findRuntimeSlots()

PromptScript API


findRuntimeSlots(text): RuntimeSlotMatch[]

Defined in: core/src/utils/runtime-slots.ts:40

Find the runtime slots, escapes and malformed {{ in prompt text.

A slot is exactly {{input.<name>}} with <name> matching [A-Za-z_][A-Za-z0-9_]*. \{{ is an escape that covers the backslash and both braces. Any other {{ is invalid and covers everything up to and including the next }}, or only the braces when nothing closes it. Text inside a match is never scanned again.

Parameters

text

string

Prompt message text

Returns

RuntimeSlotMatch[]

Matches in text order

Example

findRuntimeSlots('Hi {{input.name}}');
// [{ kind: 'slot', name: 'name', offset: 3, length: 14 }]