Skip to main content

Class: MemoryVectorIndex<DATA>

A very simple vector index that stores all entries in memory. Useful when you only have a small number of entries and don't want to set up a real database, e.g. for conversational memory that does not need to be persisted.

Type parameters

Name
DATA

Implements

Constructors

constructor

new MemoryVectorIndex<DATA>(): MemoryVectorIndex<DATA>

Type parameters

Name
DATA

Returns

MemoryVectorIndex<DATA>

Methods

asIndex

asIndex(): MemoryVectorIndex<DATA>

Returns

MemoryVectorIndex<DATA>

Implementation of

VectorIndex.asIndex

Defined in

packages/modelfusion/src/vector-index/memory/MemoryVectorIndex.ts:115


queryByVector

queryByVector(«destructured»): Promise<{ data: DATA ; id: string ; similarity?: number }[]>

Parameters

NameType
«destructured»Object
› filter?(value: DATA) => boolean
› maxResultsnumber
› queryVectorVector
› similarityThreshold?number

Returns

Promise<{ data: DATA ; id: string ; similarity?: number }[]>

Implementation of

VectorIndex.queryByVector

Defined in

packages/modelfusion/src/vector-index/memory/MemoryVectorIndex.ts:81


serialize

serialize(): string

Returns

string

Defined in

packages/modelfusion/src/vector-index/memory/MemoryVectorIndex.ts:111


upsertMany

upsertMany(data): Promise<void>

Parameters

NameType
data{ data: DATA ; id: string ; vector: Vector }[]

Returns

Promise<void>

Implementation of

VectorIndex.upsertMany

Defined in

packages/modelfusion/src/vector-index/memory/MemoryVectorIndex.ts:69


deserialize

deserialize<DATA>(«destructured»): Promise<MemoryVectorIndex<DATA>>

Type parameters

Name
DATA

Parameters

NameType
«destructured»Object
› schema?Schema<DATA>
› serializedDatastring

Returns

Promise<MemoryVectorIndex<DATA>>

Defined in

packages/modelfusion/src/vector-index/memory/MemoryVectorIndex.ts:34