Skip to content

Overview / VectorMemoryCollection

VectorMemoryCollection

Properties

PropertyModifierType
embedderNamepublicstring
embedderSizepublicnumber
namepublicstring

Methods

addPoint()

addPoint(content, vector, metadata?, id?, ...args?): Promise<undefined | object>

Add a point (and its metadata) to the vector store.

Parameters

ParameterTypeDescription
contentstringOriginal content to push.
vectornumber[]The embedding vector.
metadata?Record<string, any>Optional metadata associated with the content.
id?`${string}-${string}-${string}-${string}-${string}`id to associate with the point. It has to be a UUID-like string.
...args?object & object | object[]Optional arguments to pass.

Returns

Promise<undefined | object>

The id of the added point.


addPoints()

addPoints(points, ...args): Promise<object>

Adds an array of points to the vector memory collection.

Parameters

ParameterTypeDescription
pointsobject[]An array of PointData representing the points to be added.
...argsobject & object | object[]-

Returns

Promise<object>

The result of the upsert operation.


createCollection()

createCollection(): Promise<void>

Creates a new collection with the specified configuration.

Returns

Promise<void>


deletePoints()

deletePoints(ids): Promise<object>

Delete points by their IDs.

Parameters

ParameterTypeDescription
idsstring[]The IDs of the points to delete.

Returns

Promise<object>

The result of the deletion.


deletePointsByMetadata()

deletePointsByMetadata(metadata): undefined | Promise<object>

Delete points by their metadata.

Parameters

ParameterTypeDescription
metadataRecord<string, undefined | null | object | object | object | object | Record<string, unknown>>The metadata of the points to delete.

Returns

undefined | Promise<object>

The result of the deletion.


getAllPoints()

getAllPoints(limit, filter?): Promise<object[]>

Retrieves all points from the vector memory collection.

Parameters

ParameterTypeDefault valueDescription
limitnumber10000The maximum number of points to retrieve (default: 10000).
filter?Record<string, undefined | null | object | object | object | object | Record<string, unknown>>undefinedAn optional filter to apply to the points.

Returns

Promise<object[]>

An array of PointData.


getPoints()

getPoints(ids): Promise<object[]>

Retrieves points from the vector memory collection based on their IDs.

Parameters

ParameterTypeDescription
idsstring[]The IDs of the points to retrieve.

Returns

Promise<object[]>

An array of PointData.


recallMemoriesFromEmbedding()

recallMemoriesFromEmbedding(embedding, filter?, k?, threshold?): Promise<MemoryDocument[]>

Retrieves memories from the vector database based on an embedded vector.

Parameters

ParameterTypeDefault valueDescription
embeddingnumber[] | object | objectundefinedThe embedding vector to search for.
filter?Record<string, undefined | null | object | object | object | object | Record<string, unknown>>undefinedOptional filter to apply to the search.
k?number10The maximum number of memories to retrieve (default: 10).
threshold?numberundefinedThe score threshold for retrieved memories.

Returns

Promise<MemoryDocument[]>

An array of MemoryDocument representing the retrieved memories.


saveDump()

saveDump(folder): Promise<void>

Saves the collection dump to a specified folder.

Parameters

ParameterTypeDefault valueDescription
folderstring'dormouse/'The folder path where the dump will be saved. Defaults to 'dormouse/'.

Returns

Promise<void>


create()

static create(name, embedderName, embedderSize): Promise<VectorMemoryCollection>

Creates a new VectorMemoryCollection with the specified name, embedder name, and embedder size. If a collection with the same name already exists, it skips the creation step. If the existing collection has a different size, it updates the collection by deleting and recreating it.

Parameters

ParameterTypeDescription
namestringThe name of the collection.
embedderNamestringThe name of the embedder.
embedderSizenumberThe size of the embedder.

Returns

Promise<VectorMemoryCollection>

The created VectorMemoryCollection.

Released under the GPL-3.0 License.