LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
LangChain
  • Universal
  • Hub
  • Node
  • Load
  • Serializable
  • Encoder Backed
  • File System
  • In Memory
LangChain Core
  • Agents
  • Caches
  • Base
  • Dispatch
  • Web
  • Manager
  • Promises
  • Chat History
  • Context
  • Base
  • Langsmith
  • Documents
  • Embeddings
  • Errors
  • Example Selectors
  • Indexing
  • Base
  • Chat Models
  • Llms
  • Profile
  • Load
  • Serializable
  • Memory
  • Messages
  • Tool
  • Output Parsers
  • Openai Functions
  • Openai Tools
  • Outputs
  • Prompt Values
  • Prompts
  • Retrievers
  • Document Compressors
  • Runnables
  • Graph
  • Singletons
  • Stores
  • Structured Query
  • Tools
  • Base
  • Console
  • Log Stream
  • Run Collector
  • Tracer Langchain
  • Stream
  • Async Caller
  • Chunk Array
  • Context
  • Env
  • Event Source Parse
  • Format
  • Function Calling
  • Hash
  • Json Patch
  • Json Schema
  • Math
  • Ssrf
  • Stream
  • Testing
  • Tiktoken
  • Types
  • Vectorstores
Text Splitters
MCP Adapters
⌘I

LangChain Assistant

Ask a question to get started

Enter to send•Shift+Enter new line

Menu

LangChain
UniversalHubNodeLoadSerializableEncoder BackedFile SystemIn Memory
LangChain Core
AgentsCachesBaseDispatchWebManagerPromisesChat HistoryContextBaseLangsmithDocumentsEmbeddingsErrorsExample SelectorsIndexingBaseChat ModelsLlmsProfileLoadSerializableMemoryMessagesToolOutput ParsersOpenai FunctionsOpenai ToolsOutputsPrompt ValuesPromptsRetrieversDocument CompressorsRunnablesGraphSingletonsStoresStructured QueryToolsBaseConsoleLog StreamRun CollectorTracer LangchainStreamAsync CallerChunk ArrayContextEnvEvent Source ParseFormatFunction CallingHashJson PatchJson SchemaMathSsrfStreamTestingTiktokenTypesVectorstores
Text Splitters
MCP Adapters
Language
Theme
JavaScript@langchain/coreprompts
Module●Since v1.0

prompts

Copy
import { ... } from "@langchain/core/prompts";

Functions

function
checkValidTemplate
function
interpolateFString→ string
function
interpolateMustache→ string
function
parseFString→ ParsedTemplateNode[]
function
parseMustache→ ParsedTemplateNode[]
function
parseTemplate→ ParsedTemplateNode[]
function
renderTemplate→ string

Classes

class
AIMessagePromptTemplate

Class that represents an AI message prompt template. It extends the BaseMessageStringPromptTemplate.

class
BaseChatPromptTemplate

Abstract class that serves as a base for creating chat prompt templates. It extends the BasePromptTemplate.

class
BaseMessagePromptTemplate

Abstract class that serves as a base for creating message prompt templates. It defines how to format messages for different roles in a conversation.

class
BaseMessageStringPromptTemplate

Abstract class that serves as a base for creating message string prompt templates. It extends the BaseMessagePromptTemplate.

class
BasePromptTemplate

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

class
BaseStringPromptTemplate

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

class
ChatMessagePromptTemplate

Class that represents a chat message prompt template. It extends the BaseMessageStringPromptTemplate.

class
ChatPromptTemplate

Class that represents a chat prompt. It extends the BaseChatPromptTemplate and uses an array of BaseMessagePromptTemplate instances to format a series of messages for a conversation.

class
DictPromptTemplate

A Runnable is a generic unit of work that can be invoked, batched, streamed, and/or transformed.

class
FewShotChatMessagePromptTemplate

Chat prompt template that contains few-shot examples.

class
FewShotPromptTemplate

Prompt template that contains few-shot examples.

class
HumanMessagePromptTemplate

Class that represents a human message prompt template. It extends the BaseMessageStringPromptTemplate.

