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
  • Llms
  • Profile
  • 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
  • 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 ModelsLlmsProfileStructured OutputLoadSerializableMemoryMessagesToolOutput ParsersOpenai FunctionsOpenai ToolsOutputsPrompt ValuesPromptsRetrieversDocument CompressorsRunnablesGraphSingletonsStoresStructured QueryTestingToolsBaseConsoleLog StreamRun CollectorTracer LangchainStreamAsync CallerChunk ArrayContextEnvEvent Source ParseFormatFunction CallingHashJson PatchJson SchemaMathSsrfStandard SchemaStreamTestingTiktokenTypesVectorstores
Text Splitters
MCP Adapters
Language
Theme
JavaScript@langchain/corememory
Moduleā—Since v0.3

memory

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

Functions

function
getInputValue→ any
function
getOutputValue→ any
function
getPromptInputKey→ string

Classes

class
BaseMemory

Type Aliases

typeAlias
InputValues: Record<string, any>
View source on GitHub
typeAlias
MemoryVariables: Record<string, any>

Type alias for a record where the keys are strings and the values can be any type. This is used to represent the memory variables in a Chain.

typeAlias
OutputValues: Record<string, any>

Type alias for a record where the keys are strings and the values can be any type. This is used to represent the output values from a Chain.

This function is used by memory classes to select the input value to use for the memory. If there is only one input value, it is used. If there are multiple input values, the inputKey must be specified.

This function is used by memory classes to select the output value to use for the memory. If there is only one output value, it is used. If there are multiple output values, the outputKey must be specified. If no outputKey is specified, an error is thrown.

Function used by memory classes to get the key of the prompt input, excluding any keys that are memory variables or the "stop" key. If there is not exactly one prompt input key, an error is thrown.

Abstract base class for memory in LangChain's Chains. Memory refers to the state in Chains. It can be used to store information about past executions of a Chain and inject that information into the inputs of future executions of the Chain.

Type alias for a record where the keys are strings and the values can be any type. This is used to represent the input values for a Chain.