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/corevectorstoresSaveableVectorStore
Class●Since v1.0

SaveableVectorStore

Abstract class extending VectorStore that defines a contract for saving and loading vector store instances.

The SaveableVectorStore class allows vector store implementations to persist their data and retrieve it when needed.The format for saving and loading data is left to the implementing subclass.

Subclasses must implement the save method to handle their custom serialization logic, while the load method enables reconstruction of a vector store from saved data, requiring compatible embeddings through the EmbeddingsInterface.

Copy
class SaveableVectorStore

Bases

VectorStore

Constructors

constructor
constructor

Properties

property
embeddings: EmbeddingsInterface

Embeddings interface for generating vector embeddings from text queries, enabling vector-based similarity searches.

property
FilterType: string | object

Defines the filter type used in search and delete operations. Can be an object for structured conditions or a string for simpler filtering.

property
lc_kwargs: SerializedFields
property
lc_serializable: boolean
property
lc_aliases: __type | undefined
property
lc_attributes: __type | undefined
property
lc_id: string[]
property
lc_secrets: __type | undefined
property
lc_serializable_keys: string[] | undefined

Methods

method
_vectorstoreType→ string

Returns a string representing the type of vector store, which subclasses must implement to identify their specific vector storage type.

method
addDocuments→ Promise<void>

Method to add documents to the memory vector store. It extracts the text from each document, generates embeddings for them, and adds the resulting vectors to the store.

method
addVectors→ Promise<void>

Method to add vectors to the memory vector store. It creates MemoryVector instances for each vector and document pair and adds them to the store.

method
asRetriever→ VectorStoreRetriever<FakeVectorStore>

Creates a VectorStoreRetriever instance with flexible configuration options.

method
delete→ Promise<void>

Deletes documents from the vector store based on the specified parameters.

method
maxMarginalRelevanceSearch→ Promise<DocumentInterface<Record<string, any>>[]>

Return documents selected using the maximal marginal relevance. Maximal marginal relevance optimizes for similarity to the query AND diversity among selected documents.

method
save→ Promise<void>

Saves the current state of the vector store to the specified directory.

This method must be implemented by subclasses to define their own serialization process for persisting vector data. The implementation determines the structure and format of the saved data.

method
similaritySearch→ Promise<DocumentInterface<Record<string, any>>[]>

Searches for documents similar to a text query by embedding the query and performing a similarity search on the resulting vector.

method
similaritySearchVectorWithScore→ Promise<[Document<Record<string, any>>, number][]>

Method to perform a similarity search in the memory vector store. It calculates the similarity between the query vector and each vector in the store, sorts the results by similarity, and returns the top k results along with their scores.

method
similaritySearchWithScore→ Promise<[DocumentInterface<Record<string, any>>, number][]>

Searches for documents similar to a text query by embedding the query, and returns results with similarity scores.

method
toJSON→ Serialized
method
toJSONNotImplemented→ SerializedNotImplemented
method
fromDocuments→ Promise<FakeVectorStore>

Static method to create a FakeVectorStore instance from an array of Document instances. It adds the documents to the store.

method
fromTexts→ Promise<FakeVectorStore>

Static method to create a FakeVectorStore instance from an array of texts. It creates a Document for each text and metadata pair, and adds them to the store.

method
lc_name→ string

The name of the serializable. Override to provide an alias or to preserve the serialized module name in minified environments.

Implemented as a static method to support loading logic.

method
load→ Promise<Document<Record<string, any>>[]>

Loads the documents.

Inherited fromVectorStore

Properties

Pembeddings: EmbeddingsInterface
—

Embeddings interface for generating vector embeddings from text queries,

PFilterType: (doc: Document)
—

Defines the filter type used in search and delete operations. Can be an

Plc_kwargs: SerializedFieldsPlc_serializable: booleanPlc_aliases: __type | undefinedPlc_attributes: __type | undefinedPlc_id: string[]Plc_secrets: __type | undefinedPlc_serializable_keys: string[] | undefined

Methods

M_vectorstoreType→ string
—

Returns a string representing the type of vector store, which subclasses

MaddDocuments→ Promise<void>
—

Method to add documents to the memory vector store. It extracts the

MaddVectors→ Promise<void>
—

Method to add vectors to the memory vector store. It creates

MasRetriever→ VectorStoreRetriever<FakeVectorStore>
—

Creates a VectorStoreRetriever instance with flexible configuration options.

Mdelete→ Promise<void>
—

Deletes documents from the vector store based on the specified parameters.

MmaxMarginalRelevanceSearch→ Promise<DocumentInterface<Record<string, any>>[]>
—

Return documents selected using the maximal marginal relevance.

MsimilaritySearch→ Promise<DocumentInterface<Record<string, any>>[]>
—

Searches for documents similar to a text query by embedding the query and

MsimilaritySearchVectorWithScore→ Promise<[Document<Record<string, any>>, number][]>
—

Method to perform a similarity search in the memory vector store. It

MsimilaritySearchWithScore→ Promise<[DocumentInterface<Record<string, any>>, number][]>
—

Searches for documents similar to a text query by embedding the query,

MtoJSON→ SerializedMtoJSONNotImplemented→ SerializedNotImplementedMfromDocuments→ Promise<FakeVectorStore>
—

Static method to create a FakeVectorStore instance from an array of

MfromTexts→ Promise<FakeVectorStore>
—

Static method to create a FakeVectorStore instance from an array of

Mlc_name→ string
—

The name of the serializable. Override to provide an alias or

Inherited fromSerializable

Properties

Plc_kwargs: SerializedFieldsPlc_namespace: ["langchain_core", "callbacks", string]
—

A path to the module that contains the class, eg. ["langchain", "llms"]

Plc_serializable: booleanPlc_aliases: __type | undefinedPlc_attributes: __type | undefinedPlc_id: string[]Plc_secrets: __type | undefinedPlc_serializable_keys: string[] | undefined

Methods

MtoJSON→ SerializedMtoJSONNotImplemented→ SerializedNotImplementedMlc_name→ string
—

The name of the serializable. Override to provide an alias or

View source on GitHub