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/corememory
Moduleā—Since v1.0

memory

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

Functions

function
getInputValue→ any

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.

function
getOutputValue→ any

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
getPromptInputKey→ string

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.

Classes

class
BaseMemory

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 Aliases

typeAlias
InputValues: 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 input values for a Chain.

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.

View source on GitHub