Creates a new in-memory vector store.
Adds a document to the in-memory store.
Parameters for the operation.
Optional
document?: stringRaw text content for the document.
Optional
embedding?: number[]Embeddings for the document.
Optional
id?: stringID for the document.
Optional
metadata?: 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.
Optional
nResults?: numberNumber of top results to return.
Optional
predicate?: (value: QueryResult) => booleanFunction to filter results after retrieval.
Optional
queryEmbedding?: number[]Precomputed query embedding.
Optional
queryText?: 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.
Optional
document?: stringNew content.
Optional
embedding?: number[]New embedding.
ID of the document to update.
Optional
metadata?: 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
Map
and performs cosine similarity search on demand.Example