Vectorstore Backend Base Class
The interface of vector database backends.
A backend runs one vectorstore’s database operations: its lifecycle, its data, and its dumps.
Lifecycle, status and scheduling are the job of
VectorstoreService, which calls a backend.
- class smarter.apps.vectorstore.backends.base.SearchResult(id, text, metadata=<factory>, score=None)[source]
Bases:
objectA chunk that a search found.
- __init__(id, text, metadata=<factory>, score=None)
- text: str
- class smarter.apps.vectorstore.backends.base.SmarterVectorstoreBackend(vectorstore, embeddings=None)[source]
Bases:
ABCAbstract base class of the vector database backends.
- Parameters:
vectorstore (
VectorstoreMeta) – The vectorstore.embeddings (
Embeddings|None) – Its embeddings model. Required forupsert()andsearch().
- __init__(vectorstore, embeddings=None)[source]
- abstractmethod create_snapshot(name)[source]
Take a snapshot, or backup.
- Return type:
SnapshotInfo
- abstractmethod delete(ids)[source]
Delete chunks.
Ids that do not exist are ignored.
- Return type:
- destroy()[source]
Delete the index or collection, and any infrastructure that Smarter runs.
- Return type:
- property embeddings: Embeddings
- property index_name: str
- infrastructure_ready()[source]
Whether the infrastructure that Smarter runs is ready, and why not.
A managed service always is.
- provision()[source]
Create the database’s infrastructure, if Smarter runs it.
It returns without waiting for it.
- Return type:
- abstractmethod restore_snapshot(name)[source]
Replace the index or collection’s data with a snapshot’s.
- Return type:
- abstractmethod search(query, k=4, search_type='similarity', score_threshold=None, fetch_k=None, lambda_mult=None, metadata_filter=None)[source]
Find the chunks that are closest in meaning to a query.
- abstractmethod stats()[source]
The database’s statistics.
It includes vector_count.
- class smarter.apps.vectorstore.backends.base.SnapshotInfo(name, size_bytes=None, ready=True)[source]
Bases:
objectA Qdrant snapshot, or a Pinecone backup.
- __init__(name, size_bytes=None, ready=True)
- name: str
- ready: bool = True
- exception smarter.apps.vectorstore.backends.base.VectorStoreBackendConnectionError(message='')[source]
Bases:
VectorStoreBackendErrorThe vector database cannot be reached.
- exception smarter.apps.vectorstore.backends.base.VectorStoreBackendError(message='')[source]
Bases:
SmarterExceptionA vector database operation failed.