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
VectorIndex
<DATA
,MemoryVectorIndex
<DATA
>, (value
:DATA
) =>boolean
>
Constructors
constructor
• new MemoryVectorIndex<DATA
>(): MemoryVectorIndex
<DATA
>
Type parameters
Name |
---|
DATA |
Returns
MemoryVectorIndex
<DATA
>
Methods
asIndex
▸ asIndex(): MemoryVectorIndex
<DATA
>
Returns
MemoryVectorIndex
<DATA
>
Implementation of
Defined in
packages/modelfusion/src/vector-index/memory/MemoryVectorIndex.ts:115
queryByVector
▸ queryByVector(«destructured»
): Promise
<{ data
: DATA
; id
: string
; similarity?
: number
}[]>
Parameters
Name | Type |
---|---|
«destructured» | Object |
› filter? | (value : DATA ) => boolean |
› maxResults | number |
› queryVector | Vector |
› similarityThreshold? | number |
Returns
Promise
<{ data
: DATA
; id
: string
; similarity?
: number
}[]>
Implementation of
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
Name | Type |
---|---|
data | { data : DATA ; id : string ; vector : Vector }[] |
Returns
Promise
<void
>
Implementation of
Defined in
packages/modelfusion/src/vector-index/memory/MemoryVectorIndex.ts:69
deserialize
▸ deserialize<DATA
>(«destructured»
): Promise
<MemoryVectorIndex
<DATA
>>
Type parameters
Name |
---|
DATA |
Parameters
Name | Type |
---|---|
«destructured» | Object |
› schema? | Schema <DATA > |
› serializedData | string |
Returns
Promise
<MemoryVectorIndex
<DATA
>>
Defined in
packages/modelfusion/src/vector-index/memory/MemoryVectorIndex.ts:34