Skip to main content

Interface: IPromptTemplateStore

Defined in: internal/prompt-template-store/types.ts:54

The prompts as data: every prompt text the gateway writes, keyed by job and versioned.

Implemented by PromptTemplateStore; the type of IAIGatewayDeps.promptTemplateStore, so a host may pass its own in overrides.

Methods​

activate()​

activate(args): Promise<void>

Defined in: internal/prompt-template-store/types.ts:156

activate -- makes one version the wording in force for its key

About​

One active version per key: this one on, the others off, as one repository operation.

The version must exist (404 otherwise). Drops this instance's cache, so its next render uses the version; other instances follow after their TTL.

Who needs it​

The host's administration screen, for a new wording and for a rollback.

Pitfalls​

CHAT_MAIN is cached by the provider only when the version keeps {cacheBreakpoint} with no per-call slot before it; a version without {skills} drops the skills of a call with the WARNING skills_slot_missing.

Parameters​

args​
key​

EPromptTemplateKey

version​

number

Returns​

Promise<void>


addVersion()​

addVersion(args): Promise<IPromptTemplate>

Defined in: internal/prompt-template-store/types.ts:132

addVersion -- saves a new wording of a key, inactive

About​

A new version is a draft until activate: nothing changes for the calls.

Numbers the version after the newest one of the key (the seed is 0, the first stored version 1) and saves it with isActive: false. Returns the stored template.

Who needs it​

The host's administration screen.

Parameters​

args​
body​

string

key​

EPromptTemplateKey

Returns​

Promise<IPromptTemplate>


get()​

get(args): Promise<IPromptTemplate>

Defined in: internal/prompt-template-store/types.ts:70

get -- the active template of a key

About​

The wording in force for a job, with its version.

Reads the cached active templates. Falls back to the seed (version 0) when the repository has no active version for the key: the host's seedTemplates entry, else the shipped one; a key with neither is a 404.

Who needs it​

ContextAssembler, which needs the body of CHAT_MAIN before it renders (the cache breakpoint, the {skills} slot); the other callers go through render.

Parameters​

args​
key​

EPromptTemplateKey

Returns​

Promise<IPromptTemplate>


listVersions()​

listVersions(args): Promise<IPage<IPromptTemplate>>

Defined in: internal/prompt-template-store/types.ts:113

listVersions -- the history of a key, paged, for the administration screen

About​

Every version of a key, highest first; the cursors are version numbers.

Validates the page (a limit outside 1–200 or both cursors at once is a 400) and reads the repository: the history is never cached. An unknown cursor is the repository's 404.

Who needs it​

The host's administration screen, before activate (pick a version) and after addVersion (see it listed).

Parameters​

args​
key​

EPromptTemplateKey

page​

IPageArgs<number>

Returns​

Promise<IPage<IPromptTemplate>>


refresh()​

refresh(): Promise<void>

Defined in: internal/prompt-template-store/types.ts:170

refresh -- drops the cache and reloads the active templates from the repository

About​

For a host that changed the repository behind the store's back.

The next renders use the reloaded versions; nothing else changes.

Returns​

Promise<void>


render()​

render(args): Promise<IRenderedPrompt>

Defined in: internal/prompt-template-store/types.ts:93

render -- the active template of a key with its slots filled

About​

The text that goes to the model, and the version that produced it.

Replaces every {slot} of the active body (get) with the value of that name and returns the text with key and version, so the trace can record which wording produced which answer. A slot without a value is a 400: a silent empty slot is the classic prompt bug. A value given for a slot the body does not use is ignored.

Who needs it​

ContextAssembler (CHAT_MAIN), WorkingMemory (MEMORY_WORKING), UserMemoryStore (MEMORY_USER), QueryRewriter (KB_QUERY_REWRITE): each renders its own key before its model call.

Pitfalls​

Pass every slot the active version uses, with an empty string when there is nothing to say. A stored version may use fewer slots than the seed, never more than its key's list (IPromptTemplateStoreConfig.seedTemplates).

Parameters​

args​
key​

EPromptTemplateKey

slots​

Record<string, string>

Slot values; keys match {slot} names.

Returns​

Promise<IRenderedPrompt>