Interface: IVectorStore
Defined in: internal/vector-store/types.ts:22
Tenant-filtered vector index of KB chunks.
Implemented by VectorStore; the type of IAIGatewayDeps.vectorStore, so a host may pass its own in overrides.
Methods
deleteByDoc()
deleteByDoc(
__namedParameters):Promise<number>
Defined in: internal/vector-store/types.ts:65
deleteByDoc -- removes every chunk of one document
About
The document is gone or about to be replaced; its chunks go first.
Passes through to the adapter and returns the number of chunks removed; 0 for an unknown document.
Who needs it
KbIngestor.ingestDocument (before the new chunks are written) and KbIngestor.removeDocument.
Parameters
__namedParameters
docId
string
tenantId
string
Returns
Promise<number>
describeIndex()
describeIndex():
Promise<IVectorIndexInfo>
Defined in: internal/vector-store/types.ts:113
describeIndex -- the embedding model and vector length the index was created with
About
The ruler of the index, to compare with the Embedder's.
Passes through to the adapter's describe.
Who needs it
KbIngestor.checkIndex, before every ingest; upsertChunks and search, for their own checks.
Returns
Promise<IVectorIndexInfo>
moveBook()
moveBook(
__namedParameters):Promise<number>
Defined in: internal/vector-store/types.ts:88
moveBook -- moves a book to another library
About
Metadata only: the vectors stay, no re-embedding (D22).
Sets libraryId on every chunk of the book through the adapter and returns the number of chunks changed.
Who needs it
KbIngestor.moveBook.
Parameters
__namedParameters
bookId
string
libraryId
string
tenantId
string
Returns
Promise<number>
search()
search(
__namedParameters):Promise<IChunkHit[]>
Defined in: internal/vector-store/types.ts:134
search -- the nearest chunks of a tenant for a query vector
About
The k closest chunks inside the scope the caller named, best first.
Filters by tenant and by filters (libraries, books, tags, language), returns at most k hits with their score.
An empty filters.libraryIds finds nothing, without asking the index: a scope that came out empty by accident never
opens every library. A vector of another length than the index is a 400 (error 5372772695100).
Who needs it
KbRetriever.retrieve, once per call with a knowledge base, with the vector of the rewritten query.
Pitfalls
k is the adapter's cut; the retriever drops hits under minScore afterwards, so fewer than k may reach the prompt.
Parameters
__namedParameters
filters
k
number
tenantId
string
vector
number[]
Returns
Promise<IChunkHit[]>
upsertChunks()
upsertChunks(
__namedParameters):Promise<void>
Defined in: internal/vector-store/types.ts:42
upsertChunks -- stores the chunks of a document with their vectors
About
Nothing enters the index that cannot be compared with what is there.
Inserts or replaces the records by chunk id. Refuses the whole call before any write when a record belongs to another tenant (error 5372772694716) or when its vector was made by another embedding model or has another length than the index (error 5372772694902), both 400. An empty list is a no-op without a call to the adapter.
Who needs it
KbIngestor.ingestDocument, after deleteByDoc removed the document's old chunks.
Pitfalls
The check is per call, not per record: one bad record and nothing of the batch is written.
Parameters
__namedParameters
records
tenantId
string
Returns
Promise<void>