Skip to main content

Class: BaseChatPromptTemplate

prompts.BaseChatPromptTemplate

Base class for prompt templates. Exposes a format method that returns a string prompt given a set of input values.

Hierarchy

Constructors

constructor

new BaseChatPromptTemplate(input)

Parameters

NameType
inputBasePromptTemplateInput

Overrides

BasePromptTemplate.constructor

Defined in

langchain/src/prompts/chat.ts:89

Properties

inputVariables

inputVariables: string[]

A list of variable names the prompt template expects

Inherited from

BasePromptTemplate.inputVariables

Defined in

langchain/src/prompts/base.ts:51


outputParser

Optional outputParser: BaseOutputParser

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

Inherited from

BasePromptTemplate.outputParser

Defined in

langchain/src/prompts/base.ts:53


partialVariables

Optional partialVariables: InputValues

Partial variables

Inherited from

BasePromptTemplate.partialVariables

Defined in

langchain/src/prompts/base.ts:55

Methods

_getPromptType

Abstract _getPromptType(): string

Return the string type key uniquely identifying this class of prompt template.

Returns

string

Inherited from

BasePromptTemplate._getPromptType

Defined in

langchain/src/prompts/base.ts:110


format

format(values): Promise<string>

Format the prompt given the input values.

Example

prompt.format({ foo: "bar" });

Parameters

NameTypeDescription
valuesInputValuesA dictionary of arguments to be passed to the prompt template.

Returns

Promise<string>

A formatted prompt string.

Overrides

BasePromptTemplate.format

Defined in

langchain/src/prompts/chat.ts:95


formatMessages

Abstract formatMessages(values): Promise<BaseChatMessage[]>

Parameters

NameType
valuesInputValues

Returns

Promise<BaseChatMessage[]>

Defined in

langchain/src/prompts/chat.ts:93


formatPromptValue

formatPromptValue(values): Promise<BasePromptValue>

Format the prompt given the input values and return a formatted prompt value.

Parameters

NameType
valuesInputValues

Returns

Promise<BasePromptValue>

A formatted PromptValue.

Overrides

BasePromptTemplate.formatPromptValue

Defined in

langchain/src/prompts/chat.ts:99


mergePartialAndUserVariables

mergePartialAndUserVariables(userVariables): Promise<InputValues>

Parameters

NameType
userVariablesInputValues

Returns

Promise<InputValues>

Inherited from

BasePromptTemplate.mergePartialAndUserVariables

Defined in

langchain/src/prompts/base.ts:69


partial

Abstract partial(values): Promise<BasePromptTemplate>

Parameters

NameType
valuesPartialValues

Returns

Promise<BasePromptTemplate>

Inherited from

BasePromptTemplate.partial

Defined in

langchain/src/prompts/base.ts:67


serialize

Abstract serialize(): SerializedBasePromptTemplate

Return a json-like object representing this prompt template.

Returns

SerializedBasePromptTemplate

Inherited from

BasePromptTemplate.serialize

Defined in

langchain/src/prompts/base.ts:115


deserialize

Static deserialize(data): Promise<BasePromptTemplate>

Load a prompt template from a json-like object describing it.

Remarks

Deserializing needs to be async because templates (e.g. FewShotPromptTemplate) can reference remote resources that we read asynchronously with a web request.

Parameters

NameType
dataSerializedBasePromptTemplate

Returns

Promise<BasePromptTemplate>

Inherited from

BasePromptTemplate.deserialize

Defined in

langchain/src/prompts/base.ts:125