Creates a new in-memory vector store.
Adds a document to the in-memory store.
Parameters for the operation.
Optionaldocument?: stringRaw text content for the document.
Optionalembedding?: number[]Embeddings for the document.
Optionalid?: stringID for the document.
Optionalmetadata?: Record<string, any>Metadata for the document.
Promise that resolves to the ID of the newly added document.
Loads underlying dependencies (embeddings).
Promise that resolves to the same instance.
Executes a cosine-similarity query over the in-memory vectors.
Provide exactly one of queryText or queryEmbedding.
Query parameters.
OptionalnResults?: numberNumber of top results to return.
Optionalpredicate?: (value: QueryResult) => booleanFunction to filter results after retrieval.
OptionalqueryEmbedding?: number[]Precomputed query embedding.
OptionalqueryText?: stringRaw query string to search for.
Promise that resolves to an array of QueryResult.
Unloads underlying dependencies (embeddings).
Promise that resolves when unloading is complete.
Updates a document by ID.
Recomputes the embedding when document is provided and embedding is omitted.
Update parameters.
Optionaldocument?: stringNew content.
Optionalembedding?: number[]New embedding.
ID of the document to update.
Optionalmetadata?: Record<string, any>New metadata.
Promise that resolves when the update completes.
In-memory implementation of VectorStore.
Useful for testing or ephemeral/local scenarios where persistence is not required. Stores all vectors in a
Mapand performs cosine similarity search on demand.Example