Interface PromptService

interface PromptService {
    getAllPrompts(): PromptMap;
    getDefaultRawPrompt(id): undefined | PromptTemplate;
    getPrompt(id, args?): Promise<undefined | ResolvedPromptTemplate>;
    getRawPrompt(id): undefined | PromptTemplate;
    getUnresolvedPrompt(id): undefined | PromptTemplate;
    getVariantId(id): Promise<string>;
    getVariantIds(id): string[];
    removePrompt(id): void;
    storePromptTemplate(promptTemplate): void;
}

Implemented by

Methods

  • Allows to directly replace placeholders in the prompt. The supported format is 'Hi {{name}}!'. The placeholder is then searched inside the args object and replaced. Function references are also supported via format '~{functionId}'.

    Parameters

    • id: string

      the id of the prompt

    • Optional args: {
          [key: string]: unknown;
      }

      the object with placeholders, mapping the placeholder key to the value

      • [key: string]: unknown

    Returns Promise<undefined | ResolvedPromptTemplate>

  • Retrieve the currently selected variant ID for a given main prompt ID. If a variant is selected for the main prompt, it will be returned. Otherwise, the main prompt ID will be returned.

    Parameters

    • id: string

      the id of the main prompt

    Returns Promise<string>

    the variant ID if one is selected, or the main prompt ID otherwise