class
ImagePromptTemplate

An image prompt template for a multimodal model.

class
MessagesPlaceholder

Class that represents a placeholder for messages in a chat prompt. It extends the BaseMessagePromptTemplate.

class
PipelinePromptTemplate

Class that handles a sequence of prompts, each of which may require different input variables. Includes methods for formatting these prompts, extracting required input values, and handling partial prompts.

class
PromptTemplate

Schema to represent a basic prompt for an LLM.

class
StructuredPrompt

Interface for the input of a ChatPromptTemplate.

class
SystemMessagePromptTemplate

Class that represents a system message prompt template. It extends the BaseMessageStringPromptTemplate.

Interfaces

interface
BasePromptTemplateInput

Input common to all prompt templates.

interface
ChatMessagePromptTemplateFields

Interface for the fields of a ChatMessagePromptTemplate.

interface
ChatPromptTemplateInput

Interface for the input of a ChatPromptTemplate.

interface
FewShotChatMessagePromptTemplateInput

Input common to all prompt templates.

interface
FewShotPromptTemplateInput

Input common to all prompt templates.

interface
ImagePromptTemplateInput

Inputs to create a ImagePromptTemplate

interface
MessagesPlaceholderFields

Interface for the fields of a MessagePlaceholder.

interface
MessageStringPromptTemplateFields

Interface for the fields of a MessageStringPromptTemplate.

interface
PromptTemplateInput

Inputs to create a PromptTemplate

interface
StructuredPromptInput

Interface for the input of a ChatPromptTemplate.

Type Aliases

typeAlias
BaseMessagePromptTemplateLike: BaseMessagePromptTemplate | BaseMessageLike
typeAlias
Example: Record<string, string>
typeAlias
ExtractedFStringParams: RunInput extends Symbol ? ParamsFromFString<T> : RunInput
typeAlias
ParamsFromFString: { [Key in ExtractTemplateParamsRecursive<T>[number] | string & Record<never, never>]: any }
typeAlias
ParsedFStringNode: ParsedTemplateNode

Alias for ParsedTemplateNode since it is the same for both f-string and mustache templates.

typeAlias
ParsedTemplateNode: __type | __type

Type that represents a node in a parsed format string. It can be either a literal text or a variable name.

typeAlias
PipelinePromptParams

Type that includes the name of the prompt and the prompt itself.

typeAlias
PipelinePromptTemplateInput: Omit<BasePromptTemplateInput, "inputVariables"> & __type

Type that extends the BasePromptTemplateInput type, excluding the inputVariables property. It includes an array of pipelinePrompts and a finalPrompt.

typeAlias
SerializedBasePromptTemplate: SerializedFewShotTemplate | SerializedPromptTemplate

Represents a serialized version of a base prompt template. This type can be either a SerializedFewShotTemplate or a SerializedPromptTemplate.

typeAlias
SerializedFewShotTemplate

Represents a serialized version of a few-shot template. This type includes an _type field set to 'few_shot', input_variables which are an array of strings representing the variables to be used in the template, examples which can be a string or an array of Example objects, an optional example_prompt which is a SerializedPromptTemplate, example_separator which is a string, optional prefix and suffix strings, and template_format which specifies the format of the template.

typeAlias
SerializedPromptTemplate

Represents a serialized version of a prompt template. This type is used to create dynamic prompts for language models. It contains an optional _type field which, if present, is set to 'prompt'. It also includes input_variables, an array of strings representing the variables to be used in the prompt, an optional template_format specifying the format of the template, and an optional template which is the actual template string.

typeAlias
TemplateFormat: "f-string" | "mustache"

Type that specifies the format of a template.

typeAlias
TypedPromptInputValues: InputValues<StringWithAutocomplete<Extract<keyof RunInput, string>>>

Variables

variable
DEFAULT_FORMATTER_MAPPING: Record<TemplateFormat, Interpolator>
variable
DEFAULT_PARSER_MAPPING: Record<TemplateFormat, Parser>
View source on GitHub