store.BaseStore

Abstract base class for vector stores.

Usage

Source

store.BaseStore()

A store is responsible for storing documents and their embeddings, and retrieving relevant chunks based on similarity search.

Subclasses must implement all abstract methods to provide a concrete storage backend:

Methods

Name Description
connect() Connect to an existing store.
create() Create a new store.
retrieve() Retrieve the most similar chunks to the given text.
size() Count the number of documents in the store.
upsert() Upsert a document into the store.

connect()

Connect to an existing store.

Usage

Source

connect(*args, **kwargs)
Returns
BaseStore
A connected store instance.

create()

Create a new store.

Usage

Source

create(*args, **kwargs)
Returns
BaseStore
A newly created store instance.

retrieve()

Retrieve the most similar chunks to the given text.

Usage

Source

retrieve(text, top_k, *args, **kwargs)
Parameters
text: str

The query text to search for.

top_k: int
The maximum number of chunks to return.
Returns
Sequence[RetrievedChunk]
The most similar chunks, ordered by relevance.

size()

Count the number of documents in the store.

Usage

Source

size()
Returns
int
The number of documents (not chunks) in the store.

upsert()

Upsert a document into the store.

Usage

Source

upsert(document, *, skip_if_unchanged=True)

Insert or replace a document in the store.

Parameters
document: Document

The document to upsert.

skip_if_unchanged: bool = True
If True (default), skip the write when the existing document for the same identity key already has identical content and chunk metadata. This helps avoid unnecessary embedding work.