Class BaseStringPromptTemplate<RunInput, PartialVariableName>Abstract

Base class for string prompt templates. It extends the BasePromptTemplate class and overrides the formatPromptValue method to return a StringPromptValue.

Type Parameters

  • RunInput extends InputValues = any

  • PartialVariableName extends string = any

Hierarchy

Constructors

Properties

PromptValueReturnType: StringPromptValue
inputVariables: Extract<keyof RunInput, string>[]

A list of variable names the prompt template expects

partialVariables: PartialValues<PartialVariableName>

Partial variables

outputParser?: BaseOutputParser<unknown>

How to parse the output of calling an LLM on this formatted prompt

Methods

  • Format the prompt given the input values.

    Parameters

    • values: TypedPromptInputValues<RunInput>

      A dictionary of arguments to be passed to the prompt template.

    Returns Promise<string>

    A formatted prompt string.

    Example

    prompt.format({ foo: "bar" });
    
  • Merges partial variables and user variables.

    Parameters

    • userVariables: TypedPromptInputValues<RunInput>

      The user variables to merge with the partial variables.

    Returns Promise<InputValues<PartialVariableName | Extract<keyof RunInput, string>>>

    A Promise that resolves to an object containing the merged variables.

  • Stream all output from a runnable, as reported to the callback system. This includes all inner runs of LLMs, Retrievers, Tools, etc. Output is streamed as Log objects, which include a list of jsonpatch ops that describe how the state of the run has changed in each step, and the final state of the run. The jsonpatch ops can be applied in order to construct state.

    Parameters

    • input: RunInput
    • Optional options: Partial<BaseCallbackConfig>
    • Optional streamOptions: Omit<LogStreamCallbackHandlerInput, "autoClose">

    Returns AsyncGenerator<RunLogPatch, any, unknown>

Generated using TypeDoc