Skip to content

extractPromptDefinitions()

PromptScript API


extractPromptDefinitions(program): PromptExtraction

Defined in: core/src/prompt-definitions.ts:714

Read every @prompts entry of a program into typed definitions.

Accepts the canonical AST (CanonicalBlock with FieldEntry values) and the legacy AST (ObjectContent with TextContent values). Problems do not stop the read: the entry keeps what is valid and each problem becomes an issue. An entry whose key is reserved, malformed or collides with another key (case-insensitively) is reported and left out of prompts.

Parameters

program

ProgramInput

A resolved program, canonical or legacy

Returns

PromptExtraction

The definitions and the issues found

Example

const { prompts, issues } = extractPromptDefinitions(program);