LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
LangChain
  • Browser
  • Universal
  • Hub
  • Node
  • Load
  • Serializable
  • Encoder Backed
  • File System
  • In Memory
  • Tools
LangChain Core
  • Agents
  • Caches
  • Base
  • Dispatch
  • Web
  • Manager
  • Promises
  • Chat History
  • Context
  • Base
  • Langsmith
  • Documents
  • Embeddings
  • Errors
  • Example Selectors
  • Indexing
  • Base
  • Chat Models
  • Compat
  • Event
  • Llms
  • Profile
  • Stream
  • Structured Output
  • Load
  • Serializable
  • Memory
  • Messages
  • Tool
  • Output Parsers
  • Openai Functions
  • Openai Tools
  • Outputs
  • Prompt Values
  • Prompts
  • Retrievers
  • Document Compressors
  • Runnables
  • Graph
  • Singletons
  • Stores
  • Structured Query
  • Testing
  • 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
  • Standard Schema
  • Stream
  • Testing
  • Tiktoken
  • Types
  • Uuid
  • Vectorstores
Text Splitters
MCP Adapters
⌘I

LangChain Assistant

Ask a question to get started

Enter to send•Shift+Enter new line

Menu

LangChain
BrowserUniversalHubNodeLoadSerializableEncoder BackedFile SystemIn MemoryTools
LangChain Core
AgentsCachesBaseDispatchWebManagerPromisesChat HistoryContextBaseLangsmithDocumentsEmbeddingsErrorsExample SelectorsIndexingBaseChat ModelsCompatEventLlmsProfileStreamStructured OutputLoadSerializableMemoryMessagesToolOutput ParsersOpenai FunctionsOpenai ToolsOutputsPrompt ValuesPromptsRetrieversDocument CompressorsRunnablesGraphSingletonsStoresStructured QueryTestingToolsBaseConsoleLog StreamRun CollectorTracer LangchainStreamAsync CallerChunk ArrayContextEnvEvent Source ParseFormatFunction CallingHashJson PatchJson SchemaMathSsrfStandard SchemaStreamTestingTiktokenTypesUuidVectorstores
Text Splitters
MCP Adapters
Language
Theme
JavaScript@langchain/coreprompts
Module●Since v0.3

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
BaseChatPromptTemplate
class
BaseMessagePromptTemplate
class
BaseMessageStringPromptTemplate
class
BasePromptTemplate
class
BaseStringPromptTemplate
class
ChatMessagePromptTemplate
class
ChatPromptTemplate
class
DictPromptTemplate
class
FewShotChatMessagePromptTemplate
class
FewShotPromptTemplate
class
HumanMessagePromptTemplate
class
ImagePromptTemplate
class
MessagesPlaceholder
class
PipelinePromptTemplate
class
PromptTemplate
class
StructuredPrompt
class
SystemMessagePromptTemplate

Interfaces

Type Aliases

Variables

View source on GitHub
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.

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>>>
variable
DEFAULT_FORMATTER_MAPPING: Record<TemplateFormat, Interpolator>
variable
DEFAULT_PARSER_MAPPING: Record<TemplateFormat, Parser>

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

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

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

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

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

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

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

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.

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

Chat prompt template that contains few-shot examples.

Prompt template that contains few-shot examples.

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

An image prompt template for a multimodal model.

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

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.

Schema to represent a basic prompt for an LLM.

Interface for the input of a ChatPromptTemplate.

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