Vector Store Adapters
The adapters layer provides concrete wrappers around different vector database clients (Chroma, PGVector, Milvus). It allows the synchronization pipeline to write to any vector store using a unified interface.
Base Interface
Abstract interface for vector store backends. |
Abstract VectorStoreAdapter — the contract all backends must implement.
- Keeping this boundary explicit means:
SyncManager has no knowledge of which backend is in use.
New backends require only implementing three methods.
Contract tests can verify any adapter against this interface.
- class VectorStoreAdapter[source]
Bases:
ABCAbstract interface for vector store backends.
Each backend wraps a LangChain VectorStore and exposes the three operations the SyncManager needs:
upsert,delete, andas_retriever.- abstract upsert(document)[source]
Add or replace a document in the vector store.
The implementation should use the
document.idfield as the canonical identifier for idempotent upserts.- Parameters:
document (Document)
- Return type:
None
- abstract upsert_batch(documents)[source]
Add or replace a list of documents in the vector store.
The implementation should use each
document.idfield as the canonical identifier for idempotent upserts.- Parameters:
documents (list[Document])
- Return type:
None
- abstract delete(doc_id)[source]
Remove a document by its stable ID.
Implementations must handle the case where the ID does not exist (e.g. soft-delete stores, delete events arriving before inserts).
- Parameters:
doc_id (str)
- Return type:
None
Vector Database Implementations
Vector store adapter for ChromaDB. |
|
Vector store adapter for PGVector (PostgreSQL). |
|
Vector store adapter for Milvus. |
Chroma vector store adapter implementation.
- class ChromaAdapter(collection_name, embeddings, persist_directory=None, **kwargs)[source]
Bases:
VectorStoreAdapterVector store adapter for ChromaDB.
- Parameters:
- __init__(collection_name, embeddings, persist_directory=None, **kwargs)[source]
Initialises the ChromaAdapter.
- Parameters:
- Return type:
None
- upsert(document)[source]
Add or replace a document in the vector store.
- Parameters:
document (Document) – The LangChain Document to upsert.
- Return type:
None
- upsert_batch(documents)[source]
Add or replace a list of documents in the vector store.
- Parameters:
documents (list[Document]) – The list of LangChain Documents to upsert.
- Return type:
None
- delete(doc_id)[source]
Remove a document by its stable ID.
- Parameters:
doc_id (str) – The stable ID of the document to remove.
- Return type:
None
PGVector vector store adapter implementation.
- class PGVectorAdapter(connection_string, collection_name, embeddings, pre_delete_collection=False)[source]
Bases:
VectorStoreAdapterVector store adapter for PGVector (PostgreSQL).
- Parameters:
- __init__(connection_string, collection_name, embeddings, pre_delete_collection=False)[source]
Initialises the PGVectorAdapter.
- Parameters:
- Return type:
None
- upsert(document)[source]
Add or replace a document in the vector store.
- Parameters:
document (Document) – The LangChain Document to upsert.
- Return type:
None
- upsert_batch(documents)[source]
Add or replace a list of documents in the vector store.
- Parameters:
documents (list[Document]) – The list of LangChain Documents to upsert.
- Return type:
None
- delete(doc_id)[source]
Remove a document by its stable ID.
- Parameters:
doc_id (str) – The stable ID of the document to remove.
- Return type:
None
Milvus vector store adapter implementation.
- class MilvusAdapter(collection_name, embeddings, connection_uri='http://localhost:19530', drop_old=False, **kwargs)[source]
Bases:
VectorStoreAdapterVector store adapter for Milvus.
- Parameters:
- __init__(collection_name, embeddings, connection_uri='http://localhost:19530', drop_old=False, **kwargs)[source]
Initialises the MilvusAdapter.
- Parameters:
collection_name (str) – Name of the Milvus collection.
embeddings (Embeddings) – Embeddings model to generate vector representations.
connection_uri (str) – Connection URI for the Milvus instance (default http://localhost:19530).
drop_old (bool) – Drop and recreate collection on init (default False).
**kwargs (Any) – Additional arguments forwarded to the Milvus vector store.
- Return type:
None
- upsert(document)[source]
Add or replace a document in the vector store.
- Parameters:
document (Document) – The LangChain Document to upsert.
- Return type:
None
- upsert_batch(documents)[source]
Add or replace a list of documents in the vector store.
- Parameters:
documents (list[Document]) – The list of LangChain Documents to upsert.
- Return type:
None
- delete(doc_id)[source]
Remove a document by its stable ID.
- Parameters:
doc_id (str) – The stable ID of the document to remove.
- Return type:
None