Vector Stores#
ragbits.core.vector_stores.base.VectorStoreEntry
#
ragbits.core.vector_stores.base.VectorStoreOptions
#
ragbits.core.vector_stores.base.VectorStore
#
VectorStore(default_options: VectorStoreOptions | None = None, metadata_store: MetadataStore | None = None)
Bases: ABC
A class with an implementation of Vector Store, allowing to store and retrieve vectors by similarity function.
Constructs a new VectorStore instance.
PARAMETER | DESCRIPTION |
---|---|
default_options |
The default options for querying the vector store.
TYPE:
|
metadata_store |
The metadata store to use.
TYPE:
|
Source code in packages/ragbits-core/src/ragbits/core/vector_stores/base.py
from_config
classmethod
#
from_config(config: dict) -> VectorStore
Creates and returns an instance of the Reranker class from the given configuration.
PARAMETER | DESCRIPTION |
---|---|
config |
A dictionary containing the configuration for initializing the Reranker instance.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
VectorStore
|
An initialized instance of the Reranker class. |
RAISES | DESCRIPTION |
---|---|
NotImplementedError
|
If the class cannot be created from the provided configuration. |
Source code in packages/ragbits-core/src/ragbits/core/vector_stores/base.py
store
abstractmethod
async
#
store(entries: list[VectorStoreEntry]) -> None
Store entries in the vector store.
PARAMETER | DESCRIPTION |
---|---|
entries |
The entries to store.
TYPE:
|
retrieve
abstractmethod
async
#
retrieve(vector: list[float], options: VectorStoreOptions | None = None) -> list[VectorStoreEntry]
Retrieve entries from the vector store.
PARAMETER | DESCRIPTION |
---|---|
vector |
The vector to search for.
TYPE:
|
options |
The options for querying the vector store.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[VectorStoreEntry]
|
The entries. |
Source code in packages/ragbits-core/src/ragbits/core/vector_stores/base.py
list
abstractmethod
async
#
list(where: WhereQuery | None = None, limit: int | None = None, offset: int = 0) -> list[VectorStoreEntry]
List entries from the vector store. The entries can be filtered, limited and offset.
PARAMETER | DESCRIPTION |
---|---|
where |
The filter dictionary - the keys are the field names and the values are the values to filter by. Not specifying the key means no filtering.
TYPE:
|
limit |
The maximum number of entries to return.
TYPE:
|
offset |
The number of entries to skip.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[VectorStoreEntry]
|
The entries. |
Source code in packages/ragbits-core/src/ragbits/core/vector_stores/base.py
ragbits.core.vector_stores.in_memory.InMemoryVectorStore
#
InMemoryVectorStore(default_options: VectorStoreOptions | None = None, metadata_store: MetadataStore | None = None)
Bases: VectorStore
A simple in-memory implementation of Vector Store, storing vectors in memory.
Constructs a new InMemoryVectorStore instance.
PARAMETER | DESCRIPTION |
---|---|
default_options |
The default options for querying the vector store.
TYPE:
|
metadata_store |
The metadata store to use.
TYPE:
|
Source code in packages/ragbits-core/src/ragbits/core/vector_stores/in_memory.py
from_config
classmethod
#
from_config(config: dict) -> InMemoryVectorStore
Creates and returns an instance of the InMemoryVectorStore class from the given configuration.
PARAMETER | DESCRIPTION |
---|---|
config |
A dictionary containing the configuration for initializing the InMemoryVectorStore instance.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
InMemoryVectorStore
|
An initialized instance of the InMemoryVectorStore class. |
Source code in packages/ragbits-core/src/ragbits/core/vector_stores/in_memory.py
store
async
#
store(entries: list[VectorStoreEntry]) -> None
Store entries in the vector store.
PARAMETER | DESCRIPTION |
---|---|
entries |
The entries to store.
TYPE:
|
Source code in packages/ragbits-core/src/ragbits/core/vector_stores/in_memory.py
retrieve
async
#
retrieve(vector: list[float], options: VectorStoreOptions | None = None) -> list[VectorStoreEntry]
Retrieve entries from the vector store.
PARAMETER | DESCRIPTION |
---|---|
vector |
The vector to search for.
TYPE:
|
options |
The options for querying the vector store.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[VectorStoreEntry]
|
The entries. |
Source code in packages/ragbits-core/src/ragbits/core/vector_stores/in_memory.py
list
async
#
list(where: WhereQuery | None = None, limit: int | None = None, offset: int = 0) -> list[VectorStoreEntry]
List entries from the vector store. The entries can be filtered, limited and offset.
PARAMETER | DESCRIPTION |
---|---|
where |
The filter dictionary - the keys are the field names and the values are the values to filter by. Not specifying the key means no filtering.
TYPE:
|
limit |
The maximum number of entries to return.
TYPE:
|
offset |
The number of entries to skip.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[VectorStoreEntry]
|
The entries. |
Source code in packages/ragbits-core/src/ragbits/core/vector_stores/in_memory.py
ragbits.core.vector_stores.chroma.ChromaVectorStore
#
ChromaVectorStore(client: ClientAPI, index_name: str, distance_method: Literal['l2', 'ip', 'cosine'] = 'cosine', default_options: VectorStoreOptions | None = None, metadata_store: MetadataStore | None = None)
Bases: VectorStore
Vector store implementation using Chroma.
Constructs a new ChromaVectorStore instance.
PARAMETER | DESCRIPTION |
---|---|
client |
The ChromaDB client.
TYPE:
|
index_name |
The name of the index.
TYPE:
|
distance_method |
The distance method to use.
TYPE:
|
default_options |
The default options for querying the vector store.
TYPE:
|
metadata_store |
The metadata store to use. If None, the metadata will be stored in ChromaDB.
TYPE:
|
Source code in packages/ragbits-core/src/ragbits/core/vector_stores/chroma.py
from_config
classmethod
#
from_config(config: dict) -> ChromaVectorStore
Creates and returns an instance of the ChromaVectorStore class from the given configuration.
PARAMETER | DESCRIPTION |
---|---|
config |
A dictionary containing the configuration for initializing the ChromaVectorStore instance.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ChromaVectorStore
|
An initialized instance of the ChromaVectorStore class. |
Source code in packages/ragbits-core/src/ragbits/core/vector_stores/chroma.py
store
async
#
store(entries: list[VectorStoreEntry]) -> None
Stores entries in the ChromaDB collection.
PARAMETER | DESCRIPTION |
---|---|
entries |
The entries to store.
TYPE:
|
Source code in packages/ragbits-core/src/ragbits/core/vector_stores/chroma.py
retrieve
async
#
retrieve(vector: list[float], options: VectorStoreOptions | None = None) -> list[VectorStoreEntry]
Retrieves entries from the ChromaDB collection.
PARAMETER | DESCRIPTION |
---|---|
vector |
The vector to query.
TYPE:
|
options |
The options for querying the vector store.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[VectorStoreEntry]
|
The retrieved entries. |
RAISES | DESCRIPTION |
---|---|
MetadataNotFoundError
|
If the metadata is not found. |
Source code in packages/ragbits-core/src/ragbits/core/vector_stores/chroma.py
list
async
#
list(where: WhereQuery | None = None, limit: int | None = None, offset: int = 0) -> list[VectorStoreEntry]
List entries from the vector store. The entries can be filtered, limited and offset.
PARAMETER | DESCRIPTION |
---|---|
where |
The filter dictionary - the keys are the field names and the values are the values to filter by. Not specifying the key means no filtering.
TYPE:
|
limit |
The maximum number of entries to return.
TYPE:
|
offset |
The number of entries to skip.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[VectorStoreEntry]
|
The entries. |
RAISES | DESCRIPTION |
---|---|
MetadataNotFoundError
|
If the metadata is not found. |
Source code in packages/ragbits-core/src/ragbits/core/vector_stores/chroma.py
ragbits.core.vector_stores.qdrant.QdrantVectorStore
#
QdrantVectorStore(client: AsyncQdrantClient, index_name: str, distance_method: Distance = Distance.COSINE, default_options: VectorStoreOptions | None = None, metadata_store: MetadataStore | None = None)
Bases: VectorStore
Vector store implementation using Qdrant.
Constructs a new QdrantVectorStore instance.
PARAMETER | DESCRIPTION |
---|---|
client |
An instance of the Qdrant client.
TYPE:
|
index_name |
The name of the index.
TYPE:
|
distance_method |
The distance metric to use when creating the collection.
TYPE:
|
default_options |
The default options for querying the vector store.
TYPE:
|
metadata_store |
The metadata store to use. If None, the metadata will be stored in Qdrant.
TYPE:
|
Source code in packages/ragbits-core/src/ragbits/core/vector_stores/qdrant.py
from_config
classmethod
#
from_config(config: dict) -> QdrantVectorStore
Creates and returns an instance of the QdrantVectorStore class from the given configuration.
PARAMETER | DESCRIPTION |
---|---|
config |
A dictionary containing the configuration for initializing the QdrantVectorStore instance.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
QdrantVectorStore
|
An initialized instance of the QdrantVectorStore class. |
Source code in packages/ragbits-core/src/ragbits/core/vector_stores/qdrant.py
store
async
#
store(entries: list[VectorStoreEntry]) -> None
Stores vector entries in the Qdrant collection.
PARAMETER | DESCRIPTION |
---|---|
entries |
List of VectorStoreEntry objects to store
TYPE:
|
RAISES | DESCRIPTION |
---|---|
QdrantException
|
If upload to collection fails. |
Source code in packages/ragbits-core/src/ragbits/core/vector_stores/qdrant.py
retrieve
async
#
retrieve(vector: list[float], options: VectorStoreOptions | None = None) -> list[VectorStoreEntry]
Retrieves entries from the Qdrant collection based on vector similarity.
PARAMETER | DESCRIPTION |
---|---|
vector |
The vector to query.
TYPE:
|
options |
The options for querying the vector store.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[VectorStoreEntry]
|
The retrieved entries. |
RAISES | DESCRIPTION |
---|---|
MetadataNotFoundError
|
If metadata cannot be retrieved |
Source code in packages/ragbits-core/src/ragbits/core/vector_stores/qdrant.py
list
async
#
list(where: Filter | None = None, limit: int | None = None, offset: int = 0) -> list[VectorStoreEntry]
List entries from the vector store. The entries can be filtered, limited and offset.
PARAMETER | DESCRIPTION |
---|---|
where |
Conditions for filtering results.
TYPE:
|
Reference |
https://qdrant.tech/documentation/concepts/filtering
|
limit |
The maximum number of entries to return.
TYPE:
|
offset |
The number of entries to skip.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[VectorStoreEntry]
|
The entries. |
RAISES | DESCRIPTION |
---|---|
MetadataNotFoundError
|
If the metadata is not found. |